BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) { STATIC_CONTRACT_NOTHROW; switch (dwReason) { case DLL_PROCESS_ATTACH: { // Save the module handle. g_hThisInst = (HINSTANCE)hInstance; #ifndef FEATURE_CORECLR // clr.dll cannot be unloaded // Normally the shim prevents it from ever being unloaded, but we now support fusion loading // us directly, so we need to take an extra ref on our handle to ensure we don't get unloaded. if (FAILED(clr::win32::PreventModuleUnload(g_hThisInst))) { return FALSE; } #endif // FEATURE_CORECLR // Prevent buffer-overruns // If buffer is overrun, it is possible the saved callback has been trashed. // The callback is unsafe. //SetBufferOverrunHandler(); if (!EEDllMain((HINSTANCE)hInstance, dwReason, lpReserved)) { return FALSE; } #ifdef FEATURE_MERGE_JIT_AND_ENGINE jitOnDllProcessAttach(); #endif // FEATURE_MERGE_JIT_AND_ENGINE } break; case DLL_PROCESS_DETACH: { EEDllMain((HINSTANCE)hInstance, dwReason, lpReserved); #ifdef FEATURE_MERGE_JIT_AND_ENGINE jitOnDllProcessDetach(); #endif // FEATURE_MERGE_JIT_AND_ENGINE } break; case DLL_THREAD_DETACH: { EEDllMain((HINSTANCE)hInstance, dwReason, lpReserved); } break; } return TRUE; }
BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID pvReserved) { if (dwReason == DLL_PROCESS_ATTACH) { g_hInst = (HINSTANCE)hInstance; DisableThreadLibraryCalls((HINSTANCE)hInstance); #ifdef SELF_NO_HOST jitOnDllProcessAttach(); g_fClrCallbacksInit = TRUE; #endif } else if (dwReason == DLL_PROCESS_DETACH) { if (g_fClrCallbacksInit) jitOnDllProcessDetach(); } return TRUE; }