do not round-trip function pointer through integer
This commit is contained in:
parent
fe85591989
commit
c599a4cfc3
@ -92,11 +92,10 @@ macro_rules! compat_fn {
|
|||||||
let symbol_name: *const u8 = concat!(stringify!($symbol), "\0").as_ptr();
|
let symbol_name: *const u8 = concat!(stringify!($symbol), "\0").as_ptr();
|
||||||
let module_handle = $crate::sys::c::GetModuleHandleA(module_name as *const i8);
|
let module_handle = $crate::sys::c::GetModuleHandleA(module_name as *const i8);
|
||||||
if !module_handle.is_null() {
|
if !module_handle.is_null() {
|
||||||
match $crate::sys::c::GetProcAddress(module_handle, symbol_name as *const i8).addr() {
|
let ptr = $crate::sys::c::GetProcAddress(module_handle, symbol_name as *const i8);
|
||||||
0 => {}
|
if !ptr.is_null() {
|
||||||
n => {
|
// Transmute to the right function pointer type.
|
||||||
return Some(mem::transmute::<usize, F>(n));
|
return Some(mem::transmute(ptr));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user