Author: gbrunmar
Date: Thu Feb 7 20:32:49 2008
New Revision: 32190
URL:
http://svn.reactos.org/svn/reactos?rev=32190&view=rev
Log:
* Fixed d3d9 critical section not being unlocked in GetAdapterIdentifier
* Implemeted IDirect3D9::GetAdapterMonitor
Modified:
trunk/reactos/dll/directx/d3d9/adapter.c
trunk/reactos/dll/directx/d3d9/adapter.h
trunk/reactos/dll/directx/d3d9/d3d9_helpers.c
trunk/reactos/dll/directx/d3d9/d3d9_impl.c
Modified: trunk/reactos/dll/directx/d3d9/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/adapter.c…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/adapter.c (original)
+++ trunk/reactos/dll/directx/d3d9/adapter.c Thu Feb 7 20:32:49 2008
@@ -10,10 +10,19 @@
#include <d3d9.h>
#include <ddraw.h>
#include <strsafe.h>
+#include "adapter.h"
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
typedef BOOL (WINAPI *LPFN_DISABLEWOW64FSREDIRECTION) (PVOID*);
typedef BOOL (WINAPI *LPFN_REVERTWOW64FSREDIRECTION) (PVOID);
+
+
+typedef struct _ADAPTERMONITOR
+{
+ LPCSTR lpszDeviceName;
+ HMONITOR hMonitor;
+} ADAPTERMONITOR, *LPADAPTERMONITOR;
+
static BOOL GetDriverName(LPDISPLAY_DEVICEA pDisplayDevice, D3DADAPTER_IDENTIFIER9*
pIdentifier)
{
@@ -156,3 +165,33 @@
return TRUE;
}
+
+static BOOL CALLBACK AdapterMonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT
lprcMonitor, LPARAM dwData)
+{
+ MONITORINFOEXA MonitorInfoEx;
+ LPADAPTERMONITOR lpAdapterMonitor = (LPADAPTERMONITOR)dwData;
+
+ memset(&MonitorInfoEx, 0, sizeof(MONITORINFOEXA));
+ MonitorInfoEx.cbSize = sizeof(MONITORINFOEXA);
+
+ GetMonitorInfoA(hMonitor, (LPMONITORINFO)&MonitorInfoEx);
+
+ if (_stricmp(lpAdapterMonitor->lpszDeviceName, MonitorInfoEx.szDevice) == 0)
+ {
+ lpAdapterMonitor->hMonitor = hMonitor;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+HMONITOR GetAdapterMonitor(LPCSTR lpszDeviceName)
+{
+ ADAPTERMONITOR AdapterMonitor;
+ AdapterMonitor.lpszDeviceName = lpszDeviceName;
+ AdapterMonitor.hMonitor = NULL;
+
+ EnumDisplayMonitors(NULL, NULL, AdapterMonitorEnumProc,
(LPARAM)&AdapterMonitor);
+
+ return AdapterMonitor.hMonitor;
+}
Modified: trunk/reactos/dll/directx/d3d9/adapter.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/adapter.h…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/adapter.h (original)
+++ trunk/reactos/dll/directx/d3d9/adapter.h Thu Feb 7 20:32:49 2008
@@ -11,4 +11,6 @@
BOOL GetAdapterInfo(LPCSTR lpszDeviceName, D3DADAPTER_IDENTIFIER9* pIdentifier);
+HMONITOR GetAdapterMonitor(LPCSTR lpszDeviceName);
+
#endif
Modified: trunk/reactos/dll/directx/d3d9/d3d9_helpers.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_help…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_helpers.c (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_helpers.c Thu Feb 7 20:32:49 2008
@@ -18,6 +18,9 @@
LPDIRECT3D9_INT impl_from_IDirect3D9(LPDIRECT3D9 iface)
{
+ if (IsBadWritePtr(iface, sizeof(LPDIRECT3D9_INT)))
+ return NULL;
+
return (LPDIRECT3D9_INT)((ULONG_PTR)iface - FIELD_OFFSET(DIRECT3D9_INT, lpVtbl));
}
Modified: trunk/reactos/dll/directx/d3d9/d3d9_impl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_impl…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_impl.c (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_impl.c Thu Feb 7 20:32:49 2008
@@ -69,7 +69,7 @@
* @param LPDIRECT3D iface
* Pointer to the IDirect3D object returned from Direct3DCreate9()
*
-* @return
+* @return UINT
* The number of display adapters on the system when Direct3DCreate9() was called.
*
*/
@@ -107,7 +107,7 @@
* Pointer to a D3DADAPTER_IDENTIFIER9 structure to be filled with the available
information
* about the display adapter.
*
-* @return
+* @return HRESULT
* If the method successfully fills the pIdentified structure, the return value is
D3D_OK.
* If Adapter is out of range, Flags is invalid or pIdentifier is a bad pointer, the
return value
* will be D3DERR_INVALIDCALL.
@@ -148,6 +148,7 @@
return D3DERR_INVALIDCALL;
}
+ UNLOCK_D3D9();
return D3D_OK;
}
@@ -223,11 +224,43 @@
return D3D_OK;
}
+/*++
+* @name IDirect3D9::GetAdapterMonitor
+* @implemented
+*
+* The function IDirect3D9Impl_GetAdapterMonitor returns the monitor associated
+* with the specified display adapter.
+*
+* @param LPDIRECT3D iface
+* Pointer to the IDirect3D object returned from Direct3DCreate9()
+*
+* @param UINT Adapter
+* Adapter index to get information about. D3DADAPTER_DEFAULT is the primary display.
+* The maximum value for this is the value returned by IDirect3D::GetAdapterCount().
+*
+* @return HMONITOR
+* If the method successfully it returns the HMONITOR belonging to the specified adapter.
+* If the method fails, the return value is NULL.
+*
+*/
static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter)
{
- UNIMPLEMENTED
-
- return NULL;
+ HMONITOR hAdapterMonitor = NULL;
+
+ LPDIRECT3D9_INT This = impl_from_IDirect3D9(iface);
+ LOCK_D3D9();
+
+ if (Adapter < This->NumDisplayAdapters)
+ {
+ hAdapterMonitor =
GetAdapterMonitor(This->DisplayAdapters[Adapter].szDeviceName);
+ }
+ else
+ {
+ DPRINT1("Invalid Adapter number specified");
+ }
+
+ UNLOCK_D3D9();
+ return hAdapterMonitor;
}
static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter,
D3DDEVTYPE DeviceType,