diff --git a/ScrapHacks/ScrapHack/D3D8_Hook.h b/ScrapHacks/ScrapHack/D3D8_Hook.h index 28b44fc..8b13651 100644 --- a/ScrapHacks/ScrapHack/D3D8_Hook.h +++ b/ScrapHacks/ScrapHack/D3D8_Hook.h @@ -1,6 +1,8 @@ #pragma once +#include #include #include +#include uintmax_t frame = 0; DWORD *GetVTable(void *addr) { @@ -53,37 +55,6 @@ HRESULT WINAPI H_EndScene(LPDIRECT3DDEVICE8 dev) return hook->func(Render(dev)); } -HRESULT WINAPI H_CreateDevice(void *pDirect3D, unsigned int uiAdapter, D3DDEVTYPE pDeviceType, HWND hFocusWindow, - unsigned long ulBehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, - LPDIRECT3DDEVICE8 *ppReturnedDeviceInterface) -{ - typedef HRESULT(WINAPI * t_func)(void *, unsigned int, D3DDEVTYPE, HWND, unsigned long, D3DPRESENT_PARAMETERS *, LPDIRECT3DDEVICE8 *); - shared_ptr hook = Hook::get(H_CreateDevice); - HRESULT ret = hook->func(pDirect3D, uiAdapter, pDeviceType, hFocusWindow, ulBehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); - cout << "CreateDevice -> " << ret << endl; - void *EndScene = reinterpret_cast(GetVTable(ppReturnedDeviceInterface[0])[35]); - cout << "EndScene @ " << EndScene << endl; // EndScene - Hook::addr(EndScene, H_EndScene); - Hook::drop(H_CreateDevice); - return ret; -} - -LPDIRECT3D8 WINAPI H_Direct3DCreate8(unsigned int SDKVersion) -{ - typedef LPDIRECT3D8(_stdcall * t_func)(unsigned int); - shared_ptr hook = Hook::get(H_Direct3DCreate8); - - LPDIRECT3D8 ret = hook->func(SDKVersion); - cout << "D3D8-Create: " << SDKVersion << " -> " << ret << endl; - void *CreateDevice = reinterpret_cast(GetVTable(ret)[15]); - void *Release = reinterpret_cast(GetVTable(ret)[2]); - cout << "CreateDevice @ " << CreateDevice << endl; // CreateDevice - Hook::addr(CreateDevice, H_CreateDevice); - Hook::drop(H_Direct3DCreate8); - - return ret; -} - void unhook_d3d8() { if (hFont != INVALID_HANDLE_VALUE) @@ -99,7 +70,13 @@ void unhook_d3d8() void hook_d3d8() { + typedef void(_cdecl * t_func)(); hFont = CreateFont(20, 0, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET, 0, 0, 0, 0, "Verdana"); hBrush = CreateSolidBrush(D3DCOLOR_ARGB(25, 0, 0, 0)); - Hook::module("d3d8.dll", "Direct3DCreate8", H_Direct3DCreate8); -} \ No newline at end of file + Hook::addr(ptr(0x853954,0x2a3d8,0,4*35,0),H_EndScene); + shared_ptr hook = Hook::get(hook_d3d8); + hook->func_void(); + hook->disable(); + Hook::drop(hook_d3d8); + return; +}