提交 c599a4cf 编写于 作者: R Ralf Jung

do not round-trip function pointer through integer

上级 fe855919
......@@ -92,11 +92,10 @@ pub mod $symbol {
let symbol_name: *const u8 = concat!(stringify!($symbol), "\0").as_ptr();
let module_handle = $crate::sys::c::GetModuleHandleA(module_name as *const i8);
if !module_handle.is_null() {
match $crate::sys::c::GetProcAddress(module_handle, symbol_name as *const i8).addr() {
0 => {}
n => {
return Some(mem::transmute::<usize, F>(n));
}
let ptr = $crate::sys::c::GetProcAddress(module_handle, symbol_name as *const i8);
if !ptr.is_null() {
// Transmute to the right function pointer type.
return Some(mem::transmute(ptr));
}
}
return None;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册