- re-add support for vectored exception handling which was removed by the major refactoring patch (r17811)

- make vmwinst depend on vectored exception handling so this doesn't happen again

svn path=/trunk/; revision=18676
This commit is contained in:
Thomas Bluemel 2005-10-22 14:05:20 +00:00
parent 9ec41a63c2
commit 6b3c8a5f9a
4 changed files with 46 additions and 19 deletions

View file

@ -14,6 +14,10 @@
typedef NTSTATUS (NTAPI *USER_CALL)(PVOID Argument, ULONG ArgumentLength);
EXCEPTION_DISPOSITION NTAPI
RtlpExecuteVectoredExceptionHandlers(IN PEXCEPTION_RECORD ExceptionRecord,
IN PCONTEXT Context);
/* FUNCTIONS ****************************************************************/
/*
@ -27,16 +31,26 @@ KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
EXCEPTION_RECORD NestedExceptionRecord;
NTSTATUS Status;
/* Dispatch the exception and check the result */
if(RtlDispatchException(ExceptionRecord, Context))
/* call the vectored exception handlers */
if(RtlpExecuteVectoredExceptionHandlers(ExceptionRecord,
Context) != ExceptionContinueExecution)
{
/* Continue executing */
Status = NtContinue(Context, FALSE);
goto ContinueExecution;
}
else
{
/* Raise an exception */
Status = NtRaiseException(ExceptionRecord, Context, FALSE);
/* Dispatch the exception and check the result */
if(RtlDispatchException(ExceptionRecord, Context))
{
ContinueExecution:
/* Continue executing */
Status = NtContinue(Context, FALSE);
}
else
{
/* Raise an exception */
Status = NtRaiseException(ExceptionRecord, Context, FALSE);
}
}
/* Setup the Exception record */

View file

@ -141,15 +141,24 @@ _KiUserExceptionDispatcher@8:
mov ecx, [esp+4]
mov ebx, [esp]
/* Dispatch the exception */
push ecx
push ebx
/* Call the vectored exception handler */
call _RtlpExecuteVectoredExceptionHandlers@8
/* Check for success */
or al, al
jnz ContinueExecution
/* Dispatch the exception */
call _RtlDispatchException@8
/* Check for success */
or al, al
jz RaiseException
ContinueExecution:
/* Pop off the records */
pop ebx
pop ecx

View file

@ -28,7 +28,7 @@ typedef struct _RTL_VECTORED_EXCEPTION_HANDLER
/* FUNCTIONS ***************************************************************/
EXCEPTION_DISPOSITION
EXCEPTION_DISPOSITION NTAPI
RtlpExecuteVectoredExceptionHandlers(IN PEXCEPTION_RECORD ExceptionRecord,
IN PCONTEXT Context)
{

View file

@ -60,10 +60,9 @@ static LONG AbortInstall = 0;
/* Helper functions */
LONG WINAPI ExceptionHandler(LPEXCEPTION_POINTERS ExceptionInfo)
LONG CALLBACK VectoredExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo)
{
/* This is rude, but i don't know how to continue execution properly, that's why
we just exit here when we're not running inside of VMware */
/* we're not running in VMware, just terminate the process */
ExitProcess(ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION);
return EXCEPTION_CONTINUE_EXECUTION;
}
@ -1196,23 +1195,28 @@ WinMain(HINSTANCE hInstance,
int nCmdShow)
{
LPTOP_LEVEL_EXCEPTION_FILTER OldHandler;
PVOID ExceptionHandler;
int Version;
WCHAR *lc;
hAppInstance = hInstance;
/* Setup our exception "handler" ;-) */
OldHandler = SetUnhandledExceptionFilter(ExceptionHandler);
if(!DetectVMware(&Version))
/* Setup a vectored exception handler to protect the detection. Don't use SEH
here so we notice the next time someone removes support for vectored
exception handling from ros... */
if (!(ExceptionHandler = AddVectoredExceptionHandler(0,
VectoredExceptionHandler)))
{
ExitProcess(1);
return 1;
}
/* restore the exception handler */
SetUnhandledExceptionFilter(OldHandler);
if(!DetectVMware(&Version))
{
return 1;
}
/* unregister the handler */
RemoveVectoredExceptionHandler(ExceptionHandler);
lc = DestinationPath;
lc += GetSystemDirectory(DestinationPath, MAX_PATH) - 1;