Module: wine Branch: master Commit: 67b10761ec3b0d9a81d91d2590caa1158622ff1a URL: https://gitlab.winehq.org/wine/wine/-/commit/67b10761ec3b0d9a81d91d2590caa11...
Author: Eric Pouech epouech@codeweavers.com Date: Sat Sep 30 10:00:17 2023 +0200
winemac.drv: Use NtCallbackReturn to send back app's icons to unixlib.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55658 Signed-off-by: Eric Pouech epouech@codeweavers.com
---
dlls/winemac.drv/dllmain.c | 16 ++++++++-------- dlls/winemac.drv/image.c | 22 ++++++++++++++-------- dlls/winemac.drv/unixlib.h | 12 ------------ 3 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index b20f8d71dc9..8812426cc44 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -243,16 +243,16 @@ 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 = param_ptr(params->result); + struct app_icon_entry entries[64]; HRSRC res_info; HGLOBAL res_data; GRPICONDIR *icon_dir; + unsigned count; int i;
TRACE("()\n");
- result->count = 0; + count = 0;
res_info = NULL; EnumResourceNamesW(NULL, (LPCWSTR)RT_GROUP_ICON, get_first_resource, (LONG_PTR)&res_info); @@ -274,9 +274,9 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) goto cleanup; }
- for (i = 0; i < icon_dir->idCount && result->count < ARRAYSIZE(result->entries); i++) + for (i = 0; i < icon_dir->idCount && count < ARRAYSIZE(entries); i++) { - struct app_icon_entry *entry = &result->entries[result->count]; + struct app_icon_entry *entry = &entries[count]; int width = icon_dir->idEntries[i].bWidth; int height = icon_dir->idEntries[i].bHeight; BOOL found_better_bpp = FALSE; @@ -338,7 +338,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) { entry->png = (UINT_PTR)icon_bits; entry->icon = 0; - result->count++; + count++; } else { @@ -348,7 +348,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) { entry->icon = HandleToUlong(icon); entry->png = 0; - result->count++; + count++; } else WARN("failed to create icon %d from resource with ID %hd\n", i, icon_dir->idEntries[i].nID); @@ -363,7 +363,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) cleanup: FreeResource(res_data);
- return 0; + return NtCallbackReturn(entries, count * sizeof(entries[0]), 0); }
typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); diff --git a/dlls/winemac.drv/image.c b/dlls/winemac.drv/image.c index 857684db9c2..6e2fcf1eaa2 100644 --- a/dlls/winemac.drv/image.c +++ b/dlls/winemac.drv/image.c @@ -249,27 +249,33 @@ cleanup: */ CFArrayRef create_app_icon_images(void) { - struct app_icon_result icons; - struct app_icon_params params = { .result = (UINT_PTR)&icons }; CFMutableArrayRef images = NULL; + struct app_icon_entry *entries; + ULONG ret_len; + unsigned count; int i;
TRACE("()\n");
- macdrv_client_func(client_func_app_icon, ¶ms, sizeof(params)); - - if (!icons.count) return NULL; + if (KeUserModeCallback(client_func_app_icon, NULL, 0, (void**)&entries, &ret_len) || + (ret_len % sizeof(*entries))) + { + WARN("incorrect callback result\n"); + return NULL; + } + count = ret_len / sizeof(*entries); + if (!count || !entries) return NULL;
- images = CFArrayCreateMutable(NULL, icons.count, &kCFTypeArrayCallBacks); + images = CFArrayCreateMutable(NULL, count, &kCFTypeArrayCallBacks); if (!images) { WARN("failed to create images array\n"); return NULL; }
- for (i = 0; i < icons.count; i++) + for (i = 0; i < count; i++) { - struct app_icon_entry *icon = &icons.entries[i]; + struct app_icon_entry *icon = &entries[i]; CGImageRef cgimage = NULL;
if (icon->png) diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index 61f4f44fb75..7f14517a8ee 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -104,18 +104,6 @@ struct app_icon_entry UINT64 png; };
-struct app_icon_result -{ - UINT32 count; - struct app_icon_entry entries[64]; -}; - -/* macdrv_app_icon params */ -struct app_icon_params -{ - UINT64 result; /* FIXME: Use NtCallbackReturn instead */ -}; - /* macdrv_app_quit_request params */ struct app_quit_request_params {