Michael Ost most@museresearch.com writes:
(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?
Yes, that seems reasonable, we can't unload these dlls anyway. And it should fix your other problem too.