Make all users of DOSVM_Enter explicitly set V86 flag.
Fix mouse relay stack usage in protected mode.
Raw mode switch now handles interrupt flag correctly.
diff --git a/dlls/winedos/devices.c b/dlls/winedos/devices.c
index dda0480..fe58d6d 100644
--- a/dlls/winedos/devices.c
+++ b/dlls/winedos/devices.c
@@ -547,6 +547,7 @@
/* prepare to call device driver */
memset(&ctx, 0, sizeof(ctx));
+ ctx.EFlags |= V86_FLAG;
/* ES:BX points to request for strategy routine */
ctx.SegEs = HIWORD(DOS_LOLSeg);
diff --git a/dlls/winedos/dosaspi.c b/dlls/winedos/dosaspi.c
index 7ccd2b1..88ab4c6 100644
--- a/dlls/winedos/dosaspi.c
+++ b/dlls/winedos/dosaspi.c
@@ -82,6 +82,8 @@
/* Zero everything */
memset(&ctx, 0, sizeof(ctx));
+ ctx.EFlags |= V86_FLAG;
+
/* CS:IP is routine to call */
ctx.SegCs = SELECTOROF(lpSRB16->cmd.SRB_PostProc);
ctx.Eip = OFFSETOF(lpSRB16->cmd.SRB_PostProc);
diff --git a/dlls/winedos/dosexe.h b/dlls/winedos/dosexe.h
index b17d00b..f0027ef 100644
--- a/dlls/winedos/dosexe.h
+++ b/dlls/winedos/dosexe.h
@@ -88,7 +88,14 @@
# define MZ_SUPPORTED
#endif /* linux-i386 */
+/*
+ * Declare some CONTEXT86.EFlags bits.
+ * IF_MASK is only pushed into real mode stack.
+ */
#define V86_FLAG 0x00020000
+#define IF_MASK 0x00000200
+#define VIF_MASK 0x00080000
+#define VIP_MASK 0x00100000
#define BIOS_DATA ((void *)0x400)
diff --git a/dlls/winedos/dosvm.c b/dlls/winedos/dosvm.c
index 0ca0565..6ebf6e5 100644
--- a/dlls/winedos/dosvm.c
+++ b/dlls/winedos/dosvm.c
@@ -61,9 +61,6 @@
WORD DOSVM_psp = 0;
WORD DOSVM_retval = 0;
-#ifdef HAVE_SYS_VM86_H
-# include <sys/vm86.h>
-#endif
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
@@ -416,7 +413,7 @@
*/
if (!ISV86(&context))
{
- context.EFlags |= 0x00020000;
+ context.EFlags |= V86_FLAG;
context.SegSs = 0xffff;
context.Esp = 0;
}
@@ -580,8 +577,8 @@
int WINAPI DOSVM_Enter( CONTEXT86 *context )
{
- /* Some callers forget to turn V86_FLAG on. */
- context->EFlags |= V86_FLAG;
+ if (!ISV86(context))
+ ERR( "Called with protected mode context!\n" );
__TRY
{
diff --git a/dlls/winedos/int31.c b/dlls/winedos/int31.c
index 7125903..7b952dc 100644
--- a/dlls/winedos/int31.c
+++ b/dlls/winedos/int31.c
@@ -696,7 +696,12 @@
rm_ctx.Ebp = context->Ebp;
rm_ctx.SegFs = 0;
rm_ctx.SegGs = 0;
- rm_ctx.EFlags = context->EFlags; /* at least we need the IF flag */
+
+ /* Copy interrupt state. */
+ if (NtCurrentTeb()->dpmi_vif)
+ rm_ctx.EFlags = V86_FLAG | VIF_MASK;
+ else
+ rm_ctx.EFlags = V86_FLAG;
/* enter real mode again */
TRACE("re-entering real mode at %04lx:%04lx\n",rm_ctx.SegCs,rm_ctx.Eip);
@@ -721,6 +726,12 @@
context->SegFs = 0;
context->SegGs = 0;
+ /* Copy interrupt state. */
+ if (rm_ctx.EFlags & VIF_MASK)
+ NtCurrentTeb()->dpmi_vif = 1;
+ else
+ NtCurrentTeb()->dpmi_vif = 0;
+
/* Return to new address and hope that we didn't mess up */
TRACE("re-entering protected mode at %04lx:%08lx\n",
context->SegCs, context->Eip);
diff --git a/dlls/winedos/int33.c b/dlls/winedos/int33.c
index 41d36d7..32c4366 100644
--- a/dlls/winedos/int33.c
+++ b/dlls/winedos/int33.c
@@ -139,6 +139,12 @@
MCALLDATA *data = (MCALLDATA *)mdata;
CONTEXT86 ctx = *context;
+ if (!ISV86(&ctx))
+ {
+ ctx.EFlags |= V86_FLAG;
+ ctx.SegSs = 0; /* Allocate new stack. */
+ }
+
ctx.Eax = data->mask;
ctx.Ebx = data->but;
ctx.Ecx = data->x;
diff --git a/dlls/winedos/interrupts.c b/dlls/winedos/interrupts.c
index 941417b..f981c6d 100644
--- a/dlls/winedos/interrupts.c
+++ b/dlls/winedos/interrupts.c
@@ -26,19 +26,6 @@
#include "thread.h"
-#ifdef HAVE_SYS_VM86_H
-# include <sys/vm86.h>
-#endif
-
-#ifndef IF_MASK
-#define IF_MASK 0x00000200
-#endif
-
-#ifndef VIF_MASK
-#define VIF_MASK 0x00080000
-#endif
-
-
WINE_DEFAULT_DEBUG_CHANNEL(int);
WINE_DECLARE_DEBUG_CHANNEL(relay);
diff --git a/dlls/winedos/module.c b/dlls/winedos/module.c
index 0ed2584..cce91a1 100644
--- a/dlls/winedos/module.c
+++ b/dlls/winedos/module.c
@@ -574,7 +574,7 @@
context.Esp = init_sp;
context.SegDs = DOSVM_psp;
context.SegEs = DOSVM_psp;
- context.EFlags = 0x00080000; /* virtual interrupt flag */
+ context.EFlags = V86_FLAG | VIF_MASK;
DOSVM_SetTimer(0x10000);
ret = DOSVM_Enter( &context );