From: "Erich E. Hoover" Subject: [PATCH 1/2] ddraw: Convert calls to DirectDrawEnumerate into DirectDrawEnumerateEx. Message-Id: Date: Tue, 4 Sep 2012 14:13:40 -0600 The attached patch uses an internal callback routine in order to allow conversion of DirectDrawEnumerate calls into DirectDrawEnumerateEx calls. With this patch the DirectDrawEnumerate function will be able to take advantage of the improvements to DirectDrawEnumerateEx that are introduced in part 2. The patch also includes some minor formatting changes suggested by Henri Verbeet. From 13840005a3e54eb4e72de7feca8186579130c772 Mon Sep 17 00:00:00 2001 From: Erich Hoover Date: Tue, 4 Sep 2012 13:40:10 -0600 Subject: ddraw: Convert calls to DirectDrawEnumerate into DirectDrawEnumerateEx. --- dlls/ddraw/main.c | 52 ++++++++++++++++++++++++++++------------------------ 1 files changed, 28 insertions(+), 24 deletions(-) diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index 61e8ec9..b28a6c6 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -46,6 +46,22 @@ static HINSTANCE instance; /* value of ForceRefreshRate */ DWORD force_refresh_rate = 0; +/* Structure for converting DirectDrawEnumerateA to DirectDrawEnumerateExA */ +struct callback_info +{ + LPDDENUMCALLBACKA callback; + void *context; +}; + +/* Enumeration callback for converting DirectDrawEnumerateA to DirectDrawEnumerateExA */ +static HRESULT CALLBACK EnumCallback(GUID *guid, char *description, char *driver_name, + void *context, HMONITOR monitor) +{ + const struct callback_info *info = context; + + return info->callback(guid, description, driver_name, info->context); +} + /* Handle table functions */ BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size) { @@ -336,27 +352,15 @@ DirectDrawCreateEx(GUID *guid, * * ***********************************************************************/ -HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA Callback, void *Context) +HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA callback, void *context) { - TRACE("callback %p, context %p.\n", Callback, Context); - - TRACE(" Enumerating default DirectDraw HAL interface\n"); - /* We only have one driver */ - __TRY - { - static CHAR driver_desc[] = "DirectDraw HAL", - driver_name[] = "display"; + struct callback_info info; - Callback(NULL, driver_desc, driver_name, Context); - } - __EXCEPT_PAGE_FAULT - { - return DDERR_INVALIDPARAMS; - } - __ENDTRY + TRACE("callback %p, context %p.\n", callback, context); - TRACE(" End of enumeration\n"); - return DD_OK; + info.callback = callback; + info.context = context; + return DirectDrawEnumerateExA(EnumCallback, &info, 0x0); } /*********************************************************************** @@ -368,17 +372,17 @@ HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA Callback, void *Context) * The Flag member is not supported right now. * ***********************************************************************/ -HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA Callback, void *Context, DWORD Flags) +HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA callback, void *context, DWORD flags) { - TRACE("callback %p, context %p, flags %#x.\n", Callback, Context, Flags); + TRACE("callback %p, context %p, flags %#x.\n", callback, context, flags); - if (Flags & ~(DDENUM_ATTACHEDSECONDARYDEVICES | + if (flags & ~(DDENUM_ATTACHEDSECONDARYDEVICES | DDENUM_DETACHEDSECONDARYDEVICES | DDENUM_NONDISPLAYDEVICES)) return DDERR_INVALIDPARAMS; - if (Flags) - FIXME("flags 0x%08x not handled\n", Flags); + if (flags) + FIXME("flags 0x%08x not handled\n", flags); TRACE("Enumerating default DirectDraw HAL interface\n"); @@ -389,7 +393,7 @@ HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA Callback, void *Contex driver_name[] = "display"; /* QuickTime expects the description "DirectDraw HAL" */ - Callback(NULL, driver_desc, driver_name, Context, 0); + callback(NULL, driver_desc, driver_name, context, 0); } __EXCEPT_PAGE_FAULT { -- 1.7.5.4