winemac: Call the EnumDisplayMonitors callback using a wrapper.

Ken Thomases ken at codeweavers.com
Mon Mar 14 23:50:07 CDT 2016


Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
For <https://bugs.winehq.org/show_bug.cgi?id=40297>.

 dlls/winemac.drv/display.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c
index ad01191..8d18c62 100644
--- a/dlls/winemac.drv/display.c
+++ b/dlls/winemac.drv/display.c
@@ -861,6 +861,33 @@ better:
 }
 
 
+#ifdef __i386__
+/* Some apps pass a non-stdcall callback to EnumDisplayMonitors,
+ * so we need a small assembly wrapper to call it.
+ */
+extern BOOL enum_callback_wrapper(MONITORENUMPROC proc, HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lparam);
+__ASM_GLOBAL_FUNC( enum_callback_wrapper,
+    "pushl %ebp\n\t"
+    __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
+    __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
+    "movl %esp,%ebp\n\t"
+    __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
+    "pushl 24(%ebp)\n\t"
+    "pushl 20(%ebp)\n\t"
+    "pushl 16(%ebp)\n\t"
+    "pushl 12(%ebp)\n\t"
+    "call *8(%ebp)\n\t"
+    "leave\n\t"
+    __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
+    __ASM_CFI(".cfi_same_value %ebp\n\t")
+    "ret" )
+#else
+static inline BOOL enum_callback_wrapper(MONITORENUMPROC proc, HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lparam)
+{
+    return proc(monitor, hdc, rect, lparam);
+}
+#endif /* __i386__ */
+
 /***********************************************************************
  *              EnumDisplayMonitors  (MACDRV.@)
  */
@@ -894,7 +921,7 @@ BOOL CDECL macdrv_EnumDisplayMonitors(HDC hdc, LPRECT rect, MONITORENUMPROC proc
             {
                 HMONITOR monitor = display_id_to_monitor(displays[i].displayID);
                 TRACE("monitor %d handle %p @ %s\n", i, monitor, wine_dbgstr_rect(&monrect));
-                if (!proc(monitor, hdc, &monrect, lparam))
+                if (!enum_callback_wrapper(proc, monitor, hdc, &monrect, lparam))
                 {
                     ret = FALSE;
                     break;
@@ -915,7 +942,7 @@ BOOL CDECL macdrv_EnumDisplayMonitors(HDC hdc, LPRECT rect, MONITORENUMPROC proc
             {
                 HMONITOR monitor = display_id_to_monitor(displays[i].displayID);
                 TRACE("monitor %d handle %p @ %s\n", i, monitor, wine_dbgstr_rect(&monrect));
-                if (!proc(monitor, 0, &monrect, lparam))
+                if (!enum_callback_wrapper(proc, monitor, 0, &monrect, lparam))
                 {
                     ret = FALSE;
                     break;
-- 
2.6.0




More information about the wine-patches mailing list