View Single Post
  #9  
Old 06-25-2005, 06:53
niom niom is offline
Friend
 
Join Date: Jul 2004
Posts: 21
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 0
Thanks Rcvd at 0 Times in 0 Posts
niom Reputation: 0
Code:
HRESULT __stdcall myCreateDevice(CREATEDEVICE tramp, IDirect3D9 *d3d, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface)
{
	HWND wnd;

	wnd = pPresentationParameters->hDeviceWindow;

	SetWindowPos(wnd, 0, 10, 10, 640, 480, SWP_NOZORDER);
	SetWindowLong(wnd, GWL_STYLE, WS_VISIBLE);
	SetWindowLong(wnd, GWL_EXSTYLE, 0);

	memset(pPresentationParameters, 0, sizeof(D3DPRESENT_PARAMETERS));
	pPresentationParameters->BackBufferCount = 2;
	pPresentationParameters->Windowed = TRUE;
	pPresentationParameters->SwapEffect =  D3DSWAPEFFECT_FLIP;
	pPresentationParameters->BackBufferFormat = D3DFMT_UNKNOWN;
	pPresentationParameters->hDeviceWindow = wnd;
	pPresentationParameters->EnableAutoDepthStencil = TRUE;
	pPresentationParameters->AutoDepthStencilFormat = D3DFMT_D16;
	pPresentationParameters->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	return tramp(d3d, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
}

IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
{
	IDirect3D9 *result;
	DWORD *vtable;
	HMODULE dll;
	DIRECT3DCREATE9 orgDirect3DCreate9;

	if ((dll = LoadLibrary("\\windows\\system32\\d3d9.dll")) == NULL) return NULL;

	if ((orgDirect3DCreate9 = (DIRECT3DCREATE9)GetProcAddress(dll, "Direct3DCreate9")) == NULL) return NULL;

	if ((result = orgDirect3DCreate9(SDKVersion)) == NULL) return NULL;

	vtable = *(DWORD **)result;

	hookPre(myCreateDevice, (void *)vtable[16]);		//vtable[16]: d3d->CreateDevice()

	return result;
}
Reply With Quote