FreeLibrary and DLLMain
Posted on 2006-04-13
Now, I have a DLL (DLL A) that calls a second DLL (DLL B) to build a function upcall table. These functions are used throughout the life of DLL A by other external processes. Now, my question is... since this upcall table needs to be valid for the lifetime of DLL A, how can I free the reference to DLL B since I cannot call FreeLibrary from DllMain during PROCESS_DETACH?
I do not have access to the other applications that use this upcall table, so the idea of having a special function called prior to unload that would clean everything up isn't going to work.
How can I cleanly unload DLL B when DLL A is about to exit?