void Cheat::Initialize() { AllocConsole(); freopen("CON", "w", stdout); SetConsoleTitleA("CheatDll"); HWND hwnd =FindWindow(NULL, "D3D Tutorial 05: Textures"); sd.Windowed = TRUE; sd.SwapEffect = D3DSWAPEFFECT_COPY; sd.BackBufferFormat = D3DFMT_UNKNOWN; g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &sd, &D3DVT); void ** pVTable = *reinterpret_cast<void ***>(D3DVT); _DrawIndexedPrimitive = (DrawIndexedPrimitive)(pVTable[82]); printf("%d", (int)hwnd); printf("_DrawIndexedPrimitive Address:%x \n", (int)_DrawIndexedPrimitive); Hook::HookFunction((PVOID*)&_DrawIndexedPrimitive, hooks::My_DrawIndexedPrimitive); }
#include"stdafx.h" #include"hook.h" #include<detours.h> //HOOK的代码封装成函数了 void Hook::HookFunction(PVOID *oFunction, PVOID pDetour) { DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); DetourAttach(oFunction, pDetour); DetourTransactionCommit(); } void Hook::UnHookFunction(PVOID *oFunction, PVOID pDetour) { DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); DetourDetach(oFunction, pDetour); DetourTransactionCommit(); }
#include "stdafx.h" #include"hooks.h" namespace hooks { DrawIndexedPrimitive oPresent; bool bOnce = false; HRESULT __stdcall My_DrawIndexedPrimitive( LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount) { if (!bOnce) { /// } printf("666"); return oPresent(pDevice,type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount); } }
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)
万剑归宗 你不知道d3d9.dll 每次加载 地址都不一样吗[em_13] DrawIndexedPrimitive在 win7 x64上固定在 d3d9.dll+2B6B1 这个地址