Created
November 20, 2013 23:06
-
-
Save anonymous/7572848 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL WINAPI DllMain(HINSTANCE module_handle, DWORD reason_for_call, LPVOID reserved) | |
{ | |
if (reason_for_call == DLL_PROCESS_ATTACH) // Self-explanatory | |
{ | |
DisableThreadLibraryCalls(module_handle); // Disable DllMain calls for DLL_THREAD_* | |
if (reserved == NULL) // Dynamic load | |
{ | |
foobar_meow(); // Initialize your stuff or whatever | |
// Return FALSE if you don't want your module to be dynamically loaded | |
} | |
else // Static load | |
{ | |
// Return FALSE if you don't want your module to be statically loaded | |
return FALSE; | |
} | |
} | |
if (reason_for_call == DLL_PROCESS_DETACH) // Self-explanatory | |
{ | |
if (reserved == NULL) // Either loading the DLL has failed or FreeLibrary was called | |
{ | |
// Cleanup | |
} | |
else // Process is terminating | |
{ | |
// Cleanup | |
} | |
} | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment