diff --git a/EGameSDK/Offsets.cpp b/EGameSDK/Offsets.cpp index bb7f579..23131fd 100644 --- a/EGameSDK/Offsets.cpp +++ b/EGameSDK/Offsets.cpp @@ -36,6 +36,7 @@ namespace EGSDK { { GetOffsetNameFromClassMember(&GamePH::LocalClientDI::pPlayerDI_PH), 0x88 }, { GetOffsetNameFromClassMember(&GamePH::PlayerDI_PH::pCoPhysicsProperty), 0xE8 }, { GetOffsetNameFromClassMember(&GamePH::PlayerDI_PH::pInventoryContainerDI), 0x550 }, + { GetOffsetNameFromClassMember(&GamePH::PlayerDI_PH::nextPlayerOrientation), 0xC68 }, { GetOffsetNameFromClassMember(&GamePH::PlayerDI_PH::restrictionsEnabled), 0x2CF0 }, { GetOffsetNameFromClassMember(&GamePH::PlayerDI_PH::enableTPPModel1), 0x2DC1 }, { GetOffsetNameFromClassMember(&GamePH::PlayerDI_PH::enableTPPModel2), 0x2DC2 }, diff --git a/EGameSDK/include/EGSDK/Offsets.h b/EGameSDK/include/EGSDK/Offsets.h index 8695c01..d4979f3 100644 --- a/EGameSDK/include/EGSDK/Offsets.h +++ b/EGameSDK/include/EGSDK/Offsets.h @@ -48,6 +48,7 @@ namespace EGSDK { // Input related AddPattern(CInput, "engine_x64_rwdi.dll", "48 8B 0D [?? ?? ?? ?? 48 85 C9 74 ?? 48 8B 01 84 D2", Utils::SigScan::PatternType::RelativePointer, uint64_t**) // g_CInput + AddPattern(CDIDev_GetDeviceData, "dinput8.dll", "40 53 57 48 83 EC ?? 48 8B 01", Utils::SigScan::PatternType::Address, void*) // Rendering related AddPattern(DXPresent, "sl.interposer.dll", "48 89 5C 24 ?? 48 89 74 24 ?? 57 41 56", Utils::SigScan::PatternType::Address, void*) diff --git a/EGameTools/include/EGT/ImGui_impl/Win32_impl.h b/EGameTools/include/EGT/ImGui_impl/Win32_impl.h index 59ce3cd..ce0d8be 100644 --- a/EGameTools/include/EGT/ImGui_impl/Win32_impl.h +++ b/EGameTools/include/EGT/ImGui_impl/Win32_impl.h @@ -3,8 +3,6 @@ namespace EGT::ImGui_impl { namespace Win32 { - extern void ToggleMouseHook(bool value); - extern void Init(HWND hwnd); } } \ No newline at end of file diff --git a/EGameTools/include/EGT/Menu/Debug.h b/EGameTools/include/EGT/Menu/Debug.h index bd5b86b..6a3ac18 100644 --- a/EGameTools/include/EGT/Menu/Debug.h +++ b/EGameTools/include/EGT/Menu/Debug.h @@ -3,7 +3,6 @@ namespace EGT::Menu { namespace Debug { - extern ImGui::Option disableLowLevelMouseHook; extern ImGui::Option disableVftableScanning; extern ImGui::Option enableDebuggingConsole; diff --git a/EGameTools/src/Config/Config.cpp b/EGameTools/src/Config/Config.cpp index e239294..f737054 100644 --- a/EGameTools/src/Config/Config.cpp +++ b/EGameTools/src/Config/Config.cpp @@ -121,7 +121,6 @@ namespace EGT::Config { { "Misc:GameChecks", "IncreaseDataPAKsLimit", Menu::Misc::increaseDataPAKsLimit.GetValue(), &Menu::Misc::increaseDataPAKsLimit, OPTION }, { "World:Time", "SlowMotionSpeed", Menu::World::slowMotionSpeed, &Menu::World::slowMotionSpeed, Float }, { "World:Time", "SlowMotionTransitionTime", Menu::World::slowMotionTransitionTime, &Menu::World::slowMotionTransitionTime, Float }, - { "Debug:Misc", "DisableLowLevelMouseHook", Menu::Debug::disableLowLevelMouseHook.GetValue(), &Menu::Debug::disableLowLevelMouseHook, OPTION }, { "Debug:Misc", "DisableVftableScanning", Menu::Debug::disableVftableScanning.GetValue(), &Menu::Debug::disableVftableScanning, OPTION }, { "Debug:Misc", "EnableDebuggingConsole", Menu::Debug::enableDebuggingConsole.GetValue(), &Menu::Debug::enableDebuggingConsole, OPTION } }); @@ -231,12 +230,6 @@ namespace EGT::Config { ImGui::Option* option = reinterpret_cast(entry.optionPtr); if (option->GetChangesAreDisabled()) break; -#ifdef _DEBUG - if (entry.key == "DisableLowLevelMouseHook") { - option->SetBothValues(true); - break; - } -#endif option->SetBothValues(reader.Get(entry.section.data(), entry.key.data(), std::any_cast(entry.value))); break; diff --git a/EGameTools/src/ImGui_impl/Win32_impl.cpp b/EGameTools/src/ImGui_impl/Win32_impl.cpp index 4df7712..cea5ac3 100644 --- a/EGameTools/src/ImGui_impl/Win32_impl.cpp +++ b/EGameTools/src/ImGui_impl/Win32_impl.cpp @@ -1,9 +1,11 @@ #include +#include #include #include +#include #include #include -#include +#include extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); @@ -11,7 +13,6 @@ namespace EGT::ImGui_impl { namespace Win32 { static HWND gHwnd = nullptr; static WNDPROC oWndProc = nullptr; - static HHOOK oMouseProc = nullptr; static LRESULT __stdcall hkWindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) { switch (uMsg) { @@ -82,90 +83,45 @@ namespace EGT::ImGui_impl { return CallWindowProcA(oWndProc, hwnd, uMsg, wParam, lParam); } - static LRESULT CALLBACK hkMouseProc(int nCode, WPARAM wParam, LPARAM lParam) { - if (nCode != HC_ACTION) - return CallNextHookEx(oMouseProc, nCode, wParam, lParam); - if (GetForegroundWindow() != gHwnd) - return CallNextHookEx(oMouseProc, nCode, wParam, lParam); + static EGSDK::Utils::Hook::MHook CDIDev_GetDeviceDataHook{ "CDIDev_GetDeviceData", &EGSDK::OffsetManager::Get_CDIDev_GetDeviceData, [](IDirectInputDevice8* device, unsigned long cbObjectData, LPDIDEVICEOBJECTDATA rgdod, unsigned long* pdwInOut, unsigned long dwFlags) -> HRESULT { + HRESULT result = CDIDev_GetDeviceDataHook.ExecuteOriginal(device, cbObjectData, rgdod, pdwInOut, dwFlags); - switch (wParam) { - case WM_MOUSEWHEEL: - case WM_MOUSEHWHEEL: - { - MSLLHOOKSTRUCT* pMouseStruct = (MSLLHOOKSTRUCT*)lParam; - if (pMouseStruct == nullptr) - break; + if (!rgdod || !pdwInOut || *pdwInOut == 0) + return result; + + unsigned int validEvents = 0; + for (unsigned int i = 0; i < *pdwInOut; i++) { + if (rgdod[i].dwOfs == DIMOFS_Z) { + long scrollDelta = rgdod[i].dwData; - if (GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData)) { - if (Menu::firstTimeRunning.GetValue()) - break; for (auto& option : *ImGui::KeyBindOption::GetInstances()) { if (option->GetChangesAreDisabled()) continue; - if ((option->GetKeyBind() == VK_MWHEELUP && GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) > 0) || - (option->GetKeyBind() == VK_MWHEELDOWN && GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) < 0)) + if ((option->GetKeyBind() == VK_MWHEELUP && scrollDelta > 0) || + (option->GetKeyBind() == VK_MWHEELDOWN && scrollDelta < 0)) option->Toggle(); } - if (GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) > 0) + if (scrollDelta > 0) ImGui::KeyBindOption::scrolledMouseWheelUp = true; - else if (GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) < 0) + else if (scrollDelta < 0) ImGui::KeyBindOption::scrolledMouseWheelDown = true; + + if (Menu::Camera::firstPersonZoomIn.IsKeyDown()) + continue; } - break; - } + rgdod[validEvents++] = rgdod[i]; } - return CallNextHookEx(oMouseProc, nCode, wParam, lParam); - } - static void MouseHkMsgLoop() { - MSG msg{}; - while (oMouseProc) { - if (oMouseProc && GetMessageA(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessageA(&msg); - } - } - } + *pdwInOut = validEvents; - static void EnableMouseHook() { - if (oMouseProc) - return; - - std::thread([]() { - if (oMouseProc) - return; - - oMouseProc = SetWindowsHookExA(WH_MOUSE_LL, hkMouseProc, GetModuleHandleA(nullptr), 0); - if (!oMouseProc) { - SPDLOG_ERROR("Failed to enable low level mouse hook; mouse input-related functions (such as FreeCam speed changing through the scrollwheel) may not work"); - return; - } - - MouseHkMsgLoop(); - }).detach(); - } - static void DisableMouseHook() { - if (!oMouseProc) - return; - - UnhookWindowsHookEx(oMouseProc); - oMouseProc = nullptr; - } - void ToggleMouseHook(bool disableLowLevelMouseHook) { - if (disableLowLevelMouseHook) - DisableMouseHook(); - else - EnableMouseHook(); - } + return result; + } }; void Init(HWND hwnd) { gHwnd = hwnd; oWndProc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)hkWindowProc); - - if (!Menu::Debug::disableLowLevelMouseHook.GetValue()) - EnableMouseHook(); } } } \ No newline at end of file diff --git a/EGameTools/src/Menu/Camera.cpp b/EGameTools/src/Menu/Camera.cpp index 743ba52..95b7c5c 100644 --- a/EGameTools/src/Menu/Camera.cpp +++ b/EGameTools/src/Menu/Camera.cpp @@ -75,11 +75,9 @@ namespace EGT::Menu { static int zoomLevel = 0; if (iLevel && iLevel->IsLoaded() && viewCam) { - auto shit = viewCam->GetViewMatrix(); - if (goProMode.GetValue()) { if (goProMode.HasChangedTo(true)) { - previousFirstPersonFOV = firstPersonFOV; + previousFirstPersonFOV = viewCam->GetFOV(); goProMode.SetPrevValue(true); } @@ -88,8 +86,6 @@ namespace EGT::Menu { } else if (goProMode.HasChangedTo(false)) { firstPersonFOV = previousFirstPersonFOV; goProMode.SetPrevValue(false); - - viewCam->SetFOV(firstPersonFOV); } } @@ -98,7 +94,7 @@ namespace EGT::Menu { if (firstPersonZoomIn.IsKeyPressed()) { hasChangedZoomLevel = true; if (!isZoomingIn) { - originalFirstPersonFOVAfterZoomIn = firstPersonFOV; + originalFirstPersonFOVAfterZoomIn = viewCam->GetFOV(); previousFirstPersonFOV = originalFirstPersonFOVAfterZoomIn; } else previousFirstPersonFOV = firstPersonFOV; diff --git a/EGameTools/src/Menu/Debug.cpp b/EGameTools/src/Menu/Debug.cpp index c7c2aa1..88ac518 100644 --- a/EGameTools/src/Menu/Debug.cpp +++ b/EGameTools/src/Menu/Debug.cpp @@ -64,11 +64,6 @@ namespace EGT::Menu { { "CoPhysicsProperty", reinterpret_cast(&EGSDK::Engine::CoPhysicsProperty::Get) } }; -#ifdef _DEBUG - ImGui::Option disableLowLevelMouseHook{ true }; -#else - ImGui::Option disableLowLevelMouseHook { false }; -#endif ImGui::Option disableVftableScanning { false }; #ifdef _DEBUG ImGui::Option enableDebuggingConsole { true }; @@ -107,8 +102,6 @@ namespace EGT::Menu { void Tab::Update() {} void Tab::Render() { ImGui::SeparatorText("Misc##Debug"); - if (ImGui::Checkbox("Disable Low Level Mouse Hook", &disableLowLevelMouseHook, "Disables the low level mouse hook that is used to capture mouse input in the game; this option is used for debugging purposes")) - ImGui_impl::Win32::ToggleMouseHook(disableLowLevelMouseHook.GetValue()); if (ImGui::Checkbox("Disable Vftable Scanning", &disableVftableScanning, "Disables the vftable scanning for classes that are used in the game and used to validate a class in memory; this option is used for debugging purposes")) EGSDK::ClassHelpers::SetIsVftableScanningDisabled(disableVftableScanning.GetValue()); ImGui::Checkbox("Enable Debugging Console *", &enableDebuggingConsole, "Enables EGameTools' debugging console that shows up when starting up the game; this option is used for debugging purposes");