From ac31e9083c7692057d19c148e69da33a3ca8e97e Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Mon, 20 Nov 2023 01:16:26 +0600 Subject: [PATCH] Add IV support --- .vscode/c_cpp_properties.json | 2 +- src/dllmain.cpp | 1 + src/hook.cpp | 20 +++++++++++++++++++- src/hook.h | 3 +++ src/pch.cpp | 2 +- src/pch.h | 2 ++ 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index b5dee91..9f25679 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -10,7 +10,7 @@ "defines": [ "_DEBUG", "_DX9_SDK_INSTALLED", - "RUNTIME_CLEO" + "RUNTIME_REDUX", ], "windowsSdkVersion": "10.0.19041.0", "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe", diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 692464e..a180b01 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -78,6 +78,7 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) { if (id == HostId::GTA3) gGameVer = eGameVer::III; if (id == HostId::VC) gGameVer = eGameVer::VC; if (id == HostId::SA) gGameVer = eGameVer::SA; + if (id == HostId::IV) gGameVer = eGameVer::IV; if (id == HostId::GTA3_UNREAL) gGameVer = eGameVer::III_DE; if (id == HostId::VC_UNREAL) gGameVer = eGameVer::VC_DE; if (id == HostId::SA_UNREAL) gGameVer = eGameVer::SA_DE; diff --git a/src/hook.cpp b/src/hook.cpp index 9fce374..3de0e01 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -50,7 +50,7 @@ void Hook::SetMouseState(bool state) { LRESULT Hook::hkWndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); - if (ImGui::GetIO().WantTextInput|| (gGameVer > eGameVer::SA && mouseVisible)) { + if (ImGui::GetIO().WantTextInput || (gGameVer > eGameVer::SA && mouseVisible)) { #ifndef _WIN64 if (gGameVer == eGameVer::SA) { reinterpret_cast(0x53F1E0)(); // CPad::ClearKeyboardHistory @@ -441,6 +441,20 @@ BOOL CALLBACK Hook::hkShowCursor(bool flag) { return oShowCursor(flag); } +void Hook::InputWatcher() +{ + while (true) + { + ImGuiIO& io = ImGui::GetIO(); + if (io.MouseDrawCursor) { + io.MouseDown[0] = (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0; + io.MouseDown[1] = (GetAsyncKeyState(VK_RBUTTON) & 0x8000) != 0; + io.MouseDown[2] = (GetAsyncKeyState(VK_MBUTTON) & 0x8000) != 0; + } + Sleep(1); + } +} + bool Hook::Inject(void *pCallback) { static bool injected; if (injected) { @@ -505,6 +519,10 @@ bool Hook::Inject(void *pCallback) { } } + if (gGameVer == eGameVer::IV) { + CreateThread(nullptr, 0, reinterpret_cast(InputWatcher), nullptr, 0, nullptr); + } + return injected; } diff --git a/src/hook.h b/src/hook.h index 299c3e1..83e5be2 100644 --- a/src/hook.h +++ b/src/hook.h @@ -54,6 +54,9 @@ class Hook { static bool GetDinputDevice(void** pMouse, size_t size); static HRESULT CALLBACK hkGetDeviceState(IDirectInputDevice8* pThis, DWORD cbData, LPVOID lpvData); + // IV + static void InputWatcher(); + public: Hook() = delete; diff --git a/src/pch.cpp b/src/pch.cpp index 8ae7aea..70d6a8d 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -1,5 +1,5 @@ #include "pch.h" eRenderer gRenderer = eRenderer::Unknown; -eGameVer gGameVer; +eGameVer gGameVer = eGameVer::Unknown; void* gD3DDevice = nullptr; diff --git a/src/pch.h b/src/pch.h index f6df2d1..aec0623 100644 --- a/src/pch.h +++ b/src/pch.h @@ -18,6 +18,8 @@ enum class eGameVer { III, VC, SA, + IV, + V, III_DE, VC_DE, SA_DE,