From 1b69aae3f45666cb3fd72ea8fcd3a739cac068f6 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sat, 17 Sep 2022 19:04:26 +0200 Subject: [PATCH] winemac: Use platform-independent types for user callback params. --- dlls/winemac.drv/dllmain.c | 13 +++++++------ dlls/winemac.drv/dragdrop.c | 6 +++--- dlls/winemac.drv/event.c | 16 ++++++++-------- dlls/winemac.drv/image.c | 9 +++++---- dlls/winemac.drv/ime.c | 11 ++++++----- dlls/winemac.drv/unixlib.h | 27 ++++++++++++++++----------- 6 files changed, 45 insertions(+), 37 deletions(-) diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index ac03ec360ce..083c539dd26 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -245,7 +245,7 @@ static BOOL CALLBACK get_first_resource(HMODULE module, LPCWSTR type, LPWSTR nam static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) { struct app_icon_params *params = arg; - struct app_icon_result *result = params->result; + struct app_icon_result *result = param_ptr(params->result); HRSRC res_info; HGLOBAL res_data; GRPICONDIR *icon_dir; @@ -337,17 +337,18 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) if (!memcmp(icon_bits, png_magic, sizeof(png_magic))) { - entry->png = icon_bits; + entry->png = (UINT_PTR)icon_bits; entry->icon = 0; result->count++; } else { - entry->icon = CreateIconFromResourceEx(icon_bits, icon_dir->idEntries[i].dwBytesInRes, - TRUE, 0x00030000, width, height, 0); - if (entry->icon) + HICON icon = CreateIconFromResourceEx(icon_bits, icon_dir->idEntries[i].dwBytesInRes, + TRUE, 0x00030000, width, height, 0); + if (icon) { - entry->png = NULL; + entry->icon = HandleToUlong(icon); + entry->png = 0; result->count++; } else diff --git a/dlls/winemac.drv/dragdrop.c b/dlls/winemac.drv/dragdrop.c index afd4fb0a6d2..707e9708a01 100644 --- a/dlls/winemac.drv/dragdrop.c +++ b/dlls/winemac.drv/dragdrop.c @@ -428,7 +428,7 @@ NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) BOOL ret = FALSE; POINT pt; - TRACE("win %p x,y %d,%d effect %x pasteboard %s\n", params->hwnd, params->x, params->y, + TRACE("win %x x,y %d,%d effect %x pasteboard %s\n", params->hwnd, params->x, params->y, params->effect, wine_dbgstr_longlong(params->handle)); pt.x = params->x; @@ -511,7 +511,7 @@ NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) { struct dnd_query_exited_params *params = arg; - HWND hwnd = params->hwnd; + HWND hwnd = UlongToHandle(params->hwnd); IDropTarget *droptarget; TRACE("win %p\n", hwnd); @@ -542,7 +542,7 @@ NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) { struct dnd_query_drag_params *params = arg; - HWND hwnd = params->hwnd; + HWND hwnd = UlongToHandle(params->hwnd); BOOL ret = FALSE; POINT pt; DWORD effect; diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index ef1ab23bb1d..6ca46f55dff 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -162,8 +162,8 @@ static void macdrv_im_set_text(const macdrv_event *event) size = offsetof(struct ime_set_text_params, text[length]); if (!(params = malloc(size))) return; - params->hwnd = hwnd; - params->data = event->im_set_text.data; + params->hwnd = HandleToUlong(hwnd); + params->data = (UINT_PTR)event->im_set_text.data; params->cursor_pos = event->im_set_text.cursor_pos; params->complete = event->im_set_text.complete; @@ -229,7 +229,7 @@ static BOOL query_drag_drop(macdrv_query *query) return FALSE; } - params.hwnd = hwnd; + params.hwnd = HandleToUlong(hwnd); params.effect = drag_operations_to_dropeffects(query->drag_drop.op); params.x = query->drag_drop.x + data->whole_rect.left; params.y = query->drag_drop.y + data->whole_rect.top; @@ -244,7 +244,7 @@ static BOOL query_drag_drop(macdrv_query *query) static BOOL query_drag_exited(macdrv_query *query) { struct dnd_query_exited_params params; - params.hwnd = macdrv_get_window_hwnd(query->window); + params.hwnd = HandleToUlong(macdrv_get_window_hwnd(query->window)); return macdrv_client_func(client_func_dnd_query_exited, ¶ms, sizeof(params)); } @@ -265,7 +265,7 @@ static BOOL query_drag_operation(macdrv_query *query) return FALSE; } - params.hwnd = hwnd; + params.hwnd = HandleToUlong(hwnd); params.effect = drag_operations_to_dropeffects(query->drag_operation.offered_ops); params.x = query->drag_operation.x + data->whole_rect.left; params.y = query->drag_operation.y + data->whole_rect.top; @@ -297,9 +297,9 @@ BOOL query_ime_char_rect(macdrv_query* query) TRACE_(imm)("win %p/%p himc %p range %ld-%ld\n", hwnd, query->window, himc, range->location, range->length); - params.hwnd = hwnd; - params.data = himc; - params.result = &result; + params.hwnd = HandleToUlong(hwnd); + params.data = (UINT_PTR)himc; + params.result = (UINT_PTR)&result; params.location = range->location; params.length = range->length; ret = macdrv_client_func(client_func_ime_query_char_rect, ¶ms, sizeof(params)); diff --git a/dlls/winemac.drv/image.c b/dlls/winemac.drv/image.c index a0ee8b04aa9..857684db9c2 100644 --- a/dlls/winemac.drv/image.c +++ b/dlls/winemac.drv/image.c @@ -250,7 +250,7 @@ cleanup: CFArrayRef create_app_icon_images(void) { struct app_icon_result icons; - struct app_icon_params params = { .result = &icons }; + struct app_icon_params params = { .result = (UINT_PTR)&icons }; CFMutableArrayRef images = NULL; int i; @@ -274,7 +274,7 @@ CFArrayRef create_app_icon_images(void) if (icon->png) { - CFDataRef data = CFDataCreate(NULL, icon->png, icon->size); + CFDataRef data = CFDataCreate(NULL, param_ptr(icon->png), icon->size); if (data) { CGDataProviderRef provider = CGDataProviderCreateWithCFData(data); @@ -289,8 +289,9 @@ CFArrayRef create_app_icon_images(void) } else { - cgimage = create_cgimage_from_icon(icon->icon, icon->width, icon->height); - NtUserDestroyCursor(icon->icon, 0); + HICON handle = UlongToHandle(icon->icon); + cgimage = create_cgimage_from_icon(handle, icon->width, icon->height); + NtUserDestroyCursor(handle, 0); } if (cgimage) diff --git a/dlls/winemac.drv/ime.c b/dlls/winemac.drv/ime.c index fd94591a2b8..1b994f0c5e8 100644 --- a/dlls/winemac.drv/ime.c +++ b/dlls/winemac.drv/ime.c @@ -1397,7 +1397,8 @@ NTSTATUS WINAPI macdrv_ime_set_text(void *arg, ULONG size) { struct ime_set_text_params *params = arg; ULONG length = (size - offsetof(struct ime_set_text_params, text)) / sizeof(WCHAR); - void *himc = params->data; + void *himc = param_ptr(params->data); + HWND hwnd = UlongToHandle(params->hwnd); if (!himc) himc = RealIMC(FROM_MACDRV); @@ -1420,10 +1421,10 @@ NTSTATUS WINAPI macdrv_ime_set_text(void *arg, ULONG size) { input.ki.wScan = params->text[i]; input.ki.dwFlags = KEYEVENTF_UNICODE; - __wine_send_input(params->hwnd, &input, NULL); + __wine_send_input(hwnd, &input, NULL); input.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP; - __wine_send_input(params->hwnd, &input, NULL); + __wine_send_input(hwnd, &input, NULL); } } } @@ -1439,8 +1440,8 @@ NTSTATUS WINAPI macdrv_ime_set_text(void *arg, ULONG size) NTSTATUS WINAPI macdrv_ime_query_char_rect(void *arg, ULONG size) { struct ime_query_char_rect_params *params = arg; - struct ime_query_char_rect_result *result = params->result; - void *himc = params->data; + struct ime_query_char_rect_result *result = param_ptr(params->result); + void *himc = param_ptr(params->data); IMECHARPOSITION charpos; BOOL ret = FALSE; diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index c5e71e188fa..3ebd0ceb48a 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -117,8 +117,8 @@ UINT32 width; UINT32 height; UINT32 size; - void *png; - HICON icon; + UINT32 icon; + UINT64 png; }; struct app_icon_result @@ -130,7 +130,7 @@ /* macdrv_app_icon params */ struct app_icon_params { - struct app_icon_result *result; /* FIXME: Use NtCallbackReturn instead */ + UINT64 result; /* FIXME: Use NtCallbackReturn instead */ }; /* macdrv_app_quit_request params */ @@ -142,7 +142,7 @@ /* macdrv_dnd_query_drag params */ struct dnd_query_drag_params { - HWND hwnd; + UINT32 hwnd; UINT32 effect; INT32 x; INT32 y; @@ -152,7 +152,7 @@ /* macdrv_dnd_query_drop params */ struct dnd_query_drop_params { - HWND hwnd; + UINT32 hwnd; UINT32 effect; INT32 x; INT32 y; @@ -162,7 +162,7 @@ /* macdrv_dnd_query_exited params */ struct dnd_query_exited_params { - HWND hwnd; + UINT32 hwnd; }; /* macdrv_ime_query_char_rect result */ @@ -176,21 +176,26 @@ /* macdrv_ime_query_char_rect params */ struct ime_query_char_rect_params { - HWND hwnd; - void *data; + UINT32 hwnd; UINT32 location; + UINT64 data; + UINT64 result; /* FIXME: Use NtCallbackReturn instead */ UINT32 length; - struct ime_query_char_rect_result *result; /* FIXME: Use NtCallbackReturn instead */ }; /* macdrv_ime_set_text params */ struct ime_set_text_params { - HWND hwnd; - void *data; + UINT32 hwnd; UINT32 cursor_pos; + UINT64 data; UINT32 complete; WCHAR text[1]; }; +static inline void *param_ptr(UINT64 param) +{ + return (void *)(UINT_PTR)param; +} + C_ASSERT(client_func_last <= NtUserDriverCallbackLast + 1);