Commit 4f3f1c98 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

user32: Don't access cursoricon_object directly in CopyImage.

parent 0fef0daa
...@@ -72,37 +72,6 @@ static int get_display_bpp(void) ...@@ -72,37 +72,6 @@ static int get_display_bpp(void)
return ret; return ret;
} }
static struct cursoricon_object *get_icon_ptr( HICON handle )
{
struct cursoricon_object *obj = get_user_handle_ptr( handle, NTUSER_OBJ_ICON );
if (obj == OBJ_OTHER_PROCESS)
{
WARN( "icon handle %p from other process\n", handle );
obj = NULL;
}
return obj;
}
static struct cursoricon_frame *get_icon_frame( struct cursoricon_object *obj, int istep )
{
struct cursoricon_object *req_frame;
if (!obj->is_ani) return &obj->frame;
if (!(req_frame = get_icon_ptr( obj->ani.frames[istep] ))) return 0;
return &req_frame->frame;
}
static void release_icon_frame( struct cursoricon_object *obj, struct cursoricon_frame *frame )
{
if (obj->is_ani)
{
struct cursoricon_object *frameobj;
frameobj = (struct cursoricon_object *) (((char *)frame) - FIELD_OFFSET(struct cursoricon_object, frame));
release_user_handle_ptr( frameobj );
}
}
static void free_icon_frame( struct cursoricon_frame *frame ) static void free_icon_frame( struct cursoricon_frame *frame )
{ {
if (frame->color) DeleteObject( frame->color ); if (frame->color) DeleteObject( frame->color );
...@@ -2481,29 +2450,31 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx, ...@@ -2481,29 +2450,31 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx,
case IMAGE_ICON: case IMAGE_ICON:
case IMAGE_CURSOR: case IMAGE_CURSOR:
{ {
struct cursoricon_frame *frame; ICONINFOEXW icon_info;
struct cursoricon_object *icon;
int depth = (flags & LR_MONOCHROME) ? 1 : get_display_bpp(); int depth = (flags & LR_MONOCHROME) ? 1 : get_display_bpp();
HICON resource_icon = NULL; HICON resource_icon = 0;
HINSTANCE module; LONG width, height;
ICONINFO info; ICONINFO info;
HANDLE module;
HICON res; HICON res;
if (!(icon = get_icon_ptr( hnd ))) return 0; icon_info.cbSize = sizeof(icon_info);
if (!GetIconInfoExW( hnd, &icon_info )) return 0;
if (icon->rsrc && (flags & LR_COPYFROMRESOURCE) && icon->module.Length && if (icon_info.szModName[0] && (flags & LR_COPYFROMRESOURCE) &&
!LdrGetDllHandle( NULL, 0, &icon->module, &module )) (module = GetModuleHandleW( icon_info.szModName )))
{ {
resource_icon = CURSORICON_Load( module, icon->resname, desiredx, const WCHAR *res = icon_info.szResName[0] ? icon_info.szResName
desiredy, depth, !icon->is_icon, flags ); : MAKEINTRESOURCEW( icon_info.wResID );
release_user_handle_ptr( icon ); resource_icon = CURSORICON_Load( module, res, desiredx, desiredy, depth,
if (!(icon = get_icon_ptr( resource_icon ))) !icon_info.fIcon, flags );
{ DeleteObject( icon_info.hbmColor );
if (resource_icon) DestroyIcon( resource_icon ); DeleteObject( icon_info.hbmMask );
return 0; NtUserGetIconSize( resource_icon, 0, &width, &height );
} if (!GetIconInfoExW( resource_icon, &icon_info )) return 0;
} }
frame = get_icon_frame( icon, 0 ); else NtUserGetIconSize( hnd, 0, &width, &height );
height /= 2;
if (flags & LR_DEFAULTSIZE) if (flags & LR_DEFAULTSIZE)
{ {
...@@ -2512,44 +2483,44 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx, ...@@ -2512,44 +2483,44 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx,
} }
else else
{ {
if (!desiredx) desiredx = frame->width; if (!desiredx) desiredx = width;
if (!desiredy) desiredy = frame->height; if (!desiredy) desiredy = height;
} }
info.fIcon = icon->is_icon; info.fIcon = icon_info.fIcon;
info.xHotspot = frame->hotspot.x; info.xHotspot = icon_info.xHotspot;
info.yHotspot = frame->hotspot.y; info.yHotspot = icon_info.yHotspot;
if (desiredx == frame->width && desiredy == frame->height) if (desiredx == width && desiredy == height)
{ {
info.hbmColor = frame->color; info.hbmColor = icon_info.hbmColor;
info.hbmMask = frame->mask; info.hbmMask = icon_info.hbmMask;
res = CreateIconIndirect( &info ); res = CreateIconIndirect( &info );
} }
else else
{ {
if (frame->color) if (icon_info.hbmColor)
{ {
if (!(info.hbmColor = create_color_bitmap( desiredx, desiredy ))) if (!(info.hbmColor = create_color_bitmap( desiredx, desiredy )))
{ {
release_icon_frame( icon, frame ); DeleteObject( icon_info.hbmColor );
release_user_handle_ptr( icon ); DeleteObject( icon_info.hbmMask );
if (resource_icon) DestroyIcon( resource_icon ); if (resource_icon) DestroyIcon( resource_icon );
return 0; return 0;
} }
stretch_bitmap( info.hbmColor, frame->color, desiredx, desiredy, stretch_bitmap( info.hbmColor, icon_info.hbmColor, desiredx, desiredy,
frame->width, frame->height ); width, height );
if (!(info.hbmMask = CreateBitmap( desiredx, desiredy, 1, 1, NULL ))) if (!(info.hbmMask = CreateBitmap( desiredx, desiredy, 1, 1, NULL )))
{ {
DeleteObject( icon_info.hbmColor );
DeleteObject( icon_info.hbmMask );
DeleteObject( info.hbmColor ); DeleteObject( info.hbmColor );
release_icon_frame( icon, frame );
release_user_handle_ptr( icon );
if (resource_icon) DestroyIcon( resource_icon ); if (resource_icon) DestroyIcon( resource_icon );
return 0; return 0;
} }
stretch_bitmap( info.hbmMask, frame->mask, desiredx, desiredy, stretch_bitmap( info.hbmMask, icon_info.hbmMask, desiredx, desiredy,
frame->width, frame->height ); width, height );
} }
else else
{ {
...@@ -2557,12 +2528,13 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx, ...@@ -2557,12 +2528,13 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx,
if (!(info.hbmMask = CreateBitmap( desiredx, desiredy * 2, 1, 1, NULL ))) if (!(info.hbmMask = CreateBitmap( desiredx, desiredy * 2, 1, 1, NULL )))
{ {
release_user_handle_ptr( icon ); DeleteObject( icon_info.hbmColor );
DeleteObject( icon_info.hbmMask );
if (resource_icon) DestroyIcon( resource_icon ); if (resource_icon) DestroyIcon( resource_icon );
return 0; return 0;
} }
stretch_bitmap( info.hbmMask, frame->mask, desiredx, desiredy * 2, stretch_bitmap( info.hbmMask, icon_info.hbmMask, desiredx, desiredy * 2,
frame->width, frame->height * 2 ); width, height * 2 );
} }
res = CreateIconIndirect( &info ); res = CreateIconIndirect( &info );
...@@ -2571,8 +2543,8 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx, ...@@ -2571,8 +2543,8 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx,
DeleteObject( info.hbmMask ); DeleteObject( info.hbmMask );
} }
release_icon_frame( icon, frame ); DeleteObject( icon_info.hbmColor );
release_user_handle_ptr( icon ); DeleteObject( icon_info.hbmMask );
if (res && (flags & LR_COPYDELETEORG)) DestroyIcon( hnd ); if (res && (flags & LR_COPYDELETEORG)) DestroyIcon( hnd );
if (resource_icon) DestroyIcon( resource_icon ); if (resource_icon) DestroyIcon( resource_icon );
......
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