DPMI RawModeSwitch, return to protected mode fix
Jukka Heinonen
jhei at iki.fi
Sat May 11 09:23:39 CDT 2002
RawModeSwitch to real mode and back to protected mode
seems to work now without having to call RawModeSwitch from
signal handler.
Changelog:
RawModeSwitch can now be used to return DPMI application
back to protected mode.
Index: dpmi.c
===================================================================
RCS file: /home/wine/wine/msdos/dpmi.c,v
retrieving revision 1.62
diff -u -r1.62 dpmi.c
--- msdos/dpmi.c 7 May 2002 17:59:11 -0000 1.62
+++ msdos/dpmi.c 11 May 2002 14:04:18 -0000
@@ -33,6 +33,7 @@
#include "selectors.h"
#include "callback.h"
#include "wine/debug.h"
+#include "stackframe.h"
WINE_DEFAULT_DEBUG_CHANNEL(int31);
@@ -198,7 +199,45 @@
ERR("could not setup real-mode calls\n");
return;
}
- else Dosvm.RawModeSwitch( context );
+ else
+ {
+ /*
+ * FIXME: This routine will not work if it is called
+ * from 32 bit DPMI program and the program returns
+ * to protected mode while ESP or EIP is over 0xffff.
+ * FIXME: This routine will not work if it is not called
+ * using 16-bit-to-Wine callback glue function.
+ */
+ STACK16FRAME frame = *CURRENT_STACK16;
+
+ Dosvm.RawModeSwitch( context );
+
+ /*
+ * After this function returns to relay code, protected mode
+ * 16 bit stack will contain STACK16FRAME and single WORD
+ * (EFlags, see next comment).
+ */
+ NtCurrentTeb()->cur_stack =
+ MAKESEGPTR( context->SegSs,
+ context->Esp - sizeof(STACK16FRAME) - sizeof(WORD) );
+
+ /*
+ * After relay code returns to glue function, protected
+ * mode 16 bit stack will contain interrupt return record:
+ * IP, CS and EFlags. Since EFlags is ignored, it won't
+ * need to be initialized.
+ */
+ context->Esp -= 3 * sizeof(WORD);
+
+ /*
+ * Restore stack frame so that relay code won't be confused.
+ * It should be noted that relay code overwrites IP and CS
+ * in STACK16FRAME with values taken from current CONTEXT86.
+ * These values are what is returned to glue function
+ * (see previous comment).
+ */
+ *CURRENT_STACK16 = frame;
+ }
}
/**********************************************************************
--
Jukka Heinonen <http://www.iki.fi/jhei/>
More information about the wine-patches
mailing list