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

View file

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

View file

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

View file

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