Fix RtlpGetStackLimits to get the right limits if called in kernel-mode (separated implementations). Also don't return from _SEH_TRY blocks, because PSEH doesn't support this. Also temporarly disable a ProbeForRead check in KiContinue because it currently causes trouble
Modified: trunk/reactos/lib/ntdll/main/i386/dispatch.S
Modified: trunk/reactos/lib/rtl/i386/except.s
Modified: trunk/reactos/ntoskrnl/ke/exception.c
Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
Modified: trunk/reactos/ntoskrnl/rtl/i386/seh.s

Modified: trunk/reactos/lib/ntdll/main/i386/dispatch.S
--- trunk/reactos/lib/ntdll/main/i386/dispatch.S	2005-09-12 01:32:11 UTC (rev 17813)
+++ trunk/reactos/lib/ntdll/main/i386/dispatch.S	2005-09-12 02:57:47 UTC (rev 17814)
@@ -184,3 +184,19 @@
     call _RtlRaiseException@4
     ret 8
 
+.globl _RtlpGetStackLimits@8
+_RtlpGetStackLimits@8:
+
+    /* Get the stack limits */
+    mov eax, [fs:TEB_STACK_LIMIT]
+    mov ecx, [fs:TEB_STACK_BASE]
+
+    /* Return them */
+    mov edx, [esp+4]
+    mov [edx], eax
+    mov edx, [esp+8]
+    mov [edx], ecx
+
+    /* return */
+    ret 8
+

Modified: trunk/reactos/lib/rtl/i386/except.s
--- trunk/reactos/lib/rtl/i386/except.s	2005-09-12 01:32:11 UTC (rev 17813)
+++ trunk/reactos/lib/rtl/i386/except.s	2005-09-12 02:57:47 UTC (rev 17814)
@@ -24,22 +24,6 @@
 
 /* FUNCTIONS ****************************************************************/
 
-.globl _RtlpGetStackLimits@8
-_RtlpGetStackLimits@8:
-
-    /* Get the stack limits */
-    mov eax, [fs:TEB_STACK_LIMIT]
-    mov ecx, [fs:TEB_STACK_BASE]
-
-    /* Return them */
-    mov edx, [esp+4]
-    mov [edx], eax
-    mov edx, [esp+8]
-    mov [edx], ecx
-
-    /* return */
-    ret 8
-
 .globl _RtlpGetExceptionList@0
 _RtlpGetExceptionList@0:
 

Modified: trunk/reactos/ntoskrnl/ke/exception.c
--- trunk/reactos/ntoskrnl/ke/exception.c	2005-09-12 01:32:11 UTC (rev 17813)
+++ trunk/reactos/ntoskrnl/ke/exception.c	2005-09-12 02:57:47 UTC (rev 17814)
@@ -23,7 +23,7 @@
     CONTEXT LocalContext;
 
     /* We'll have to make a copy and probe it */
-    ProbeForRead(Context, sizeof(CONTEXT), sizeof(ULONG));
+    //ProbeForRead(Context, sizeof(CONTEXT), sizeof(ULONG));
     RtlMoveMemory(&LocalContext, Context, sizeof(CONTEXT));
     Context = &LocalContext;
 
@@ -99,6 +99,7 @@
         /* Check the previous mode */
         if (PreviousMode != KernelMode)
         {
+#if 0
             /* Probe the context */
             ProbeForRead(Context, sizeof(CONTEXT), sizeof(ULONG));
 
@@ -107,13 +108,14 @@
                          FIELD_OFFSET(EXCEPTION_RECORD, NumberParameters) +
                          sizeof(ULONG),
                          sizeof(ULONG));
-
+#endif
             /* Validate the maximum parameters */
             if ((ParameterCount = ExceptionRecord->NumberParameters) >
                 EXCEPTION_MAXIMUM_PARAMETERS)
             {
                 /* Too large */
-                return STATUS_INVALID_PARAMETER;
+                Status = STATUS_INVALID_PARAMETER;
+                _SEH_LEAVE;
             }
 
             /* Probe the entire parameters now*/

Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
--- trunk/reactos/ntoskrnl/ke/i386/exp.c	2005-09-12 01:32:11 UTC (rev 17813)
+++ trunk/reactos/ntoskrnl/ke/i386/exp.c	2005-09-12 02:57:47 UTC (rev 17814)
@@ -930,6 +930,7 @@
     KD_CONTINUE_TYPE Action;
     ULONG_PTR Stack, NewStack;
     ULONG Size;
+    BOOLEAN UserDispatch = FALSE;
     DPRINT1("KiDispatchException() called\n");
 
     /* Increase number of Exception Dispatches */
@@ -1042,7 +1043,8 @@
 
                 /* Set EIP to the User-mode Dispathcer */
                 TrapFrame->Eip = (ULONG)KeUserExceptionDispatcher;
-                return;
+                UserDispatch = TRUE;
+                _SEH_LEAVE;
             }
             _SEH_HANDLE
             {
@@ -1051,6 +1053,9 @@
             _SEH_END;
         }
 
+        /* If we dispatch to user, return now */
+        if (UserDispatch) return;
+
         /* FIXME: Forward the exception to the debugger for 2nd chance */
 
         /* 3rd strike, kill the thread */

Modified: trunk/reactos/ntoskrnl/rtl/i386/seh.s
--- trunk/reactos/ntoskrnl/rtl/i386/seh.s	2005-09-12 01:32:11 UTC (rev 17813)
+++ trunk/reactos/ntoskrnl/rtl/i386/seh.s	2005-09-12 02:57:47 UTC (rev 17814)
@@ -9,6 +9,8 @@
  *                    Please keep them in sync.
  */
 
+#include <ndk/asm.h>
+
 #define ExceptionContinueExecution	0
 #define ExceptionContinueSearch		1
 #define ExceptionNestedException	2
@@ -364,3 +366,26 @@
 
     // We should never get here
     ret
+    
+.intel_syntax noprefix
+.globl _RtlpGetStackLimits@8
+_RtlpGetStackLimits@8:
+
+    /* Get the current thread */
+    mov eax, [fs:KPCR_CURRENT_THREAD]
+
+    /* Get the stack limits */
+    mov ecx, [eax+KTHREAD_STACK_LIMIT]
+    mov edx, [eax+KTHREAD_INITIAL_STACK]
+    sub edx, SIZEOF_FX_SAVE_AREA
+
+    /* Return them */
+    mov eax, [esp+4]
+    mov [eax], ecx
+
+    mov eax, [esp+8]
+    mov [eax], edx
+
+    /* return */
+    ret 8
+