/****************************** Public Functions *****************************/ EXTERN_C BOOL WINAPI DllMain(HINSTANCE hmod, DWORD dwReason, PVOID pvReserved) { switch (dwReason) { case DLL_PROCESS_ATTACH: { return AttachProcess(hmod); } case DLL_THREAD_ATTACH: ThreadContextTLSEntry::InitializeThread(); #ifdef HEAP_TRACK_ALLOC HeapAllocator::InitializeThread(); #endif return TRUE; case DLL_THREAD_DETACH: // If we are not doing DllCanUnloadNow, so we should clean up. Otherwise, DllCanUnloadNow is already running, // so the ThreadContext global lock is already taken. If we try to clean up, we will block on the ThreadContext // global lock while holding the loader lock, which DllCanUnloadNow may block on waiting for thread termination // which requires the loader lock. DllCanUnloadNow will clean up for us anyway, so we can just skip the whole thing. ThreadBoundThreadContextManager::DestroyContextAndEntryForCurrentThread(); return TRUE; case DLL_PROCESS_DETACH: lockedDll = ::DeleteAtom(lockedDll); AssertMsg(lockedDll == 0, "Failed to release the lock for chakracore.dll"); #ifdef DYNAMIC_PROFILE_STORAGE DynamicProfileStorage::Uninitialize(); #endif #ifdef ENABLE_JS_ETW // Do this before DetachProcess() so that we won't have ETW rundown callbacks while destroying threadContexts. EtwTrace::UnRegister(); #endif #ifdef VTUNE_PROFILING VTuneChakraProfile::UnRegister(); #endif // don't do anything if we are in forceful shutdown // try to clean up handles in graceful shutdown if (pvReserved == NULL) { DetachProcess(); } #if defined(CHECK_MEMORY_LEAK) || defined(LEAK_REPORT) else { ThreadBoundThreadContextManager::DestroyAllContexts(); DetachProcess(); ThreadContext::ReportAndCheckLeaksOnProcessDetach(); } #endif return TRUE; default: AssertMsg(FALSE, "DllMain() called with unrecognized dwReason."); return FALSE; } }
// // Cleanup symbol tables // int ShFinalize() { if (!DetachProcess()) return 0; return 1; }
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: if (!InitProcess()) return FALSE; break; case DLL_THREAD_ATTACH: if (!InitThread()) return FALSE; break; case DLL_THREAD_DETACH: if (!DetachThread()) return FALSE; break; case DLL_PROCESS_DETACH: DetachProcess(); break; default: assert(0 && "DllMain(): Reason for calling DLL Main is unknown"); return FALSE; } return TRUE; }
// // Cleanup symbol tables // bool ShFinalize() { if (isInitialized) { DetachProcess(); isInitialized = false; } return true; }
// // Cleanup symbol tables // int ShFinalize() { DetachProcess(); return 1; }
int C_DECL Hlsl2Glsl_Shutdown() { return DetachProcess(); }