From 6c22a5c3a327d066f104df54d2723b709fd5891e Mon Sep 17 00:00:00 2001 From: Andrew Riedi Date: Thu, 7 Feb 2008 01:29:51 -0800 Subject: [PATCH] user32: Check for .ico and .cur magic. --- dlls/user32/cursoricon.c | 7 ++++++- dlls/user32/tests/cursoricon.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletions(-) diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index 88fdd65..51ba296 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -899,8 +899,13 @@ static HICON CURSORICON_LoadFromFile( LPCWSTR filename, if (!bits) return hIcon; + /* fCursor is ignored if the .ico or .cur magic exists. */ + if (memcmp( bits, "\x00\x00\x01\x00", 4 ) == 0) + fCursor = FALSE; + else if (memcmp( bits, "\x00\x00\x02\x00", 4 ) == 0) + fCursor = TRUE; /* Check for .ani. */ - if (memcmp( bits, "RIFF", 4 ) == 0) + else if (memcmp( bits, "RIFF", 4 ) == 0) { FIXME("No support for .ani cursors.\n"); goto end; diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index f65aa5e..daa08f6 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -567,6 +567,25 @@ static void test_CreateIcon(void) DeleteObject(hbmColor); } +static void test_LoadImage(void) +{ + HANDLE handle; + BOOL ret; + DWORD error; + + /* Test loading an icon as a cursor. */ + SetLastError(0xdeadbeef); + handle = LoadImageA(NULL, "icon.ico", IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE); + ok(handle != NULL, "LoadImage() failed.\n"); + error = GetLastError(); + ok(error == 0, "Last error: %u\n", error); + + ret = DestroyIcon(handle); + ok(ret, "DestroyIcon() failed.\n"); + error = GetLastError(); + ok(error == 0, "Last error: %u\n", error); +} + static void test_DestroyCursor(void) { static const BYTE bmp_bits[4096]; @@ -670,6 +689,7 @@ START_TEST(cursoricon) test_CopyImage_Bitmap(32); test_initial_cursor(); test_CreateIcon(); + test_LoadImage(); test_DestroyCursor(); do_parent(); test_child_process(); -- 1.4.4.2