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

svn path=/trunk/; revision=17814
This commit is contained in:
Alex Ionescu 2005-09-12 02:57:47 +00:00
parent 19ca3d1d83
commit 9e5af04e26
5 changed files with 52 additions and 20 deletions

View file

@ -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

View file

@ -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:

View file

@ -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*/

View file

@ -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 */

View file

@ -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 @@ _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