[NTOSKRNL]
[reactos.git] / reactos / ntoskrnl / ke / i386 / v86vdm.c
index 503f413..c083bc4 100644 (file)
@@ -526,8 +526,12 @@ KiEnterV86Mode(IN PKV8086_STACK_FRAME StackFrame)
     TrapFrame->HardwareEsp = 0x11FFE;
     TrapFrame->ExceptionList = EXCEPTION_CHAIN_END;
     TrapFrame->Dr7 = 0;
-    //TrapFrame->DbgArgMark = 0xBADB0D00;
+
+    /* Set some debug fields if trap debugging is enabled */
+#if TRAP_DEBUG
+    TrapFrame->DbgArgMark = 0xBADB0D00;
     TrapFrame->PreviousPreviousMode = -1;
+#endif
     
     /* Disable interrupts */
     _disable();
@@ -563,6 +567,34 @@ KiEnterV86Mode(IN PKV8086_STACK_FRAME StackFrame)
     /* Exit to V86 mode */
     KiEoiHelper(TrapFrame);
 }
+
+VOID
+NTAPI
+Ke386SetIOPL(VOID)
+{
+
+    PKTHREAD Thread = KeGetCurrentThread();
+    PKPROCESS Process = Thread->ApcState.Process;
+    PKTRAP_FRAME TrapFrame;
+    CONTEXT Context;
+
+    /* IOPL was enabled for this process/thread */
+    Process->Iopl = TRUE;
+    Thread->Iopl = TRUE;
+
+    /* Get the trap frame on exit */
+    TrapFrame = KeGetTrapFrame(Thread);
+
+    /* Convert to a context */
+    Context.ContextFlags = CONTEXT_CONTROL;
+    KeTrapFrameToContext(TrapFrame, NULL, &Context);
+    
+    /* Set the IOPL flag */
+    Context.EFlags |= EFLAGS_IOPL;
+    
+    /* Convert back to a trap frame */
+    KeContextToTrapFrame(&Context, NULL, TrapFrame, CONTEXT_CONTROL, UserMode);
+}
  
 /* PUBLIC FUNCTIONS ***********************************************************/