diff --git a/Hooking.cpp b/Hooking.cpp index 87b90fd..cf60225 100644 --- a/Hooking.cpp +++ b/Hooking.cpp @@ -758,15 +758,6 @@ LRESULT hooked_RegularWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) // set menu focus menu->SetFocus(!focus); menu->SetVisibility(!focus); - - // disable game input -#if TRAE - *(bool*)0x8551A9 = Hooking::GetInstance().GetMenu()->IsFocus(); -#elif TR8 - *(bool*)0xA02B79 = Hooking::GetInstance().GetMenu()->IsFocus(); -#elif TR7 - *(bool*)ADDR(0x110AF09, 0x1101689) = Hooking::GetInstance().GetMenu()->IsFocus(); -#endif } // pass input to menu diff --git a/Menu.cpp b/Menu.cpp index 430cc64..f8a90f7 100644 --- a/Menu.cpp +++ b/Menu.cpp @@ -355,7 +355,7 @@ void Menu::Process(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) // if menu is focussed and being hidden also stop focus if (m_focus && !m_visible) { - m_focus = false; + SetFocus(false); } } @@ -1121,6 +1121,15 @@ FreeCameraMode Menu::GetFreeCamMode() const noexcept void Menu::SetFocus(bool value) noexcept { m_focus = value; + + // enable/disable game input +#if TRAE + * (bool*)0x8551A9 = m_focus; +#elif TR8 + * (bool*)0xA02B79 = m_focus; +#elif TR7 + * (bool*)ADDR(0x110AF09, 0x1101689) = m_focus; +#endif } bool Menu::IsVisible() const noexcept diff --git a/data/config.json b/data/config.json index e64c4ea..d829224 100644 --- a/data/config.json +++ b/data/config.json @@ -1,4 +1,4 @@ { - // Removes the ~5 seconds legal screen while starting the game. + // Removes the ~5 seconds legal screen while starting the game (Legend, Anniversary). "remove_legal_screen": true } diff --git a/dllmain.cpp b/dllmain.cpp index a6e76b8..00db1e6 100644 --- a/dllmain.cpp +++ b/dllmain.cpp @@ -17,6 +17,20 @@ BOOL WINAPI hGetVersionExA(LPOSVERSIONINFOA lpStartupInfo) return dGetVersionExA(lpStartupInfo); } +bool CheckVersion() +{ + auto hModule = GetModuleHandleA(nullptr); + auto header = (PIMAGE_NT_HEADERS)((DWORD_PTR)hModule + ((PIMAGE_DOS_HEADER)hModule)->e_lfanew); + +#if RETAIL_VERSION + // if retail check if not debug exe timestamp + return header->FileHeader.TimeDateStamp != 0x446DCF16; +#else + // if debug check for debug exe timestamp + return header->FileHeader.TimeDateStamp == 0x446DCF16; +#endif +} + DWORD WINAPI Hook(LPVOID lpParam) { MH_Initialize(); @@ -35,6 +49,15 @@ DWORD WINAPI Hook(LPVOID lpParam) BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + // since there could be retail and debug asi in same folder + // unload early if exe timestamp is wrong one +#if TR7 + if (!CheckVersion()) + { + return FALSE; + } +#endif + switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: