missing DLL_PROCESS_DETACH
-
Hi, I've been writing DLL that attaches to any process by using global hook, and I need to handle attach/detach operation. It is working fine except when I abort debugging program with msdev. I'm using Japanese version of msdev so I can't tell you the exact name of menu title to ABORT debugging, but we sometimes do that for various reasons. In that case, DllMain was not called with DLL_PROCESS_DETACH. And it seems DLL is left loaded. (The reason I think so is: I can't delete that DLL file even after I ended my application which unloads all DLLs from memory.) I'm doing this on Win2K. And not that program being debugged with msdev is not a program that loads the DLL and let attach to processes. Is that a problem by design? If someone knows any documents describing this, please let me know. Thanks. Kurotora
-
Hi, I've been writing DLL that attaches to any process by using global hook, and I need to handle attach/detach operation. It is working fine except when I abort debugging program with msdev. I'm using Japanese version of msdev so I can't tell you the exact name of menu title to ABORT debugging, but we sometimes do that for various reasons. In that case, DllMain was not called with DLL_PROCESS_DETACH. And it seems DLL is left loaded. (The reason I think so is: I can't delete that DLL file even after I ended my application which unloads all DLLs from memory.) I'm doing this on Win2K. And not that program being debugged with msdev is not a program that loads the DLL and let attach to processes. Is that a problem by design? If someone knows any documents describing this, please let me know. Thanks. Kurotora
There may be a hint in the TerminateProcess API docs: TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating. So, if 'End debugging' command is implemented with a call to TerminateProcess, your DLL won't be nofified. Tomasz Sowinski -- http://www.shooltz.com
-
Hi, I've been writing DLL that attaches to any process by using global hook, and I need to handle attach/detach operation. It is working fine except when I abort debugging program with msdev. I'm using Japanese version of msdev so I can't tell you the exact name of menu title to ABORT debugging, but we sometimes do that for various reasons. In that case, DllMain was not called with DLL_PROCESS_DETACH. And it seems DLL is left loaded. (The reason I think so is: I can't delete that DLL file even after I ended my application which unloads all DLLs from memory.) I'm doing this on Win2K. And not that program being debugged with msdev is not a program that loads the DLL and let attach to processes. Is that a problem by design? If someone knows any documents describing this, please let me know. Thanks. Kurotora
Stupid Question but.... Did you use, the FreeLibrary() function in your Aplication? Regards ;) Carlos Antollini.
-
There may be a hint in the TerminateProcess API docs: TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating. So, if 'End debugging' command is implemented with a call to TerminateProcess, your DLL won't be nofified. Tomasz Sowinski -- http://www.shooltz.com
-
Stupid Question but.... Did you use, the FreeLibrary() function in your Aplication? Regards ;) Carlos Antollini.
Carlos, Yes. My application unloads my DLLs with FreeLibrary() and do this up to 100 times until GetModuleFileName() returns 0 which means my DLLs are unloaded from memory. Normaly it's working fine. Can anyone know how to unload DLL perfectly without rebooting system? Thanks. I love Code Project, do you? Kurotora