From bb3d6b36883bb4485ab658138b141350ecddbf00 Mon Sep 17 00:00:00 2001 From: expend20 <36543551+expend20@users.noreply.github.com> Date: Thu, 13 Oct 2022 09:06:15 +0200 Subject: [PATCH] Frida Windows: calling original UnhandledExceptionFilter in the hook (#832) --- libafl/src/bolts/os/windows_exceptions.rs | 4 +++- libafl_frida/src/windows_hooks.rs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libafl/src/bolts/os/windows_exceptions.rs b/libafl/src/bolts/os/windows_exceptions.rs index 170ef1a541..7e722642df 100644 --- a/libafl/src/bolts/os/windows_exceptions.rs +++ b/libafl/src/bolts/os/windows_exceptions.rs @@ -14,7 +14,9 @@ use num_enum::TryFromPrimitive; pub use windows::Win32::{ Foundation::NTSTATUS, System::{ - Diagnostics::Debug::{AddVectoredExceptionHandler, EXCEPTION_POINTERS}, + Diagnostics::Debug::{ + AddVectoredExceptionHandler, UnhandledExceptionFilter, EXCEPTION_POINTERS, + }, Threading::{IsProcessorFeaturePresent, PROCESSOR_FEATURE_ID}, }, }; diff --git a/libafl_frida/src/windows_hooks.rs b/libafl_frida/src/windows_hooks.rs index 06bae64a6e..61bdfad230 100644 --- a/libafl_frida/src/windows_hooks.rs +++ b/libafl_frida/src/windows_hooks.rs @@ -1,7 +1,8 @@ // Based on the example of setting hooks: Https://github.com/frida/frida-rust/blob/main/examples/gum/hook_open/src/lib.rs use frida_gum::{interceptor::Interceptor, Gum, Module, NativePointer}; use libafl::bolts::os::windows_exceptions::{ - handle_exception, IsProcessorFeaturePresent, EXCEPTION_POINTERS, PROCESSOR_FEATURE_ID, + handle_exception, IsProcessorFeaturePresent, UnhandledExceptionFilter, EXCEPTION_POINTERS, + PROCESSOR_FEATURE_ID, }; /// Initialize the hooks @@ -50,6 +51,6 @@ pub fn initialize(gum: &Gum) { exception_pointers: *mut EXCEPTION_POINTERS, ) -> i32 { handle_exception(exception_pointers); - unreachable!("handle_exception should not return"); + UnhandledExceptionFilter(exception_pointers) } }