Unloading implicitly loaded DLLs

Michael Ost most at museresearch.com
Tue Jan 3 16:45:34 CST 2006

I am looking for some expert advice in how to handle unloading
"implicitly loaded DLLs". I have found two issues. 

(1) The first is a crash that happens in dlls/ntdll/loader.c
MODULE_FlushModrefs. wine_unload_dll() is called for such a DLL, but
SectionHandle is NULL so the call crashes. 

My solution was to turn off the LDR_WINE_INTERNAL flag in
attach_implicitly_loaded_dlls() but I am not real clear what that flag
is or whether that approach is good. An alternative is to add a check
for a null SectionHeader before calling wine_unload_dll().

(2) Second is that these DLLs are DLL_PROCESS_DETACHED in
process_detach() every time _any_ DLL is unloaded. This happens because
the LoadCount is 0. I set it to -1 in attach_implicitly_loaded_dlls()
which does the trick. But again I don't know what the heck I am messing
with. Is that OK?

Attached is a diff of the two changes. I'm not looking for points for
style. But just a check on the approach for now. Thanks ... mo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: loader.c.patch
Type: text/x-patch
Size: 852 bytes
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20060103/5bc2cacb/loader.c.patch

More information about the wine-devel mailing list