From 0b348f29fa52ec51dd4d0dcd09aa4bf35f5e17e9 Mon Sep 17 00:00:00 2001 From: igromanru Date: Thu, 6 Jun 2024 17:44:17 +0200 Subject: [PATCH] fix: searchLength calculation --- src/Hook.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Hook.cpp b/src/Hook.cpp index 8aa17b3..952b757 100644 --- a/src/Hook.cpp +++ b/src/Hook.cpp @@ -91,7 +91,7 @@ namespace Hook // } // DEBUG_PRINT("Game module handle: %p\n", reinterpret_cast(gameHandle)); - const auto moduleHandle = GetModuleHandleW(L"d3d11.dll"); + const auto moduleHandle = reinterpret_cast(GetModuleHandleW(L"d3d11.dll")); if (!moduleHandle) { DEBUG_PRINT("Error: Failed to get d3d11.dll module handle. LastError: %lu\n", GetLastError()); @@ -108,9 +108,9 @@ namespace Hook // } // DEBUG_PRINT("d3d11.dll module size: %lu\n", info.SizeOfImage); - const auto searchStart = reinterpret_cast(moduleHandle) + 0x100000; - // const auto searchLength = static_cast(info.SizeOfImage - 0x10000); - constexpr auto searchLength = static_cast(0x200000); + const auto searchStart = moduleHandle + 0x100000; + // const auto searchLength = static_cast(moduleHandle + info.SizeOfImage - searchStart - 0x1000); + const auto searchLength = moduleHandle + 0x200000 - searchStart; auto functionAddress = reinterpret_cast(IgroWidgets::FindPattern(searchStart, searchLength, reinterpret_cast("\x48\x89\x5C\x24\x08\x48\x89\x74\x24\x10\x57\x48\x83\xEC\x00\x41\x8B\xF0\x48\x8B\xDA\x48\x8D\xB9\x00\x00\x00\xFF\x48\x8B\xCF\xE8\x00\x00\x00\x00\x84\xC0\x74\x00\x48\x85\xDB\x74\x00\x8B\x8B\x00\x00\x00\x00\x8B\x93"), "xxxxxxxxxxxxxx?xxxxxxxxx???xxxxx????xxx?xxxx?xx????xx"));