CURSORICON_SimulateLoadingFromResourceW param check. VFP6 EXEs now work.

C. Daniel Mojoli B. cdmojoli at
Tue Mar 23 10:08:51 CST 2004

Add minimal parameter validation to function
CURSORICON_SimulateLoadingFromResourceW(...). We check that the icon file at
least begins with icon magic.

This is essential for running Visual FoxPro 6 APP or EXE files because its
runtime will unpack resources (e.g. a background image) in temporary files and
then test whether that file can be loaded successfully by several methods, one
of them being trying to load the resource as a cursor icon.

With current Wine code this behavior will cause an exception when the resource
is actually not an icon.

Relying on failure semantics seems a horrible way to program but VFP6 does
so. Please notice VFP6 does not fail when you "do some.{prg|fxp}" because it
seems to use the resource's original file extension to determine what function
should load the resource.

I am unaware of this situation under VFP7 or VFP8. (I actually have not coded
anything in *BASE since 1991!)

Index: windows/cursoricon.c
RCS file: /home/wine/wine/windows/cursoricon.c,v
retrieving revision 1.71
diff -u -r1.71 cursoricon.c
--- windows/cursoricon.c	12 Feb 2004 00:35:01 -0000	1.71
+++ windows/cursoricon.c	23 Mar 2004 14:19:21 -0000
@@ -504,6 +504,9 @@
         if (pos>=(LPBYTE)bits+766) goto fail;
+    if ( *(LPDWORD)bits!=0x00010000 ) goto fail; /* icon files start with 00 00 01 00 */
     if (!(entries = bits->idCount)) goto fail;
     size = sizeof(CURSORICONDIR) + sizeof(CURSORICONDIRENTRY) * (entries - 1);
     _free = (LPBYTE) size;

More information about the wine-patches mailing list