Author: ion
Date: Mon Feb 20 06:43:54 2012
New Revision: 55735

URL: http://svn.reactos.org/svn/reactos?rev=55735&view=rev
Log:
[NTOSKRNL]: MOV CRX, YYY and MOV YYY, CRX, as well as the DR equivalents were 
not correctly detected as privileged instructions in the GPF handler. Fixes 
Winetests.
[NTOSKRNL]: The "Write" bit in the x86 Error Code is not bit 1, it is bit 2. 
Fix all the GPF handlers to check for bit 2 instead when determining if an 
exception was due to read or write. Fixes Winetests.
I'll say it nicely this time for Timo: when you rewrite ASM, do it carefully :)

Modified:
    trunk/reactos/ntoskrnl/ke/i386/traphdlr.c

Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.c?rev=55735&r1=55734&r2=55735&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Mon Feb 20 06:43:54 
2012
@@ -970,6 +970,12 @@
             }
             
             /* Check for privileged instructions */
+            DPRINT("Instruction (%d) at fault: %lx %lx %lx %lx\n",
+                    i,
+                    Instructions[i],
+                    Instructions[i + 1],
+                    Instructions[i + 2],
+                    Instructions[i + 3]);
             if (Instruction == 0xF4)                            // HLT
             {
                 /* HLT is privileged */
@@ -988,10 +994,11 @@
                     (Instructions[i + 1] == 0x08) ||               // INVD
                     (Instructions[i + 1] == 0x09) ||               // WBINVD
                     (Instructions[i + 1] == 0x35) ||               // SYSEXIT
-                    (Instructions[i + 1] == 0x26) ||               // MOV DR, 
XXX
+                    (Instructions[i + 1] == 0x21) ||               // MOV DR, 
XXX
                     (Instructions[i + 1] == 0x06) ||               // CLTS
                     (Instructions[i + 1] == 0x20) ||               // MOV CR, 
XXX
-                    (Instructions[i + 1] == 0x24) ||               // MOV YYY, 
DR
+                    (Instructions[i + 1] == 0x22) ||               // MOV XXX, 
CR
+                    (Instructions[i + 1] == 0x23) ||               // MOV YYY, 
DR
                     (Instructions[i + 1] == 0x30) ||               // WRMSR
                     (Instructions[i + 1] == 0x33))                 // RDPMC
                     // INVLPG, INVLPGA, SYSRET
@@ -1192,7 +1199,7 @@
             KeBugCheckWithTf(IRQL_NOT_LESS_OR_EQUAL,
                              Cr2,
                              -1,
-                             TrapFrame->ErrCode & 1,
+                             TrapFrame->ErrCode & 2 ? TRUE : FALSE,
                              TrapFrame->Eip,
                              TrapFrame);
         }
@@ -1254,7 +1261,7 @@
         /* This status code is repurposed so we can recognize it later */
         KiDispatchException2Args(KI_EXCEPTION_ACCESS_VIOLATION,
                                  TrapFrame->Eip,
-                                 TrapFrame->ErrCode & 1,
+                                 TrapFrame->ErrCode & 2 ? TRUE : FALSE,
                                  Cr2,
                                  TrapFrame);
     }
@@ -1264,7 +1271,7 @@
         /* These faults only have two parameters */
         KiDispatchException2Args(Status,
                                  TrapFrame->Eip,
-                                 TrapFrame->ErrCode & 1,
+                                 TrapFrame->ErrCode & 2 ? TRUE : FALSE,
                                  Cr2,
                                  TrapFrame);
     }
@@ -1273,7 +1280,7 @@
     KiDispatchExceptionFromTrapFrame(STATUS_IN_PAGE_ERROR,
                                      TrapFrame->Eip,
                                      3,
-                                     TrapFrame->ErrCode & 1,
+                                     TrapFrame->ErrCode & 2 ? TRUE : FALSE,
                                      Cr2,
                                      Status,
                                      TrapFrame);


Reply via email to