bool BGSSaveLoadManager::LoadGame_Hook(const char * saveName, bool unk1) { #ifdef DEBUG _MESSAGE("Executing BGSSaveLoadManager::LoadGame_Hook. saveName: %s", saveName); #endif FriendLink::PreLoadGame(); g_loadGameLock.Enter(); Serialization::SetSaveName(saveName); PluginManager::Dispatch_Message(0, SKSEMessagingInterface::kMessage_PreLoadGame, (void*)saveName, strlen(saveName), NULL); bool result = CALL_MEMBER_FN(this, LoadGame_HookTarget)(saveName, unk1); PluginManager::Dispatch_Message(0, SKSEMessagingInterface::kMessage_PostLoadGame, (void*)result, 1, NULL); Serialization::SetSaveName(NULL); g_loadGameLock.Leave(); // Clear invalid handles in OnUpdate event registration list UInt32 enableClearRegs = 0; if (GetConfigOption_UInt32("General", "ClearInvalidRegistrations", &enableClearRegs)) { if (enableClearRegs) { UInt32 count = (*g_skyrimVM)->ClearInvalidRegistrations(); if (count > 0) _MESSAGE("ClearInvalidRegistrations: Removed %d invalid OnUpdate registration(s)", count); } } #ifdef DEBUG _MESSAGE("Executed BGSSaveLoadManager::LoadGame_Hook."); #endif return result; }
void Hooks_Debug_Init(void) { GetSystemTime(&s_launchTime); UInt32 enableMiniDump = 0; GetConfigOption_UInt32("Debug", "WriteMinidumps", &enableMiniDump); if(enableMiniDump) { _MESSAGE("minidumps enabled"); // try to get dbghelp s_dbgHelpDLL = LoadLibrary("dbghelp.dll"); if(s_dbgHelpDLL) { s_dbgHelpWriteDump = (_MiniDumpWriteDump)GetProcAddress(s_dbgHelpDLL, "MiniDumpWriteDump"); if(!s_dbgHelpWriteDump) _WARNING("dbghelp missing MiniDumpWriteDump, upgrade to dbghelp 5.1 or later"); } else { _MESSAGE("no dbghelp"); } // we want to catch crashes from hook commit, apply exception filter in Init function if(s_dbgHelpDLL && s_dbgHelpWriteDump) { // precalculate as much as possible char myDocumentsPath[MAX_PATH]; ASSERT(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, myDocumentsPath))); sprintf_s(s_crashDumpPath, sizeof(s_crashDumpPath), "%s\\My Games\\Skyrim\\SKSE\\Crashdumps\\%04d-%02d-%02d_%02d.%02d.%02d.dmp", myDocumentsPath, s_launchTime.wYear, s_launchTime.wMonth, s_launchTime.wDay, s_launchTime.wHour, s_launchTime.wMinute, s_launchTime.wSecond); IFileStream::MakeAllDirs(s_crashDumpPath); // replace previous exception filter s_oldExceptionFilter = SetUnhandledExceptionFilter(ExceptionFilter); _MESSAGE("old exception filter = %08X", s_oldExceptionFilter); // disable game overwriting exception filter UInt32 thunkAddress = (UInt32)GetIATAddr((UInt8 *)GetModuleHandle(NULL), "kernel32.dll", "SetUnhandledExceptionFilter"); SafeWrite32(thunkAddress, (UInt32)SetUnhandledExceptionFilter_Hook); } } }
bool BGSSaveLoadManager::LoadGame_Hook(UInt64 *unk0, UInt32 unk1, UInt32 unk2, void *unk3) { const char *saveName = reinterpret_cast<const char *>(unk0[0xBB0 / 8]); // Game actually does this, we may as well do the same if (!saveName) saveName = ""; #ifdef DEBUG _MESSAGE("Executing BGSSaveLoadManager::LoadGame_Hook. saveName: %s", saveName); #endif g_loadGameLock.Enter(); Serialization::SetSaveName(saveName); PluginManager::Dispatch_Message(0, SKSEMessagingInterface::kMessage_PreLoadGame, (void*)saveName, strlen(saveName), NULL); bool result = CALL_MEMBER_FN(this, LoadGame_HookTarget)(unk0, unk1, unk2, unk3); PluginManager::Dispatch_Message(0, SKSEMessagingInterface::kMessage_PostLoadGame, (void*)result, 1, NULL); Serialization::SetSaveName(NULL); g_loadGameLock.Leave(); // Clear invalid handles in OnUpdate event registration list UInt32 enableClearRegs = 0; if(GetConfigOption_UInt32("General", "ClearInvalidRegistrations", &enableClearRegs)) { if(enableClearRegs) { UInt32 count = (*g_skyrimVM)->ClearInvalidRegistrations(); if (count > 0) _MESSAGE("ClearInvalidRegistrations: Removed %d invalid OnUpdate registration(s)", count); } } #ifdef DEBUG _MESSAGE("Executed BGSSaveLoadManager::LoadGame_Hook."); #endif return result; }