Index: dll_init.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/dll_init.cc,v retrieving revision 1.33 diff -u -p -r1.33 dll_init.cc --- dll_init.cc 14 Nov 2002 04:29:39 -0000 1.33 +++ dll_init.cc 28 Feb 2003 13:14:41 -0000 @@ -304,35 +304,45 @@ dll_list::load_after_fork (HANDLE parent the parent had some of those. */ if (d.type == DLL_LOAD) { - HMODULE h = LoadLibraryEx (d.name, NULL, DONT_RESOLVE_DLL_REFERENCES); - - /* See if DLL will load in proper place. If so, free it and reload - it the right way. - It sort of stinks that we can't invert the order of the FreeLibrary - and LoadLibrary since Microsoft documentation seems to imply that that - should do what we want. However, since the library was loaded above, - the second LoadLibrary does not execute it's startup code unless it - is first unloaded. */ - if (h == d.handle) + HMODULE h; + if (GetVersion() < 0x80000000) /* not on 9x/Me */ { - FreeLibrary (h); - LoadLibrary (d.name); + h = LoadLibraryEx (d.name, NULL, DONT_RESOLVE_DLL_REFERENCES); + /* See if DLL will load in proper place. If so, free it and reload + it the right way. + It sort of stinks that we can't invert the order of the FreeLibrary + and LoadLibrary since Microsoft documentation seems to imply that that + should do what we want. However, since the library was loaded above, + the second LoadLibrary does not execute it's startup code unless it + is first unloaded. */ + if (h == d.handle) + { + FreeLibrary (h); + LoadLibrary (d.name); + } } - else if (try2) - api_fatal ("unable to remap %s to same address as parent(%p) != %p", - d.name, d.handle, h); - else + else /* 9x/Me */ + h = LoadLibrary (d.name); + + if (h != d.handle) { - /* It loaded in the wrong place. Dunno why this happens but it always - seems to happen when there are multiple DLLs attempting to load into - the same address space. In the "forked" process, the second DLL always - loads into a different location. */ - FreeLibrary (h); - /* Block all of the memory up to the new load address. */ - reserve_upto (d.name, (DWORD) d.handle); - try2 = 1; /* And try */ - continue; /* again. */ + if (try2) + api_fatal ("unable to remap %s to same address as parent(%p) != %p", + d.name, d.handle, h); + else + { + /* It loaded in the wrong place. Dunno why this happens but it always + seems to happen when there are multiple DLLs attempting to load into + the same address space. In the "forked" process, the second DLL always + loads into a different location. */ + FreeLibrary (h); + /* Block all of the memory up to the new load address. */ + reserve_upto (d.name, (DWORD) d.handle); + try2 = 1; /* And try */ + continue; /* again. */ + } } + /* If we reached here, and try2 is set, then there is a lot of memory to release. */ if (try2)