[ros-diffs] [sir_richard] 45509: [NTOS]: Sync up KiDispatchException with x86 code (and going back to C comment formatting).

sir_richard at svn.reactos.org sir_richard at svn.reactos.org
Tue Feb 9 03:00:52 CET 2010


Author: sir_richard
Date: Tue Feb  9 03:00:52 2010
New Revision: 45509

URL: http://svn.reactos.org/svn/reactos?rev=45509&view=rev
Log:
[NTOS]: Sync up KiDispatchException with x86 code (and going back to C comment formatting).

Modified:
    trunk/reactos/ntoskrnl/ke/arm/exp.c

Modified: trunk/reactos/ntoskrnl/ke/arm/exp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/exp.c?rev=45509&r1=45508&r2=45509&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/exp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/exp.c [iso-8859-1] Tue Feb  9 03:00:52 2010
@@ -176,67 +176,51 @@
                     IN BOOLEAN FirstChance)
 {
     CONTEXT Context;
-    
-    //
-    // Increase number of Exception Dispatches
-    //
+
+    /* Increase number of Exception Dispatches */
     KeGetCurrentPrcb()->KeExceptionDispatchCount++;
-    
-    //
-    // Set the context flags
-    //
+
+    /* Set the context flags */
     Context.ContextFlags = CONTEXT_FULL;
     
-    //
-    // FIXME-V6: VFP Support
-    //
-    
-    //
-    // Get a Context
-    //
+    /* Check if User Mode or if the kernel debugger is enabled */
+    if ((PreviousMode == UserMode) || (KeGetPcr()->KdVersionBlock))
+    {
+        /* FIXME-V6: VFP Support */
+    }
+
+    /* Get a Context */
     KeTrapFrameToContext(TrapFrame, ExceptionFrame, &Context);
-    
-    //
-    // Look at our exception code
-    //
+
+    /* Look at our exception code */
     switch (ExceptionRecord->ExceptionCode)
     {
-        //
-        // Breakpoint
-        //
+        /* Breakpoint */
         case STATUS_BREAKPOINT:
-            
-            //
-            // We want the instruction right before the int 3
-            //
+
+            /* Decrement PC by four */
             Context.Pc -= sizeof(ULONG);
             break;
-            
-        //
-        // Internal exception
-        //
+
+        /* Internal exception */
         case KI_EXCEPTION_ACCESS_VIOLATION:
-            
-            //
-            // Set correct code
-            //
+
+            /* Set correct code */
             ExceptionRecord->ExceptionCode = STATUS_ACCESS_VIOLATION;
+            if (PreviousMode == UserMode)
+            {
+                /* FIXME: Handle no execute */
+            }
             break;
     }
-       
-    //
-    // Handle kernel-mode first, it's simpler
-    //
+
+    /* Handle kernel-mode first, it's simpler */
     if (PreviousMode == KernelMode)
     {
-        //
-        // Check if this is a first-chance exception
-        //
+        /* Check if this is a first-chance exception */
         if (FirstChance == TRUE)
         {
-            //
-            // Break into the debugger for the first time
-            //
+            /* Break into the debugger for the first time */
             if (KiDebugRoutine(TrapFrame,
                                ExceptionFrame,
                                ExceptionRecord,
@@ -244,21 +228,15 @@
                                PreviousMode,
                                FALSE))
             {
-                //
-                // Exception was handled
-                //
+                /* Exception was handled */
                 goto Handled;
             }
-            
-            //
-            // If the Debugger couldn't handle it, dispatch the exception
-            //
+
+            /* If the Debugger couldn't handle it, dispatch the exception */
             if (RtlDispatchException(ExceptionRecord, &Context)) goto Handled;
         }
-        
-        //
-        // This is a second-chance exception, only for the debugger
-        //
+
+        /* This is a second-chance exception, only for the debugger */
         if (KiDebugRoutine(TrapFrame,
                            ExceptionFrame,
                            ExceptionRecord,
@@ -266,15 +244,11 @@
                            PreviousMode,
                            TRUE))
         {
-            //
-            // Exception was handled
-            //
+            /* Exception was handled */
             goto Handled;
         }
-        
-        //
-        // Third strike; you're out
-        //
+
+        /* Third strike; you're out */
         KeBugCheckEx(KMODE_EXCEPTION_NOT_HANDLED,
                      ExceptionRecord->ExceptionCode,
                      (ULONG_PTR)ExceptionRecord->ExceptionAddress,
@@ -283,19 +257,27 @@
     }
     else
     {
-        //
-        // FIXME-USER: Do user-mode exception handling
-        //
-        ASSERT(FALSE);
-    }
-    
+        /* FIXME: TODO */
+        /* 3rd strike, kill the process */
+        DPRINT1("Kill %.16s, ExceptionCode: %lx, ExceptionAddress: %lx\n",
+                PsGetCurrentProcess()->ImageFileName,
+                ExceptionRecord->ExceptionCode,
+                ExceptionRecord->ExceptionAddress);
+
+        ZwTerminateProcess(NtCurrentProcess(), ExceptionRecord->ExceptionCode);
+        KeBugCheckEx(KMODE_EXCEPTION_NOT_HANDLED,
+                     ExceptionRecord->ExceptionCode,
+                     (ULONG_PTR)ExceptionRecord->ExceptionAddress,
+                     (ULONG_PTR)TrapFrame,
+                     0);
+    }
+
 Handled:
-    //
-    // Convert the context back into Trap/Exception Frames
-    //
+    /* Convert the context back into Trap/Exception Frames */
     KeContextToTrapFrame(&Context,
                          ExceptionFrame,
                          TrapFrame,
                          Context.ContextFlags,
                          PreviousMode);
+    return;
 }




More information about the Ros-diffs mailing list