[WIN32SS] Try to load the module before fetching an icon, instead of failing on a...
authorMark Jansen <mark.jansen@reactos.org>
Fri, 10 Jun 2016 20:57:26 +0000 (20:57 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Fri, 10 Jun 2016 20:57:26 +0000 (20:57 +0000)
svn path=/trunk/; revision=71609

reactos/win32ss/user/user32/windows/cursoricon.c

index f5a17ac..97ce68b 100644 (file)
@@ -1867,11 +1867,12 @@ CURSORICON_CopyImage(
         TRACE("Got module %wZ, resource %p (%S).\n", &ustrModule,
             ustrRsrc.Buffer, IS_INTRESOURCE(ustrRsrc.Buffer) ? L"" : ustrRsrc.Buffer);
 
         TRACE("Got module %wZ, resource %p (%S).\n", &ustrModule,
             ustrRsrc.Buffer, IS_INTRESOURCE(ustrRsrc.Buffer) ? L"" : ustrRsrc.Buffer);
 
-        /* Get the module handle */
-        if (!GetModuleHandleExW(0, ustrModule.Buffer, &hModule))
+        /* Get the module handle or load the module */
+        hModule = LoadLibraryExW(ustrModule.Buffer, NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE | LOAD_LIBRARY_AS_DATAFILE);
+        if (!hModule)
         {
         {
-            /* This should never happen */
-            ERR("Invalid handle? Module='%wZ', error %lu.\n", &ustrModule, GetLastError());
+            DWORD err = GetLastError();
+            ERR("Unable to load/use module '%wZ' in process %lu, error %lu.\n", &ustrModule, GetCurrentProcessId(), err);
             SetLastError(ERROR_INVALID_PARAMETER);
             goto leave;
         }
             SetLastError(ERROR_INVALID_PARAMETER);
             goto leave;
         }