From 5604f3d826ddfd696663bfc571ab11329398c93a Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Thu, 18 Mar 2021 16:22:05 +0100 Subject: [PATCH] fixes fro win32 --- libafl/src/bolts/os/windows_exceptions.rs | 2 +- libafl/src/bolts/shmem.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libafl/src/bolts/os/windows_exceptions.rs b/libafl/src/bolts/os/windows_exceptions.rs index 5193cd4ef1..5eb41413f8 100644 --- a/libafl/src/bolts/os/windows_exceptions.rs +++ b/libafl/src/bolts/os/windows_exceptions.rs @@ -217,7 +217,7 @@ pub unsafe fn setup_exception_handler(handler: &mut T) -> compiler_fence(Ordering::SeqCst); unsafe { - if let Some(prev) = SetUnhandledExceptionFilter(Some(handle_exception)) { + if let Some(prev) = SetUnhandledExceptionFilter(Some(core::mem::transmute(handle_exception as as *const c_void))) { PREVIOUS_HANDLER = Some(core::mem::transmute(prev as *const c_void)); } } diff --git a/libafl/src/bolts/shmem.rs b/libafl/src/bolts/shmem.rs index ef2f491d1e..eb79ff8777 100644 --- a/libafl/src/bolts/shmem.rs +++ b/libafl/src/bolts/shmem.rs @@ -455,10 +455,10 @@ pub mod shmem { Error, }; - use core::{ptr, slice}; + use core::{ptr, slice, ffi::c_void}; use uuid::Uuid; - const INVALID_HANDLE_VALUE: i32 = -1; + const INVALID_HANDLE_VALUE: isize = -1; const FILE_MAP_ALL_ACCESS: u32 = 0xf001f; const PAGE_READWRITE: u32 = 0x04; @@ -509,7 +509,7 @@ pub mod shmem { impl Win32ShMem { pub fn from_str(map_str_bytes: &[u8; 20], map_size: usize) -> Result { unsafe { - let handle = OpenFileMappingA(FILE_MAP_ALL_ACCESS, false, map_str_bytes as *const u8); + let handle = OpenFileMappingA(FILE_MAP_ALL_ACCESS, false, map_str_bytes as *const u8 as *const i8); if handle == HANDLE(0) { return Err(Error::Unknown(format!( "Cannot open shared memory {}", @@ -528,23 +528,23 @@ pub mod shmem { Ok(Self { shm_str: map_str_bytes.clone(), handle: handle, - map; map, + map: map, map_size: map_size, }) } pub fn new(map_size: usize) -> Result { - let uuid = Uuid::new_v4().unwrap(); + let uuid = Uuid::new_v4(); let mut map_str_bytes = format!("libafl_{}", uuid.to_simple()).as_mut_bytes(); map_str_bytes[19] = 0; // Trucate to size 20 unsafe { let handle = CreateFileMappingA( - INVALID_HANDLE_VALUE, + HANDLE(INVALID_HANDLE_VALUE), ptr::null_mut(), PAGE_READWRITE, 0, map_size as u32, - map_str_bytes as *const u8, + map_str_bytes as *const u8 as *const i8, ); if handle == HANDLE(0) { return Err(Error::Unknown(format!(