winedos / Fix real mode interrupt vector access under Win16
Jukka Heinonen
jhei at iki.fi
Mon Oct 6 16:16:49 CDT 2003
This patch should fix crash in 16-bit code reported
on wine-devel. This is actually the same problem as
with BIOS data area. Under Win16, real mode vectors
may have been moved to another location and a bit more
complex code must be used to access them.
Changelog:
Use correct pointer when accessing real mode interrupt
vectors under Win16.
Index: dlls/winedos/interrupts.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/interrupts.c,v
retrieving revision 1.21
diff -u -r1.21 interrupts.c
--- dlls/winedos/interrupts.c 4 Oct 2003 03:06:18 -0000 1.21
+++ dlls/winedos/interrupts.c 6 Oct 2003 21:03:57 -0000
@@ -72,6 +72,27 @@
/**********************************************************************
+ * DOSVM_GetRMVector
+ *
+ * Return pointer to real mode interrupt vector. These are not at fixed
+ * location because those Win16 programs that do not use any real mode
+ * code have protected NULL pointer catching block at low linear memory
+ * and interrupt vectors have been moved to another location.
+ */
+static FARPROC16* DOSVM_GetRMVector( BYTE intnum )
+{
+ LDT_ENTRY entry;
+ FARPROC16 proc;
+
+ proc = GetProcAddress16( GetModuleHandle16( "KERNEL" ),
+ (LPCSTR)(ULONG_PTR)183 );
+ wine_ldt_get_entry( LOWORD(proc), &entry );
+
+ return (FARPROC16*)wine_ldt_get_base( &entry ) + intnum;
+}
+
+
+/**********************************************************************
* DOSVM_IsIRQ
*
* Return TRUE if interrupt is an IRQ.
@@ -517,7 +538,7 @@
*/
FARPROC16 DOSVM_GetRMHandler( BYTE intnum )
{
- return ((FARPROC16*)0)[intnum];
+ return *DOSVM_GetRMVector( intnum );
}
@@ -530,7 +551,7 @@
{
TRACE("Set real mode interrupt vector %02x <- %04x:%04x\n",
intnum, HIWORD(handler), LOWORD(handler) );
- ((FARPROC16*)0)[intnum] = handler;
+ *DOSVM_GetRMVector( intnum ) = handler;
}
--
Jukka Heinonen <http://www.iki.fi/jhei/>
More information about the wine-patches
mailing list