[PATCH 0/1] MR3974: winemac.drv: Ensure user-land callback can access app_icon results.
Wine-Bugs: https://bugs.winehq.org/show_bug.cgi?id=55658 Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3974
From: Eric Pouech <epouech(a)codeweavers.com> Wine-Bugs: https://bugs.winehq.org/show_bug.cgi?id=55658 Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> --- dlls/winemac.drv/image.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/dlls/winemac.drv/image.c b/dlls/winemac.drv/image.c index 857684db9c2..24a6cfe768d 100644 --- a/dlls/winemac.drv/image.c +++ b/dlls/winemac.drv/image.c @@ -249,27 +249,46 @@ cleanup: */ CFArrayRef create_app_icon_images(void) { - struct app_icon_result icons; - struct app_icon_params params = { .result = (UINT_PTR)&icons }; + struct app_icon_result* icons; + struct app_icon_params params; CFMutableArrayRef images = NULL; int i; + ULONG_PTR zero_bits = 0; + SIZE_T size; TRACE("()\n"); +#ifdef _WIN64 + if (NtCurrentTeb()->WowTebOffset) + { + SYSTEM_BASIC_INFORMATION info; + + NtQuerySystemInformation(SystemEmulationBasicInformation, &info, sizeof(info), NULL); + zero_bits = (ULONG_PTR)info.HighestUserAddress | 0x7fffffff; + } +#endif + size = sizeof(*icons); + if (NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&icons, zero_bits, &size, + MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)) + { + WARN("Failed to allocated user memory\n"); + return NULL; + } + params.result = (ULONG_PTR)icons; macdrv_client_func(client_func_app_icon, ¶ms, sizeof(params)); - if (!icons.count) return NULL; + if (!icons->count) goto cleanup; - images = CFArrayCreateMutable(NULL, icons.count, &kCFTypeArrayCallBacks); + images = CFArrayCreateMutable(NULL, icons->count, &kCFTypeArrayCallBacks); if (!images) { WARN("failed to create images array\n"); - return NULL; + goto cleanup; } - for (i = 0; i < icons.count; i++) + for (i = 0; i < icons->count; i++) { - struct app_icon_entry *icon = &icons.entries[i]; + struct app_icon_entry *icon = &icons->entries[i]; CGImageRef cgimage = NULL; if (icon->png) @@ -306,6 +325,9 @@ CFArrayRef create_app_icon_images(void) CFRelease(images); images = NULL; } +cleanup: + size = 0; + NtFreeVirtualMemory(GetCurrentProcess(), (void **)&icons, &size, MEM_RELEASE); return images; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3974
what happened (to make the link between bugzilla entry and this fix): * psapi tests expects msinfo32 (in wow64) to stay running while performing a couple of tests * msinfo32 (in new wow64) was not displaying any window (about shell) and returned immediately * msinfo32 (in new wow64) failed to create its window as the builtin classes where not registered (esp. the DIALOG one here) * this happens because of a crash in pSetForeGroundWindow() in a user mode callback, which was silently ignored (actually reported in warn:seh, but potentially overseen) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3974#note_47062
We shouldn't need to pass result pointer from unixlib to PE. It was needed during the transition (when the driver couldn't assume that it's executed on Unix stack), but at this point it's just a leftover. We can just have the result on PE stack now and just pass it to `NtCallbackReturn` when returning from the callback. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3974#note_47064
participants (3)
-
Eric Pouech -
eric pouech (@epo) -
Jacek Caban (@jacek)