Merge pull request #1153 from napi-rs/update-windows-crate

chore(napi): upgrade windows crate
This commit is contained in:
LongYinan 2022-04-27 14:12:22 +08:00 committed by GitHub
commit 43d39fae3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View file

@ -73,7 +73,7 @@ optional = true
version = "1"
[target.'cfg(windows)'.dependencies]
windows = { version = "0.35", features = [
windows = { version = "0.36", features = [
"Win32_System_WindowsProgramming",
"Win32_System_LibraryLoader",
"Win32_Foundation",

View file

@ -10,6 +10,7 @@
//! [win_delay_load_hook.cc]: https://github.com/nodejs/node-gyp/blob/e18a61afc1669d4897e6c5c8a6694f4995a0f4d6/src/win_delay_load_hook.cc
use std::ffi::CStr;
use std::os::raw::c_char;
use windows::core::PCSTR;
use windows::Win32::Foundation::HINSTANCE;
@ -36,7 +37,20 @@ unsafe extern "C" fn load_exe_hook(event: u32, info: *const DELAYLOAD_INFO) -> H
return HINSTANCE::default();
}
unsafe { GetModuleHandleA(PCSTR::default()) }
match unsafe { GetModuleHandleA(PCSTR::default()) } {
Ok(h) => h,
Err(e) => unsafe {
let location = "win_delay_load_hook.rs\0";
let err = format!("{}", e);
crate::sys::napi_fatal_error(
location.as_ptr() as *const c_char,
22,
format!("{}\0", err).as_ptr() as *const c_char,
err.len(),
);
unreachable!();
},
}
}
#[no_mangle]