Improve Windows page fault handler.

- Re-throw exception if not access violation exception.
- If pointer is not within known pointers also re-throw.

Change-Id: I01461f550994e32c9e8757b0344e70f2195612fb
Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
Mrozek, Michal
2019-09-06 11:57:39 +02:00
committed by sys_ocldev
parent 093bc4da9c
commit d4571d685a
3 changed files with 34 additions and 6 deletions

View File

@@ -18,10 +18,14 @@ std::function<LONG(struct _EXCEPTION_POINTERS *exceptionInfo)> PageFaultManagerW
PageFaultManagerWindows::PageFaultManagerWindows() {
pageFaultHandler = [&](struct _EXCEPTION_POINTERS *exceptionInfo) {
if (exceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && !this->verifyPageFault(reinterpret_cast<void *>(exceptionInfo->ExceptionRecord->ExceptionInformation[1]))) {
return EXCEPTION_CONTINUE_SEARCH;
if (exceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
if (this->verifyPageFault(reinterpret_cast<void *>(exceptionInfo->ExceptionRecord->ExceptionInformation[1]))) {
//this is our fault that we serviced, continue app execution
return EXCEPTION_CONTINUE_EXECUTION;
}
}
return EXCEPTION_CONTINUE_EXECUTION;
//not our exception
return EXCEPTION_CONTINUE_SEARCH;
};
previousHandler = AddVectoredExceptionHandler(1, pageFaultHandlerWrapper);