Skip to content

Commit c999188

Browse files
seritoolsmbilker
authored andcommitted
Remove dependency on GetModuleHandleW and CreateEventW
Just use the `A` variants instead (already imported anyways)
1 parent 37c42b9 commit c999188

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

library/std/src/sys/windows/c/windows_sys.lst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,7 +2451,6 @@ Windows.Win32.System.Kernel.FLOATING_SAVE_AREA
24512451
Windows.Win32.System.Kernel.OBJ_DONT_REPARSE
24522452
Windows.Win32.System.LibraryLoader.GetModuleFileNameW
24532453
Windows.Win32.System.LibraryLoader.GetModuleHandleA
2454-
Windows.Win32.System.LibraryLoader.GetModuleHandleW
24552454
Windows.Win32.System.LibraryLoader.GetProcAddress
24562455
Windows.Win32.System.Performance.QueryPerformanceCounter
24572456
Windows.Win32.System.Performance.QueryPerformanceFrequency
@@ -2494,7 +2493,7 @@ Windows.Win32.System.Threading.CREATE_SEPARATE_WOW_VDM
24942493
Windows.Win32.System.Threading.CREATE_SHARED_WOW_VDM
24952494
Windows.Win32.System.Threading.CREATE_SUSPENDED
24962495
Windows.Win32.System.Threading.CREATE_UNICODE_ENVIRONMENT
2497-
Windows.Win32.System.Threading.CreateEventW
2496+
Windows.Win32.System.Threading.CreateEventA
24982497
Windows.Win32.System.Threading.CreateProcessW
24992498
Windows.Win32.System.Threading.CreateThread
25002499
Windows.Win32.System.Threading.DEBUG_ONLY_THIS_PROCESS

library/std/src/sys/windows/c/windows_sys.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ extern "system" {
4545
}
4646
#[link(name = "kernel32")]
4747
extern "system" {
48-
pub fn CreateEventW(
48+
pub fn CreateEventA(
4949
lpeventattributes: *const SECURITY_ATTRIBUTES,
5050
bmanualreset: BOOL,
5151
binitialstate: BOOL,
52-
lpname: PCWSTR,
52+
lpname: PCSTR,
5353
) -> HANDLE;
5454
}
5555
#[link(name = "kernel32")]
@@ -247,11 +247,7 @@ extern "system" {
247247
#[link(name = "kernel32")]
248248
extern "system" {
249249
pub fn GetModuleHandleA(lpmodulename: PCSTR) -> HMODULE;
250-
}
251-
#[link(name = "kernel32")]
252-
extern "system" {
253-
pub fn GetModuleHandleW(lpmodulename: PCWSTR) -> HMODULE;
254-
}
250+
255251
#[link(name = "kernel32")]
256252
extern "system" {
257253
pub fn GetOverlappedResult(

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

Lines changed: 1 addition & 1 deletion
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/windows/os.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ pub fn error_string(mut errnum: i32) -> String {
4040
// `[MS-ERREF]`: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a
4141
if (errnum & c::FACILITY_NT_BIT as i32) != 0 {
4242
// format according to https://support.microsoft.com/en-us/help/259693
43-
const NTDLL_DLL: &[u16] = &[
44-
'N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _, '.' as _, 'D' as _, 'L' as _,
45-
'L' as _, 0,
46-
];
47-
module = c::GetModuleHandleW(NTDLL_DLL.as_ptr());
43+
module = c::GetModuleHandleA(b"NTDLL.DLL\0".as_ptr() as *const i8);
4844

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

0 commit comments

Comments
 (0)