Skip to content

Commit

Permalink
fix: searchLength calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
igromanru committed Jun 6, 2024
1 parent 29b3720 commit 0b348f2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace Hook
// }
// DEBUG_PRINT("Game module handle: %p\n", reinterpret_cast<void*>(gameHandle));

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

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

0 comments on commit 0b348f2

Please sign in to comment.