From 9cae851aec88f74297e85c6cc92d619f438e797d Mon Sep 17 00:00:00 2001 From: Gregor Brunmar Date: Fri, 14 Dec 2007 07:13:21 +0000 Subject: [PATCH] * Added helper function to read Direct3D registry properties * Started implementing Direct3DCreate9 svn path=/trunk/; revision=31206 --- reactos/dll/directx/d3d9/d3d9.c | 35 ++++++++++++++++++++++++- reactos/dll/directx/d3d9/d3d9.rbuild | 5 ++++ reactos/dll/directx/d3d9/d3d9_helpers.c | 34 ++++++++++++++++++++++++ reactos/dll/directx/d3d9/d3d9_helpers.h | 11 ++++++++ reactos/dll/directx/d3d9/d3d9_private.h | 12 ++++++++- 5 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 reactos/dll/directx/d3d9/d3d9_helpers.c create mode 100644 reactos/dll/directx/d3d9/d3d9_helpers.h diff --git a/reactos/dll/directx/d3d9/d3d9.c b/reactos/dll/directx/d3d9/d3d9.c index e64714070a7..9fbee835621 100644 --- a/reactos/dll/directx/d3d9/d3d9.c +++ b/reactos/dll/directx/d3d9/d3d9.c @@ -1,5 +1,15 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS ReactX + * FILE: dll/directx/d3d9/d3d9.c + * PURPOSE: d3d9.dll implementation + * PROGRAMERS: Magnus Olsen + * Gregor Brunmar + */ + #include #include "d3d9_private.h" +#include "d3d9_helpers.h" #include @@ -41,8 +51,31 @@ HRESULT DebugSetMute(DWORD dw1) DLLAPI IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) { + HINSTANCE hDebugDll; + DWORD LoadDebugDll; + DWORD LoadDebugDllSize; + LPDIRECT3D9 D3D9Obj = 0; + LPDIRECT3DCREATE9 DebugDirect3DCreate9 = 0; + UNIMPLEMENTED - return 0; + + LoadDebugDllSize = sizeof(LoadDebugDll); + if (ReadRegistryValue(REG_DWORD, "LoadDebugRuntime", (LPBYTE)&LoadDebugDll, &LoadDebugDllSize)) + { + if (0 != LoadDebugDll) + { + hDebugDll = LoadLibrary("d3d9d.dll"); + + if (0 != hDebugDll) + { + DebugDirect3DCreate9 = (LPDIRECT3DCREATE9)GetProcAddress(hDebugDll, "Direct3DCreate9"); + + D3D9Obj = DebugDirect3DCreate9(SDKVersion); + } + } + } + + return D3D9Obj; } BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) diff --git a/reactos/dll/directx/d3d9/d3d9.rbuild b/reactos/dll/directx/d3d9/d3d9.rbuild index cf23c5445b2..25cc7133e0e 100644 --- a/reactos/dll/directx/d3d9/d3d9.rbuild +++ b/reactos/dll/directx/d3d9/d3d9.rbuild @@ -2,6 +2,11 @@ + + advapi32 + kernel32 + d3d9.c + d3d9_helpers.c d3d9.rc diff --git a/reactos/dll/directx/d3d9/d3d9_helpers.c b/reactos/dll/directx/d3d9/d3d9_helpers.c new file mode 100644 index 00000000000..25925984a93 --- /dev/null +++ b/reactos/dll/directx/d3d9/d3d9_helpers.c @@ -0,0 +1,34 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS ReactX + * FILE: dll/directx/d3d9/d3d9_helpers.c + * PURPOSE: d3d9.dll helper functions + * PROGRAMERS: Gregor Brunmar + */ + +#include "d3d9_helpers.h" + + +static LPCSTR D3dDebugRegPath = "Software\\Microsoft\\Direct3D"; + +BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataBuffer, IN OUT LPDWORD DataBufferSize) +{ + HKEY hKey; + DWORD Type; + LONG Ret; + + if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, D3dDebugRegPath, 0, KEY_QUERY_VALUE, &hKey)) + return FALSE; + + Ret = RegQueryValueEx(hKey, ValueName, 0, &Type, DataBuffer, DataBufferSize); + + RegCloseKey(hKey); + + if (ERROR_SUCCESS != Ret) + return FALSE; + + if (Type != ValueType) + return FALSE; + + return TRUE; +} diff --git a/reactos/dll/directx/d3d9/d3d9_helpers.h b/reactos/dll/directx/d3d9/d3d9_helpers.h new file mode 100644 index 00000000000..f17e818ee3a --- /dev/null +++ b/reactos/dll/directx/d3d9/d3d9_helpers.h @@ -0,0 +1,11 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS ReactX + * FILE: dll/directx/d3d9/d3d9_helpers.h + * PURPOSE: d3d9.dll helper functions + * PROGRAMERS: Gregor Brunmar + */ + +#include + +BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataBuffer, IN OUT LPDWORD DataBufferSize); diff --git a/reactos/dll/directx/d3d9/d3d9_private.h b/reactos/dll/directx/d3d9/d3d9_private.h index 6c36eb85d30..af30eee55fc 100644 --- a/reactos/dll/directx/d3d9/d3d9_private.h +++ b/reactos/dll/directx/d3d9/d3d9_private.h @@ -1,8 +1,18 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS ReactX + * FILE: dll/directx/d3d9/d3d9_helpers.c + * PURPOSE: d3d9.dll helper functions + * PROGRAMERS: Gregor Brunmar + */ + #include #include #define DLLAPI __declspec(dllexport) +typedef IDirect3D9* WINAPI (*LPDIRECT3DCREATE9)(UINT); + struct _tagDIRECTD3D9_INT_ { /* 0x0000 */ LPVOID lpVtbl; /* LPDIRECTD3D9 functoions table */ @@ -11,7 +21,7 @@ struct _tagDIRECTD3D9_INT_ /* 0x0020 */ DWORD dwProcessId; /* 0x0024 */ struct _tagDIRECTD3D9_INT_ * lpInt; /* 0x0028 */ DWORD dwIntRefCnt; /* Increases and decreases by AddRef() and Release() */ -/* 0x002c */ DWORD unknown000011; /* 0x00000001 - Probably AdapterIndex */ +/* 0x002c */ DWORD unknown000011; /* 0x00000001 - Probably AdapterIndex */ /* 0x0030 */ GUID DisplayGuid; /*? Always {67685559-3106-11D0-B971-00AA00342F9F} ? */ /* 0x0040 */ CHAR DeviceName[16]; /* 0x0050 */ DWORD unknown000020; -- 2.17.1