BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: if(!dll_cs.LockCount && !dll_cs.OwningThread) InitializeCriticalSection(&dll_cs); if (!hook_cs.LockCount && !hook_cs.OwningThread) InitializeCriticalSection(&hook_cs); InitHooks(); GetCurrentConfig(&dxglcfg, true); break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: ShutdownHooks(); DeleteCriticalSection(&hook_cs); ZeroMemory(&hook_cs, sizeof(CRITICAL_SECTION)); DeleteCriticalSection(&dll_cs); ZeroMemory(&dll_cs, sizeof(CRITICAL_SECTION)); break; } return TRUE; }
bool LuaEx::Unload(char *error, size_t maxlen) { if (luavm) { UnregisterInstances(); } for (auto i = ScriptExtensions().begin(); i != ScriptExtensions().end(); ++i) { (*i)->Shutdown(); } ShutdownHooks(); return true; }
void MQ2NavigationPlugin::Plugin_Shutdown() { if (!m_initialized) return; RemoveCommand("/navigate"); RemoveMQ2Data("Navigation"); Stop(); // shut down all of the modules for (const auto& m : m_modules) { m.second->Shutdown(); } // delete all of the modules m_modules.clear(); ShutdownRenderer(); ShutdownHooks(); m_initialized = false; }
void DllStop() { #if defined(SHOW_EXE_TIMINGS) || defined(SHOW_EXE_MSGBOX) wchar_t szTimingMsg[512]; UNREFERENCED_PARAMETER(szTimingMsg); HANDLE hTimingHandle = GetStdHandle(STD_OUTPUT_HANDLE); #endif print_timings(L"DllStop"); //gbDllStopCalled = TRUE; -- в конце #ifdef HOOK_USE_DLLTHREAD DllThreadClose(); #endif #ifdef _DEBUG wchar_t *szModule = (wchar_t*)calloc((MAX_PATH+1),sizeof(wchar_t)); if (!GetModuleFileName(NULL, szModule, MAX_PATH+1)) _wcscpy_c(szModule, MAX_PATH+1, L"GetModuleFileName failed"); const wchar_t* pszName = PointToName(szModule); //if (!lstrcmpi(pszName, L"mingw32-make.exe")) // GuiMessageBox(ghConEmuWnd, L"mingw32-make.exe terminating", L"ConEmuHk", MB_SYSTEMMODAL); free(szModule); #endif // 120528 - Очистить буфер от мышиных событий, иначе получаются казусы. // Если во время выполнения команды (например "dir c: /s") // успеть дернуть мышкой - то при возврате в ФАР сразу пойдет фаровский драг if (ghConWnd) { print_timings(L"FlushMouseEvents"); FlushMouseEvents(); } #ifdef USE_PIPE_SERVER if (gpHookServer) { print_timings(L"StopPipeServer"); gpHookServer->StopPipeServer(); free(gpHookServer); gpHookServer = NULL; } #endif #ifdef _DEBUG if (ghGuiClientRetHook) { print_timings(L"unhookWindowsHookEx"); user->unhookWindowsHookEx(ghGuiClientRetHook); } #endif if (/*!gbSkipInjects &&*/ gbHooksWasSet) { print_timings(L"ShutdownHooks"); gbHooksWasSet = FALSE; // Завершить работу с реестром DoneHooksReg(); // "Закрыть" хуки ShutdownHooks(); } //if (gnRunMode == RM_APPLICATION) //{ print_timings(L"SendStopped"); SendStopped(); //} if (gpConMap) { print_timings(L"gpConMap->CloseMap"); gpConMap->CloseMap(); gpConInfo = NULL; delete gpConMap; gpConMap = NULL; } //#ifndef TESTLINK print_timings(L"CommonShutdown"); CommonShutdown(); print_timings(L"FinalizeHookedModules"); FinalizeHookedModules(); #ifndef _DEBUG HeapDeinitialize(); #endif #ifdef _DEBUG #ifdef UseDebugExceptionFilter // ?gfnPrevFilter? // Вернуть. A value of NULL for this parameter specifies default handling within UnhandledExceptionFilter. SetUnhandledExceptionFilter(NULL); #endif #endif gbDllStopCalled = TRUE; print_timings(L"DllStop - Done"); }