Commit 67b10761 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winemac.drv: Use NtCallbackReturn to send back app's icons to unixlib.

parent b4b39bfb
...@@ -243,16 +243,16 @@ static BOOL CALLBACK get_first_resource(HMODULE module, LPCWSTR type, LPWSTR nam ...@@ -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) static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
{ {
struct app_icon_params *params = arg; struct app_icon_entry entries[64];
struct app_icon_result *result = param_ptr(params->result);
HRSRC res_info; HRSRC res_info;
HGLOBAL res_data; HGLOBAL res_data;
GRPICONDIR *icon_dir; GRPICONDIR *icon_dir;
unsigned count;
int i; int i;
TRACE("()\n"); TRACE("()\n");
result->count = 0; count = 0;
res_info = NULL; res_info = NULL;
EnumResourceNamesW(NULL, (LPCWSTR)RT_GROUP_ICON, get_first_resource, (LONG_PTR)&res_info); 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) ...@@ -274,9 +274,9 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
goto cleanup; 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 width = icon_dir->idEntries[i].bWidth;
int height = icon_dir->idEntries[i].bHeight; int height = icon_dir->idEntries[i].bHeight;
BOOL found_better_bpp = FALSE; BOOL found_better_bpp = FALSE;
...@@ -338,7 +338,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) ...@@ -338,7 +338,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
{ {
entry->png = (UINT_PTR)icon_bits; entry->png = (UINT_PTR)icon_bits;
entry->icon = 0; entry->icon = 0;
result->count++; count++;
} }
else else
{ {
...@@ -348,7 +348,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) ...@@ -348,7 +348,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
{ {
entry->icon = HandleToUlong(icon); entry->icon = HandleToUlong(icon);
entry->png = 0; entry->png = 0;
result->count++; count++;
} }
else else
WARN("failed to create icon %d from resource with ID %hd\n", i, icon_dir->idEntries[i].nID); 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) ...@@ -363,7 +363,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
cleanup: cleanup:
FreeResource(res_data); FreeResource(res_data);
return 0; return NtCallbackReturn(entries, count * sizeof(entries[0]), 0);
} }
typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size);
......
...@@ -249,27 +249,33 @@ cleanup: ...@@ -249,27 +249,33 @@ cleanup:
*/ */
CFArrayRef create_app_icon_images(void) CFArrayRef create_app_icon_images(void)
{ {
struct app_icon_result icons;
struct app_icon_params params = { .result = (UINT_PTR)&icons };
CFMutableArrayRef images = NULL; CFMutableArrayRef images = NULL;
struct app_icon_entry *entries;
ULONG ret_len;
unsigned count;
int i; int i;
TRACE("()\n"); TRACE("()\n");
macdrv_client_func(client_func_app_icon, &params, sizeof(params)); if (KeUserModeCallback(client_func_app_icon, NULL, 0, (void**)&entries, &ret_len) ||
(ret_len % sizeof(*entries)))
if (!icons.count) return NULL; {
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) if (!images)
{ {
WARN("failed to create images array\n"); WARN("failed to create images array\n");
return NULL; 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; CGImageRef cgimage = NULL;
if (icon->png) if (icon->png)
......
...@@ -104,18 +104,6 @@ struct app_icon_entry ...@@ -104,18 +104,6 @@ struct app_icon_entry
UINT64 png; 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 */ /* macdrv_app_quit_request params */
struct app_quit_request_params struct app_quit_request_params
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment