Do not emulate interrupts in win32 apps
Jukka Heinonen
jhei at iki.fi
Fri May 9 13:36:58 CDT 2003
This small patch prevents Win32 applications from using
interrupts. Even Windows95 applications really use Win16
code or VxDs if they want to use interrupts. And
EXCEPTION_ACCESS_VIOLATION is the correct exception in
this case so returning FALSE would not work.
Changelog:
Win32 applications are not supposed to be able to use intXX
instructions.
Index: memory/instr.c
===================================================================
RCS file: /home/wine/wine/memory/instr.c,v
retrieving revision 1.21
diff -u -r1.21 instr.c
--- memory/instr.c 26 Feb 2003 20:34:45 -0000 1.21
+++ memory/instr.c 9 May 2003 18:28:32 -0000
@@ -32,6 +32,8 @@
#ifdef __i386__
+extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
+
/* macros to set parts of a DWORD */
#define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
#define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
@@ -686,14 +688,31 @@
break; /* Unable to emulate it */
case 0xcd: /* int <XX> */
- if(!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
- ERR("could not initialize interrupt handling\n");
- else {
- context->Eip += prefixlen + 2;
- Dosvm.EmulateInterruptPM( context, instr[1] );
- return TRUE;
- }
- break; /* Unable to emulate it */
+ if (IS_SELECTOR_SYSTEM(context->SegCs))
+ {
+ /*
+ * Win32 applications cannot use interrupts.
+ */
+ EXCEPTION_RECORD rec;
+ rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
+ rec.ExceptionRecord = NULL;
+ rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
+ rec.ExceptionAddress = (LPVOID)context->Eip;
+ rec.NumberParameters = 0;
+ EXC_RtlRaiseException( &rec, context );
+ return TRUE;
+ }
+ else if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
+ {
+ ERR("could not initialize interrupt handling\n");
+ }
+ else
+ {
+ context->Eip += prefixlen + 2;
+ Dosvm.EmulateInterruptPM( context, instr[1] );
+ return TRUE;
+ }
+ break; /* Unable to emulate it */
case 0xcf: /* iret */
if (long_op)
--
Jukka Heinonen <http://www.iki.fi/jhei/>
More information about the wine-patches
mailing list