2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS ReactX
4 * FILE: dll/directx/d3d9/d3d9_helpers.c
5 * PURPOSE: d3d9.dll helper functions
6 * PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
9 #include "d3d9_helpers.h"
13 #include "d3d9_private.h"
15 static LPCSTR D3dDebugRegPath
= "Software\\Microsoft\\Direct3D";
18 BOOL
ReadRegistryValue(IN DWORD ValueType
, IN LPCSTR ValueName
, OUT LPBYTE DataBuffer
, IN OUT LPDWORD DataBufferSize
)
24 if (ERROR_SUCCESS
!= RegOpenKeyEx(HKEY_LOCAL_MACHINE
, D3dDebugRegPath
, 0, KEY_QUERY_VALUE
, &hKey
))
27 Ret
= RegQueryValueEx(hKey
, ValueName
, 0, &Type
, DataBuffer
, DataBufferSize
);
31 if (ERROR_SUCCESS
!= Ret
)
34 if (Type
!= ValueType
)
40 HRESULT
FormatDebugString(IN OUT LPSTR Buffer
, IN LONG BufferSize
, IN LPCSTR FormatString
, ... )
46 return DDERR_INVALIDPARAMS
;
48 va_start(vargs
, FormatString
);
49 BytesWritten
= _vsnprintf(Buffer
, BufferSize
-1, FormatString
, vargs
);
51 if (BytesWritten
< BufferSize
)
54 Buffer
[BufferSize
-1] = '\0';
59 HRESULT
CreateD3D9(OUT LPDIRECT3D9
*ppDirect3D9
)
61 LPDIRECTD3D9_INT pDirect3D9
;
64 return DDERR_INVALIDPARAMS
;
66 pDirect3D9
= HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTD3D9_INT
));
69 return DDERR_OUTOFMEMORY
;
71 pDirect3D9
->unknown000007
= 0;
72 pDirect3D9
->lpInt
= 0;
74 pDirect3D9
->lpVtbl
= &Direct3D9_Vtbl
;
75 pDirect3D9
->dwProcessId
= GetCurrentThreadId();
76 pDirect3D9
->dwRefCnt
= 1;
78 *ppDirect3D9
= (IDirect3D9
*)pDirect3D9
;