I resolved the error
using VirtualProtect in FindPattern
PHP Code:
DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
{
DWORD dwBack;
VirtualProtect((LPVOID)dwAddress, dwLen, PAGE_EXECUTE_READWRITE, &dwBack);
for (DWORD i = 0; i < dwLen; i++)
{
if (bCompare((BYTE*)(dwAddress + i), bMask, szMask))
{
VirtualProtect((LPVOID)dwAddress, dwLen, dwBack, &dwBack);
return (DWORD)(dwAddress + i);
}
}
VirtualProtect((LPVOID)dwAddress, dwLen, dwBack, &dwBack);
return 0;
}
porem agora está causando crash
http://puu.sh/cASBT/62ba84f186.jpg
Reset
PHP Code:
HRESULT WINAPI Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
dMenu.pFont->OnLostDevice();
HRESULT hRet = pReset(pDevice, pPresentationParameters);
dMenu.pFont->OnResetDevice();
return hRet;
}
EndScene
PHP Code:
HRESULT WINAPI EndScene(LPDIRECT3DDEVICE9 pDevice)
{
ReFont(pDevice);
dMenu.BuildMenu("~ WgetProgramer ~", 10, 0, 700, 2000, YELLOW, BLACK, RED, pDevice);
WoWThread();
return pEndScene(pDevice);
}
D3DHook
PHP Code:
int D3Dinit(void)
{
DWORD hD3D, adr, *vtbl;
hD3D = 0;
do
{
hD3D = (DWORD)GetModuleHandle("d3d9.dll");
Sleep(10);
} while (!hD3D);
adr = FindPattern((DWORD)GetModuleHandle("d3d9.dll"), 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
if (adr)
{
memcpy(&vtbl, (void *)(adr + 2), 4);
pReset = (oReset)DetourFunction((PBYTE)vtbl[16], (PBYTE)Reset, 5);
pEndScene = (oEndScene)DetourFunction((PBYTE)vtbl[42], (PBYTE)EndScene, 5);
}
return 0;
}