fixes fro win32
This commit is contained in:
parent
c447db6db6
commit
5604f3d826
@ -217,7 +217,7 @@ pub unsafe fn setup_exception_handler<T: 'static + Handler>(handler: &mut T) ->
|
|||||||
compiler_fence(Ordering::SeqCst);
|
compiler_fence(Ordering::SeqCst);
|
||||||
|
|
||||||
unsafe {
|
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));
|
PREVIOUS_HANDLER = Some(core::mem::transmute(prev as *const c_void));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,10 +455,10 @@ pub mod shmem {
|
|||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
use core::{ptr, slice};
|
use core::{ptr, slice, ffi::c_void};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
const INVALID_HANDLE_VALUE: i32 = -1;
|
const INVALID_HANDLE_VALUE: isize = -1;
|
||||||
const FILE_MAP_ALL_ACCESS: u32 = 0xf001f;
|
const FILE_MAP_ALL_ACCESS: u32 = 0xf001f;
|
||||||
const PAGE_READWRITE: u32 = 0x04;
|
const PAGE_READWRITE: u32 = 0x04;
|
||||||
|
|
||||||
@ -509,7 +509,7 @@ pub mod shmem {
|
|||||||
impl Win32ShMem {
|
impl Win32ShMem {
|
||||||
pub fn from_str(map_str_bytes: &[u8; 20], map_size: usize) -> Result<Self, Error> {
|
pub fn from_str(map_str_bytes: &[u8; 20], map_size: usize) -> Result<Self, Error> {
|
||||||
unsafe {
|
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) {
|
if handle == HANDLE(0) {
|
||||||
return Err(Error::Unknown(format!(
|
return Err(Error::Unknown(format!(
|
||||||
"Cannot open shared memory {}",
|
"Cannot open shared memory {}",
|
||||||
@ -528,23 +528,23 @@ pub mod shmem {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
shm_str: map_str_bytes.clone(),
|
shm_str: map_str_bytes.clone(),
|
||||||
handle: handle,
|
handle: handle,
|
||||||
map; map,
|
map: map,
|
||||||
map_size: map_size,
|
map_size: map_size,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(map_size: usize) -> Result<Self, Error> {
|
pub fn new(map_size: usize) -> Result<Self, Error> {
|
||||||
let uuid = Uuid::new_v4().unwrap();
|
let uuid = Uuid::new_v4();
|
||||||
let mut map_str_bytes = format!("libafl_{}", uuid.to_simple()).as_mut_bytes();
|
let mut map_str_bytes = format!("libafl_{}", uuid.to_simple()).as_mut_bytes();
|
||||||
map_str_bytes[19] = 0; // Trucate to size 20
|
map_str_bytes[19] = 0; // Trucate to size 20
|
||||||
unsafe {
|
unsafe {
|
||||||
let handle = CreateFileMappingA(
|
let handle = CreateFileMappingA(
|
||||||
INVALID_HANDLE_VALUE,
|
HANDLE(INVALID_HANDLE_VALUE),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
0,
|
0,
|
||||||
map_size as u32,
|
map_size as u32,
|
||||||
map_str_bytes as *const u8,
|
map_str_bytes as *const u8 as *const i8,
|
||||||
);
|
);
|
||||||
if handle == HANDLE(0) {
|
if handle == HANDLE(0) {
|
||||||
return Err(Error::Unknown(format!(
|
return Err(Error::Unknown(format!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user