[PATCH] user32: Handle LoadImage with 0x0 requests and no LR_DEFAULTSIZE

Marcus Meissner meissner at suse.de
Thu Jan 27 11:38:48 CST 2011


Hi,

When desiredx and desiredy are 0 and LR_DEFAULTSIZE is NOT set,
use the size of the first resource entry.
(Just the size ... We still need to search for the one with the
best color match.)

Obsoletes previously submitted patch which had just the warning.

(The whitespacing is actually different between the two functions,
 but I do not dare to touch it ;)

Ciao, Marcus
---
 dlls/user32/cursoricon.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index fcb5d75..d376ceb 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -1143,11 +1143,17 @@ static HICON CURSORICON_LoadFromFile( LPCWSTR filename,
     if ( filesize < (sizeof(*dir) + sizeof(dir->idEntries[0])*(dir->idCount-1)) )
         goto end;
 
+    if ( !width && !height && !(loadflags & LR_DEFAULTSIZE) ) {
+        int xdepth;
+
+        if (!CURSORICON_GetFileEntry( dir, 0, &width, &height, &xdepth))
+            goto end;
+        /* Fall through, and let the other code look for the best color */
+    }
     if ( fCursor )
         entry = CURSORICON_FindBestCursorFile( dir, width, height, depth );
     else
         entry = CURSORICON_FindBestIconFile( dir, width, height, depth );
-
     if ( !entry )
         goto end;
 
@@ -1206,11 +1212,25 @@ static HICON CURSORICON_Load(HINSTANCE hInstance, LPCWSTR name,
 
     if (!(handle = LoadResource( hInstance, hRsrc ))) return 0;
     if (!(dir = LockResource( handle ))) return 0;
+    if (!width && !height && !(loadflags & LR_DEFAULTSIZE)) {
+        int xdepth;
+
+        if (fCursor) {
+            if (!CURSORICON_GetResCursorEntry( dir, 0, &width, &height, &xdepth))
+                return 0;
+        } else {
+            if (!CURSORICON_GetResIconEntry( dir, 0, &width, &height, &xdepth))
+                return 0;
+        }
+        /* Fall through, and let the other code look for the best color */
+    }
     if (fCursor)
         dirEntry = CURSORICON_FindBestCursorRes( dir, width, height, depth );
     else
         dirEntry = CURSORICON_FindBestIconRes( dir, width, height, depth );
-    if (!dirEntry) return 0;
+    if (!dirEntry)
+        return 0;
+
     wResId = dirEntry->wResId;
     FreeResource( handle );
 
@@ -2281,7 +2301,8 @@ HANDLE WINAPI LoadImageW( HINSTANCE hinst, LPCWSTR name, UINT type,
             if (!desiredx) desiredx = GetSystemMetrics(SM_CXCURSOR);
             if (!desiredy) desiredy = GetSystemMetrics(SM_CYCURSOR);
         }
-    }
+    } /* else case in handled in CURSORICON_Load/LoadFromFile seperately */
+
     if (loadflags & LR_LOADFROMFILE) loadflags &= ~LR_SHARED;
     switch (type) {
     case IMAGE_BITMAP:
-- 
1.7.1




More information about the wine-patches mailing list