Skip to content

Commit

Permalink
Remove dependency on GetModuleHandleW and CreateEventW
Browse files Browse the repository at this point in the history
Just use the `A` variants instead (already imported anyways)
  • Loading branch information
seritools committed Dec 1, 2024
1 parent 99db2ce commit 10bb60d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl File {
fn acquire_lock(&self, flags: c::LOCK_FILE_FLAGS) -> io::Result<()> {
unsafe {
let mut overlapped: c::OVERLAPPED = mem::zeroed();
let event = c::CreateEventW(ptr::null_mut(), c::FALSE, c::FALSE, ptr::null());
let event = c::CreateEventA(ptr::null_mut(), c::FALSE, c::FALSE, ptr::null());
if event.is_null() {
return Err(io::Error::last_os_error());
}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/windows/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Handle {
pub fn new_event(manual: bool, init: bool) -> io::Result<Handle> {
unsafe {
let event =
c::CreateEventW(ptr::null_mut(), manual as c::BOOL, init as c::BOOL, ptr::null());
c::CreateEventA(ptr::null_mut(), manual as c::BOOL, init as c::BOOL, ptr::null());
if event.is_null() {
Err(io::Error::last_os_error())
} else {
Expand Down
7 changes: 1 addition & 6 deletions library/std/src/sys/pal/windows/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ pub fn error_string(mut errnum: i32) -> String {
// GetLastError. For more information about Windows error codes, see
// `[MS-ERREF]`: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a
if (errnum & c::FACILITY_NT_BIT as i32) != 0 {
// format according to https://support.microsoft.com/en-us/help/259693
const NTDLL_DLL: &[u16] = &[
'N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _, '.' as _, 'D' as _, 'L' as _,
'L' as _, 0,
];
module = c::GetModuleHandleW(NTDLL_DLL.as_ptr());
module = c::GetModuleHandleA(c"NTDLL.DLL".as_ptr().cast());

if !module.is_null() {
errnum ^= c::FACILITY_NT_BIT as i32;
Expand Down

0 comments on commit 10bb60d

Please sign in to comment.