From 64887ac832dbc99486a831809fc142b21f8c0a28 Mon Sep 17 00:00:00 2001 From: Dennis Duda Date: Fri, 29 Nov 2024 23:45:20 +0100 Subject: [PATCH] Remove dependency on `GetModuleHandleW` and `CreateEventW` Just use the `A` variants instead (already imported anyways) --- library/std/src/sys/pal/windows/fs.rs | 2 +- library/std/src/sys/pal/windows/handle.rs | 2 +- library/std/src/sys/pal/windows/os.rs | 7 +------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/library/std/src/sys/pal/windows/fs.rs b/library/std/src/sys/pal/windows/fs.rs index 74b5a99f5e3e0..1d6a6732f9c48 100644 --- a/library/std/src/sys/pal/windows/fs.rs +++ b/library/std/src/sys/pal/windows/fs.rs @@ -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()); } diff --git a/library/std/src/sys/pal/windows/handle.rs b/library/std/src/sys/pal/windows/handle.rs index 82a880faf5fa7..e86db56e63c92 100644 --- a/library/std/src/sys/pal/windows/handle.rs +++ b/library/std/src/sys/pal/windows/handle.rs @@ -23,7 +23,7 @@ impl Handle { pub fn new_event(manual: bool, init: bool) -> io::Result { 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 { diff --git a/library/std/src/sys/pal/windows/os.rs b/library/std/src/sys/pal/windows/os.rs index 048d238995c8a..2b548873c2684 100644 --- a/library/std/src/sys/pal/windows/os.rs +++ b/library/std/src/sys/pal/windows/os.rs @@ -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;