Resubmitted patch: GetWindowLong16 behaviour
Jukka Heinonen
jhei at iki.fi
Sun Feb 10 08:01:02 CST 2002
This patch is required to make Colonization and Civilization 2 work.
The patch might look funny but I believe there is a bug in Windows
GetWindowLong16 that converts invalid offsets into valid ones.
Changelog:
Convert some invalid offsets in GetWindowLong16 into valid offsets.
Index: wine/windows/win.c
===================================================================
RCS file: /home/wine/wine/windows/win.c,v
retrieving revision 1.176
diff -u -r1.176 win.c
--- wine/windows/win.c 2002/01/22 00:50:07 1.176
+++ wine/windows/win.c 2002/02/10 11:53:59
@@ -1873,6 +1873,24 @@
{
if (offset > wndPtr->cbWndExtra - sizeof(LONG))
{
+ /*
+ * Some programs try to access last element from 16 bit
+ * code using illegal offset value. Hopefully this is
+ * what those programs really expect.
+ */
+ if (type == WIN_PROC_16 &&
+ wndPtr->cbWndExtra >= 4 &&
+ offset == wndPtr->cbWndExtra - sizeof(WORD))
+ {
+ INT offset2 = wndPtr->cbWndExtra - sizeof(LONG);
+
+ ERR( "- replaced invalid offset %d with %d\n",
+ offset, offset2 );
+
+ retvalue = *(LONG *)(((char *)wndPtr->wExtra) + offset2);
+ WIN_ReleasePtr( wndPtr );
+ return retvalue;
+ }
WARN("Invalid offset %d\n", offset );
WIN_ReleasePtr( wndPtr );
SetLastError( ERROR_INVALID_INDEX );
--
Jukka Heinonen <http://www.iki.fi/jhei/>
More information about the wine-patches
mailing list