Skip to content

Commit 10bb60d

Browse files
committed
Remove dependency on GetModuleHandleW and CreateEventW
Just use the `A` variants instead (already imported anyways)
1 parent 99db2ce commit 10bb60d

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

library/std/src/sys/pal/windows/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl File {
338338
fn acquire_lock(&self, flags: c::LOCK_FILE_FLAGS) -> io::Result<()> {
339339
unsafe {
340340
let mut overlapped: c::OVERLAPPED = mem::zeroed();
341-
let event = c::CreateEventW(ptr::null_mut(), c::FALSE, c::FALSE, ptr::null());
341+
let event = c::CreateEventA(ptr::null_mut(), c::FALSE, c::FALSE, ptr::null());
342342
if event.is_null() {
343343
return Err(io::Error::last_os_error());
344344
}

library/std/src/sys/pal/windows/handle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Handle {
2323
pub fn new_event(manual: bool, init: bool) -> io::Result<Handle> {
2424
unsafe {
2525
let event =
26-
c::CreateEventW(ptr::null_mut(), manual as c::BOOL, init as c::BOOL, ptr::null());
26+
c::CreateEventA(ptr::null_mut(), manual as c::BOOL, init as c::BOOL, ptr::null());
2727
if event.is_null() {
2828
Err(io::Error::last_os_error())
2929
} else {

library/std/src/sys/pal/windows/os.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ pub fn error_string(mut errnum: i32) -> String {
3131
// GetLastError. For more information about Windows error codes, see
3232
// `[MS-ERREF]`: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a
3333
if (errnum & c::FACILITY_NT_BIT as i32) != 0 {
34-
// format according to https://support.microsoft.com/en-us/help/259693
35-
const NTDLL_DLL: &[u16] = &[
36-
'N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _, '.' as _, 'D' as _, 'L' as _,
37-
'L' as _, 0,
38-
];
39-
module = c::GetModuleHandleW(NTDLL_DLL.as_ptr());
34+
module = c::GetModuleHandleA(c"NTDLL.DLL".as_ptr().cast());
4035

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

0 commit comments

Comments
 (0)