From: "Erich E. Hoover" Subject: [PATCH 1/1] ddraw: Return the primary legacy ddraw device last. Message-Id: Date: Mon, 13 Oct 2014 13:16:40 -0600 Fixes bug #37307. There are a couple of other bugs that are preventing Urban Assault from working, but this fixes the problem with returning the interfaces in the wrong order. From 75b58d9fb45a75cb586db207fa64b77325173278 Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Mon, 13 Oct 2014 11:01:34 -0600 Subject: ddraw: Return the primary legacy ddraw device last. --- dlls/ddraw/main.c | 29 +++++++++++++++++++---------- dlls/ddraw/tests/ddrawmodes.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index 68bf3e3..eea245b 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -59,7 +59,7 @@ static HRESULT CALLBACK enum_callback(GUID *guid, char *description, char *drive return info->callback(guid, description, driver_name, info->context); } -static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMCALLBACKEXA callback, +static BOOL ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMCALLBACKEXA callback, void *context) { struct wined3d_adapter_identifier adapter_id; @@ -88,6 +88,17 @@ static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMC adapter_id.device_name, context, wined3d_get_adapter_monitor(wined3d, adapter)); } } + return cont_enum; +} + +static void ddraw_enumerate_primary_device(LPDDENUMCALLBACKEXA callback, void *context) +{ + /* QuickTime expects the description "DirectDraw HAL" */ + static char DriverDescription[] = "DirectDraw HAL"; + static char DriverName[] = "display"; + + TRACE("Default interface: DirectDraw HAL\n"); + callback(NULL, DriverDescription, DriverName, context, 0); } /* Handle table functions */ @@ -421,17 +432,15 @@ HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA callback, void *contex __TRY { - /* QuickTime expects the description "DirectDraw HAL" */ - static CHAR driver_desc[] = "DirectDraw HAL", - driver_name[] = "display"; - BOOL cont_enum; - - TRACE("Default interface: DirectDraw HAL\n"); - cont_enum = callback(NULL, driver_desc, driver_name, context, 0); + BOOL cont_enum = TRUE; /* The Battle.net System Checker expects both a NULL device and a GUID-based device */ - if (cont_enum && (flags & ~DDENUM_ATTACHEDSECONDARYDEVICES)) - ddraw_enumerate_secondary_devices(wined3d, callback, context); + if (flags & DDENUM_ATTACHEDSECONDARYDEVICES) + cont_enum = ddraw_enumerate_secondary_devices(wined3d, callback, context); + + /* Urban Assault expects the NULL device to be returned last */ + if(cont_enum) + ddraw_enumerate_primary_device(callback, context); } __EXCEPT_PAGE_FAULT { diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c index 39b3555..d19c698 100644 --- a/dlls/ddraw/tests/ddrawmodes.c +++ b/dlls/ddraw/tests/ddrawmodes.c @@ -222,9 +222,30 @@ static BOOL WINAPI test_count_callbackExA(GUID *lpGUID, char *lpDriverDescriptio return TRUE; } +static BOOL WINAPI test_last_callbackExA(GUID *lpGUID, char *lpDriverDescription, + char *lpDriverName, void *lpContext, HMONITOR hm) +{ + GUID **context_guid = (GUID **)lpContext; + static GUID last_guid; + + trace("test_count_callbackExA: %p %s %s %p %p\n", lpGUID, + lpDriverDescription, lpDriverName, lpContext, hm); + + if(lpGUID) + { + memcpy(&last_guid, lpGUID, sizeof(GUID)); + *context_guid = &last_guid; + } + else + *context_guid = NULL; + + return TRUE; +} + static void test_DirectDrawEnumerateExA(void) { DWORD callbackCount; + GUID *lastGUID; HRESULT ret; if (!pDirectDrawEnumerateExA) @@ -266,6 +287,20 @@ static void test_DirectDrawEnumerateExA(void) do not include any secondary devices */ ok(callbackCount >= 1, "Expected at least one device, got %d\n", callbackCount); + /* Test with valid callback parameter and return the last device */ + lastGUID = (GUID *)0xdeadbeef; + ret = pDirectDrawEnumerateExA(test_last_callbackExA, &lastGUID, + DDENUM_ATTACHEDSECONDARYDEVICES); + ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret); + /* Note: this list includes the primary devices as well and some systems (such as the TestBot) + do not include any secondary devices */ + ok(lastGUID != (GUID *)0xdeadbeef, "Expected last device to be set by callback.\n"); + if(lastGUID != (GUID *)0xdeadbeef) + { + ok(lastGUID == NULL, "Expected last device to be primary device (NULL), got %s.\n", + wine_dbgstr_guid(lastGUID)); + } + /* Test with valid callback parameter, NULL context parameter, and all flags set. */ trace("Calling DirectDrawEnumerateExA with all flags set and NULL context.\n"); ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL, -- 1.7.9.5