Created
March 15, 2019 12:33
-
-
Save AmyrAhmady/b831dbfcf6211ff3fc772f090f73989c to your computer and use it in GitHub Desktop.
smh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool DXHook::Initialize() | |
{ | |
L_INFO << "DX Init Started"; | |
auto location = Pattern::Find("\x48\x8B\x3D\x00\x00\x00\x00\x48\x8D\x54\x24\x00\x48\x8B\x07\x48\x8B\xCF\xFF\x50\x60", "xxx????xxxx?xxxxxxxxx"); | |
while (!location) | |
{ | |
location = Pattern::Find("\x48\x8B\x3D\x00\x00\x00\x00\x48\x8D\x54\x24\x00\x48\x8B\x07\x48\x8B\xCF\xFF\x50\x60", "xxx????xxxx?xxxxxxxxx"); | |
Sleep(50); | |
} | |
L_INFO << "Got location from given pattern " << location; | |
if (location != 0) | |
{ | |
uintptr_t ppDXGISwapChain = *((uintptr_t*)location); | |
if (ppDXGISwapChain == NULL) | |
{ | |
return false; | |
} | |
IDXGISwapChain *pSwapChain = *(IDXGISwapChain **)(ppDXGISwapChain);; | |
L_INFO << "test2"; | |
if (pSwapChain != NULL) | |
{ | |
L_INFO << "getting stuff right now..."; | |
uintptr_t realSwapChainVFTable = *(uintptr_t *)(pSwapChain); | |
DWORD dwProt1 = NULL, dwProt2 = NULL; | |
VirtualProtect((LPVOID)(realSwapChainVFTable), 512, PAGE_EXECUTE_READWRITE, &dwProt1); | |
memcpy(&hkSwapChainVFTable, (const void *)(realSwapChainVFTable), 512); | |
VirtualProtect((LPVOID)(realSwapChainVFTable), 512, dwProt1, &dwProt2); | |
pRealPresent = (DXGISwapChainPresent)hkSwapChainVFTable[8]; | |
hkSwapChainVFTable[8] = (uintptr_t)dxPresent; | |
VirtualProtect((LPVOID)(pSwapChain), 4, PAGE_EXECUTE_READWRITE, &dwProt1); | |
*(uintptr_t *)(pSwapChain) = (uintptr_t)&hkSwapChainVFTable; | |
VirtualProtect((LPVOID)(pSwapChain), 4, dwProt1, &dwProt2); | |
} | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment