[PATCH 0/1] MR11669: krnl386: Respect the MOVEABLE flag in AllocResource16.
MOVEABLE matters in LoadResource because it causes the least significant bit of the returned resource handle to be a 0 instead of a 1, and the game Odell Down Under evidently masks off the lowest bit before calling FreeResource. If the handle does not match exactly, FreeResource16 will not find it in the resource table, and will proceed to call GlobalFree16 even if the resource's reference count is not zero. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=26040 --- I don't have a great explanation for why the game doesn't free the exact same handle that it was given. My best guess is that it somehow made sense in the game's architecture to derive the resource handle from the allocated segment selector and the resource flags. But, when the game starts, it shows a splash screen with the text "Copyright 1994" and the address of the game studio: 6160 Summit Drive North, Minneapolis, MN. That's only 5 miles away from the CodeWeavers office. Maybe one of you CodeWeavers folks could knock on the door and ask why they wrote the code that way 32 years ago? ;-) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11669
From: Alex Henrie <alexhenrie24@gmail.com> MOVEABLE matters in LoadResource because it causes the least significant bit of the returned resource handle to be a 0 instead of a 1, and the game Odell Down Under evidently masks off the lowest bit before calling FreeResource. If the handle does not match exactly, FreeResource16 will not find it in the resource table, and will proceed to call GlobalFree16 even if the resource's reference count is not zero. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=26040 --- dlls/krnl386.exe16/resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/krnl386.exe16/resource.c b/dlls/krnl386.exe16/resource.c index ec6440d6a66..bcdb01a3b30 100644 --- a/dlls/krnl386.exe16/resource.c +++ b/dlls/krnl386.exe16/resource.c @@ -875,7 +875,7 @@ HGLOBAL16 WINAPI AllocResource16( HMODULE16 hModule, HRSRC16 hRsrc, DWORD size) pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc); if (size < (DWORD)pNameInfo->length << sizeShift) size = (DWORD)pNameInfo->length << sizeShift; - ret = GlobalAlloc16( GMEM_FIXED, size ); + ret = GlobalAlloc16( pNameInfo->flags & NE_SEGFLAGS_MOVEABLE ? GMEM_MOVEABLE : GMEM_FIXED, size ); if (ret) FarSetOwner16( ret, hModule ); return ret; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11669
participants (2)
-
Alex Henrie -
Alex Henrie (@alexhenrie)