Skip to content

Commit 8210565

Browse files
committed
replace offsets into signatures
1 parent 9880244 commit 8210565

File tree

2 files changed

+166
-123
lines changed

2 files changed

+166
-123
lines changed

metahook.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,31 @@ inline PVOID MH_GetModuleBase(HMODULE hModule)
1010
return (PVOID)mem.AllocationBase;
1111
}
1212

13-
inline DWORD MH_GetModuleSize(HMODULE hModule)
13+
inline LONG_PTR MH_GetModuleSize(HMODULE hModule)
1414
{
1515
return ((IMAGE_NT_HEADERS*)((LONG_PTR)hModule + ((IMAGE_DOS_HEADER*)hModule)->e_lfanew))->OptionalHeader.SizeOfImage;
1616
}
1717

18-
inline void* MH_SearchPattern(void* pStartSearch, DWORD dwSearchLen, const char* pPattern, DWORD dwPatternLen)
18+
inline void* MH_SearchPattern(void* pStartSearch, LONG_PTR dwSearchLen, const char* pPattern, LONG_PTR dwPatternLen)
1919
{
20-
LONG_PTR dwStartAddr = (LONG_PTR)pStartSearch;
21-
LONG_PTR dwEndAddr = dwStartAddr + dwSearchLen - dwPatternLen;
20+
BYTE *dwStartAddr = (BYTE *)pStartSearch;
21+
BYTE *dwEndAddr = dwStartAddr + dwSearchLen - dwPatternLen;
2222

2323
while (dwStartAddr < dwEndAddr)
2424
{
2525
bool found = true;
2626

27-
for (DWORD i = 0; i < dwPatternLen; i++)
27+
for (LONG_PTR i = 0; i < dwPatternLen; i++)
2828
{
29-
char code = *(char*)(dwStartAddr + i);
30-
if (pPattern[i] != 0x2A && pPattern[i] != code)
29+
if ((BYTE)pPattern[i] != 0x2A && (BYTE)pPattern[i] != dwStartAddr[i])
3130
{
3231
found = false;
3332
break;
3433
}
3534
}
3635

3736
if (found)
38-
return (void*)dwStartAddr;
37+
return dwStartAddr;
3938

4039
dwStartAddr++;
4140
}

0 commit comments

Comments
 (0)