mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2026-10-10 12:53:04 +08:00
- Removed low level mouse hook and replaced with DInput8 hooks instead
- Blocked in-game mouse scroll wheel when "First Person Zoom In" is being pressed down - Added E3 Def support for player orientation
This commit is contained in:
@@ -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 },
|
||||
|
||||
@@ -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*)
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
namespace EGT::ImGui_impl {
|
||||
namespace Win32 {
|
||||
extern void ToggleMouseHook(bool value);
|
||||
|
||||
extern void Init(HWND hwnd);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
namespace EGT::Menu {
|
||||
namespace Debug {
|
||||
extern ImGui::Option disableLowLevelMouseHook;
|
||||
extern ImGui::Option disableVftableScanning;
|
||||
extern ImGui::Option enableDebuggingConsole;
|
||||
|
||||
|
||||
@@ -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<ImGui::Option*>(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<bool>(entry.value)));
|
||||
break;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include <Windows.h>
|
||||
#include <dinput.h>
|
||||
#include <spdlog\spdlog.h>
|
||||
#include <ImGui\imgui_hotkey.h>
|
||||
#include <EGSDK\Utils\Hook.h>
|
||||
#include <EGSDK\Engine\CInput.h>
|
||||
#include <EGT\Menu\Menu.h>
|
||||
#include <EGT\Menu\Debug.h>
|
||||
#include <EGT\Menu\Camera.h>
|
||||
|
||||
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<void*, HRESULT(*)(IDirectInputDevice8*, unsigned long, LPDIDEVICEOBJECTDATA, unsigned long*, unsigned long), IDirectInputDevice8*, unsigned long, LPDIDEVICEOBJECTDATA, unsigned long*, unsigned long> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -64,11 +64,6 @@ namespace EGT::Menu {
|
||||
{ "CoPhysicsProperty", reinterpret_cast<void*(*)()>(&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");
|
||||
|
||||
Reference in New Issue
Block a user