Hi all,

while trying to run Win2.0 paint.exe, I tracked down a big problem:
Call USER.174: LOADICON(0x02b6,0000:0001 #0001) ret=027f:5115 ds=02b7
trace:resource:LoadImageW (0x02b6,0x1,1,0,0,0x00008040)
err:icon:CURSORICON_Load norm. instance: 0237
trace:resource:RES_FindResource2 (00000237 C:\WIN2.02\CALENDAR.EXE, 0000000e, 
00000001, 0409, W, PE)
err:resource:RES_FindResource2 typeStr: 0xe
err:resource:NE_FindResource pModule: 0x4046e97c
trace:resource:NE_FindResource module=0237 name=#0001 type=#000e
trace:resource:NE_FindTypeSection   Skipping type 8002
trace:resource:NE_FindTypeSection   Skipping type 8003
trace:resource:NE_FindTypeSection   Skipping type 8004
trace:resource:NE_FindTypeSection   Skipping type 8005
trace:resource:NE_FindTypeSection   Skipping type 8006
trace:resource:NE_FindTypeSection   Skipping type 8009
warn:resource:NE_FindResource failed!
Ret  USER.174: LOADICON() retval=0x0000 ret=027f:5115 ds=02b7

Note that NE_FindResource() above has type 0xe set instead of the type
0x8003 as required for LoadIcon() with Win16 !
Of course paint.exe really contains an icon name 0x1 with icon ID 0x8003...

Call chain:
LoadIcon16 -> ... -> LoadImageW
-> CURSORICON_Load ("Load from resource" part)
-> FindResourceW (with type RT_GROUP_ICONW (0xe) instead of win16 icon type 0x8003 !!!)
-> RES_FindResource
-> RES_FindResource2
-> NE_FindResource with wrong ID 0xe !

In short: the use of RT_GROUP_ICONW (and probably RT_GROUP_CURSORW)
in CURSORICON_Load is very problematic when it comes to loading icons/cursors
from Win16 programs.
--> I assume that CURSORICON_Load() is broken for *every* Win16 access.

What to do ?
I'm afraid we need to check whether Win16 or not in CURSORICON_Load (how ??)
and pass Win16 or Win32 resource ID depending on that check.
It's not nice, but... it's Windows ! ;-)

Expressed in code:
        if (HIWORD(hInstance))
        { /* Win32 */
                hMappedRes = fCursor ? RT_GROUP_CURSORW : RT_GROUP_ICONW;
        }
        else /* Win16 */
                hMappedRes = fCursor ? 0x8001 : 0x8003;

        if (!(hRsrc = FindResourceW( hInstance, name, hMappedRes )))

This works, BTW.

Well, not really...
It gets further (finds the icon resource), but:
resdump.exe shows this icon as existing as a resource, but somehow empty,
so Wine fails, too (in CURSORICON_FindBestIcon()).
Maybe this is a Win2.0 structure incompatibility ?

Anyway, it's the Win16 CURSORICON_Load problem that ought to be fixed first.

Andreas Mohr

Reply via email to