Skip to content

Commit 0b348f2

Browse files
committed
fix: searchLength calculation
1 parent 29b3720 commit 0b348f2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Hook.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ namespace Hook
9191
// }
9292
// DEBUG_PRINT("Game module handle: %p\n", reinterpret_cast<void*>(gameHandle));
9393

94-
const auto moduleHandle = GetModuleHandleW(L"d3d11.dll");
94+
const auto moduleHandle = reinterpret_cast<uintptr_t>(GetModuleHandleW(L"d3d11.dll"));
9595
if (!moduleHandle)
9696
{
9797
DEBUG_PRINT("Error: Failed to get d3d11.dll module handle. LastError: %lu\n", GetLastError());
@@ -108,9 +108,9 @@ namespace Hook
108108
// }
109109
// DEBUG_PRINT("d3d11.dll module size: %lu\n", info.SizeOfImage);
110110

111-
const auto searchStart = reinterpret_cast<uintptr_t>(moduleHandle) + 0x100000;
112-
// const auto searchLength = static_cast<size_t>(info.SizeOfImage - 0x10000);
113-
constexpr auto searchLength = static_cast<size_t>(0x200000);
111+
const auto searchStart = moduleHandle + 0x100000;
112+
// const auto searchLength = static_cast<size_t>(moduleHandle + info.SizeOfImage - searchStart - 0x1000);
113+
const auto searchLength = moduleHandle + 0x200000 - searchStart;
114114
auto functionAddress = reinterpret_cast<LPVOID>(IgroWidgets::FindPattern(searchStart, searchLength,
115115
reinterpret_cast<const uint8_t*>("\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"),
116116
"xxxxxxxxxxxxxx?xxxxxxxxx???xxxxx????xxx?xxxx?xx????xx"));

0 commit comments

Comments
 (0)