//===- FuzzerUtilWindows.cpp - Misc utils for Windows. --------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // Misc utils implementation for Windows. //===----------------------------------------------------------------------===// #include"FuzzerPlatform.h" #if LIBFUZZER_WINDOWS #include"FuzzerCommand.h" #include"FuzzerIO.h" #include"FuzzerInternal.h" #include <cassert> #include <chrono> #include <cstring> #include <errno.h> #include <io.h> #include <iomanip> #include <signal.h> #include <stdio.h> #include <sys/types.h> #include <windows.h>
// This must be included after windows.h. #include <psapi.h>
namespace fuzzer {
staticconst FuzzingOptions* HandlerOpt = nullptr;
staticLONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo) { switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: case EXCEPTION_STACK_OVERFLOW: if (HandlerOpt->HandleSegv)
Fuzzer::StaticCrashSignalCallback(); break; case EXCEPTION_DATATYPE_MISALIGNMENT: case EXCEPTION_IN_PAGE_ERROR: if (HandlerOpt->HandleBus)
Fuzzer::StaticCrashSignalCallback(); break; case EXCEPTION_ILLEGAL_INSTRUCTION: case EXCEPTION_PRIV_INSTRUCTION: if (HandlerOpt->HandleIll)
Fuzzer::StaticCrashSignalCallback(); break; case EXCEPTION_FLT_DENORMAL_OPERAND: case EXCEPTION_FLT_DIVIDE_BY_ZERO: case EXCEPTION_FLT_INEXACT_RESULT: case EXCEPTION_FLT_INVALID_OPERATION: case EXCEPTION_FLT_OVERFLOW: case EXCEPTION_FLT_STACK_CHECK: case EXCEPTION_FLT_UNDERFLOW: case EXCEPTION_INT_DIVIDE_BY_ZERO: case EXCEPTION_INT_OVERFLOW: if (HandlerOpt->HandleFpe)
Fuzzer::StaticCrashSignalCallback(); break; // TODO: handle (Options.HandleXfsz)
} return EXCEPTION_CONTINUE_SEARCH;
}
BOOL WINAPI CtrlHandler(DWORD dwCtrlType) { switch (dwCtrlType) { case CTRL_C_EVENT: if (HandlerOpt->HandleInt)
Fuzzer::StaticInterruptCallback(); returnTRUE; case CTRL_BREAK_EVENT: if (HandlerOpt->HandleTerm)
Fuzzer::StaticInterruptCallback(); returnTRUE;
} returnFALSE;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.