util: return original func address in OverwriteCall

This commit is contained in:
Ramen2X 2023-01-05 13:53:02 -05:00
parent 571261c85f
commit 9c70a965bc
2 changed files with 8 additions and 3 deletions

View file

@ -125,15 +125,20 @@ LPVOID OverwriteVirtualTable(LPVOID object, SIZE_T methodIndex, LPVOID overrideF
return originalFunction;
}
BOOL OverwriteCall(LPVOID destination, LPVOID localCall)
LPVOID OverwriteCall(LPVOID destination, LPVOID localCall)
{
char originalFunction[5];
char callInst[5];
callInst[0] = '\xE8';
*(DWORD*)(&callInst[1]) = (DWORD)localCall - ((DWORD)destination + 5);
return WriteMemory(destination, callInst, 5);
if (!WriteMemory(destination, callInst, 5, originalFunction)) {
return NULL;
}
return (LPVOID)((*(DWORD *)(originalFunction + 1)) + ((DWORD)destination + 5));
}
LPVOID SearchPattern(LPVOID imageBase, LPCVOID search, SIZE_T count)

View file

@ -5,7 +5,7 @@
BOOL WriteMemory(LPVOID destination, LPVOID source, size_t length, LPVOID oldData = NULL);
BOOL OverwriteCall(LPVOID destination, LPVOID localCall);
LPVOID OverwriteCall(LPVOID destination, LPVOID localCall);
LPVOID SearchPattern(LPVOID imageBase, LPCVOID search, SIZE_T count);