From: "Erich E. Hoover" Subject: [PATCH 2/2] ddraw: Enumerate wined3d interfaces with DirectDrawEnumerateEx. Message-Id: Date: Tue, 4 Sep 2012 14:14:52 -0600 The attached patch uses wined3d to enumerate the display adapters for DirectDrawEnumerateEx, which is needed by the Battle.net System Checker in order to locate the amount of video RAM for the primary graphics card (Bug #29573). Specifically, the system checker expects that there be more devices than just the default "NULL" adapter (it expects at least one GUID-based adapter) and it expects the driver name from DirectDrawEnumerateEx to match the device name from GetAdapterIdentifier. Many thanks go to Henri Verbeet and Bruno Jesus for their comments on this patch. From 243239c521ddcd181ee1747cab4e0468798ba3e4 Mon Sep 17 00:00:00 2001 From: Erich Hoover Date: Tue, 4 Sep 2012 13:44:10 -0600 Subject: ddraw: Enumerate wined3d interfaces with DirectDrawEnumerateEx. --- dlls/ddraw/main.c | 39 ++++++++++++++++++++++++++++++++++----- 1 files changed, 34 insertions(+), 5 deletions(-) diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index b28a6c6..1c5eecc 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -374,6 +374,8 @@ HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA callback, void *context) ***********************************************************************/ HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA callback, void *context, DWORD flags) { + struct wined3d *wined3d; + TRACE("callback %p, context %p, flags %#x.\n", callback, context, flags); if (flags & ~(DDENUM_ATTACHEDSECONDARYDEVICES | @@ -384,23 +386,50 @@ HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA callback, void *contex if (flags) FIXME("flags 0x%08x not handled\n", flags); - TRACE("Enumerating default DirectDraw HAL interface\n"); + TRACE("Enumerating ddraw interfaces\n"); + wined3d = wined3d_create(7, WINED3D_LEGACY_DEPTH_BIAS); - /* We only have one driver by now */ __TRY { + /* QuickTime expects the description "DirectDraw HAL" */ static CHAR driver_desc[] = "DirectDraw HAL", driver_name[] = "display"; - - /* QuickTime expects the description "DirectDraw HAL" */ - callback(NULL, driver_desc, driver_name, context, 0); + struct wined3d_adapter_identifier adapter_id; + HRESULT hr = S_OK; + UINT adapter = 0; + BOOL cont_enum; + + /* The Battle.net System Checker expects both a NULL device and a GUID-based device */ + TRACE("Default interface: DirectDraw HAL\n"); + cont_enum = callback(NULL, driver_desc, driver_name, context, 0); + for (adapter = 0; SUCCEEDED(hr) && cont_enum; adapter++) + { + char DriverName[512] = ""; + + /* The Battle.net System Checker expects the GetAdapterIdentifier DeviceName to match the + * Driver Name, so obtain the DeviceName and GUID from D3D. */ + memset(&adapter_id, 0x0, sizeof(adapter_id)); + adapter_id.device_name = DriverName; + adapter_id.device_name_size = sizeof(DriverName); + wined3d_mutex_lock(); + hr = wined3d_get_adapter_identifier(wined3d, adapter, 0x0, &adapter_id); + wined3d_mutex_unlock(); + if (SUCCEEDED(hr)) + { + TRACE("Interface %d: %s\n", adapter, wine_dbgstr_guid(&adapter_id.device_identifier)); + cont_enum = callback(&adapter_id.device_identifier, driver_desc, + adapter_id.device_name, context, 0); + } + } } __EXCEPT_PAGE_FAULT { + wined3d_decref(wined3d); return DDERR_INVALIDPARAMS; } __ENDTRY; + wined3d_decref(wined3d); TRACE("End of enumeration\n"); return DD_OK; } -- 1.7.5.4