diff --git a/reactos/lib/ntdll/main/i386/dispatch.S b/reactos/lib/ntdll/main/i386/dispatch.S index 42bbff5f74c..a812835f8cc 100644 --- a/reactos/lib/ntdll/main/i386/dispatch.S +++ b/reactos/lib/ntdll/main/i386/dispatch.S @@ -184,3 +184,19 @@ Exit: 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 + diff --git a/reactos/lib/rtl/i386/except.s b/reactos/lib/rtl/i386/except.s index ac8b3840368..949c92ff0ce 100644 --- a/reactos/lib/rtl/i386/except.s +++ b/reactos/lib/rtl/i386/except.s @@ -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: diff --git a/reactos/ntoskrnl/ke/exception.c b/reactos/ntoskrnl/ke/exception.c index 7ecf15783b9..40f190e472b 100644 --- a/reactos/ntoskrnl/ke/exception.c +++ b/reactos/ntoskrnl/ke/exception.c @@ -23,7 +23,7 @@ KiContinuePreviousModeUser(IN PCONTEXT Context, 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 @@ KiRaiseException(PEXCEPTION_RECORD ExceptionRecord, /* Check the previous mode */ if (PreviousMode != KernelMode) { +#if 0 /* Probe the context */ ProbeForRead(Context, sizeof(CONTEXT), sizeof(ULONG)); @@ -107,13 +108,14 @@ KiRaiseException(PEXCEPTION_RECORD ExceptionRecord, 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*/ diff --git a/reactos/ntoskrnl/ke/i386/exp.c b/reactos/ntoskrnl/ke/i386/exp.c index 61f2bba4ccd..2288f27b224 100644 --- a/reactos/ntoskrnl/ke/i386/exp.c +++ b/reactos/ntoskrnl/ke/i386/exp.c @@ -930,6 +930,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, 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 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, /* Set EIP to the User-mode Dispathcer */ TrapFrame->Eip = (ULONG)KeUserExceptionDispatcher; - return; + UserDispatch = TRUE; + _SEH_LEAVE; } _SEH_HANDLE { @@ -1051,6 +1053,9 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, _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 */ diff --git a/reactos/ntoskrnl/rtl/i386/seh.s b/reactos/ntoskrnl/rtl/i386/seh.s index 03ccd6b3ba6..8255cf87ced 100755 --- a/reactos/ntoskrnl/rtl/i386/seh.s +++ b/reactos/ntoskrnl/rtl/i386/seh.s @@ -9,6 +9,8 @@ * Please keep them in sync. */ +#include + #define ExceptionContinueExecution 0 #define ExceptionContinueSearch 1 #define ExceptionNestedException 2 @@ -364,3 +366,26 @@ _except_finish: // 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 +