From d85acadff2aa93d4ea2fe3414766b8b0a51de63a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sun, 12 Apr 2026 14:47:00 +0200 Subject: [PATCH] Swap `WaitForSingleObjectEx` with `WaitForSingleObject` and check result --- bindings.txt | 2 +- src/dbghelp.rs | 5 +++-- src/windows_sys.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bindings.txt b/bindings.txt index 166224b9..54bb4582 100644 --- a/bindings.txt +++ b/bindings.txt @@ -60,4 +60,4 @@ Windows.Win32.System.Threading.GetCurrentProcessId Windows.Win32.System.Threading.GetCurrentThread Windows.Win32.System.Threading.INFINITE Windows.Win32.System.Threading.ReleaseMutex -Windows.Win32.System.Threading.WaitForSingleObjectEx \ No newline at end of file +Windows.Win32.System.Threading.WaitForSingleObject \ No newline at end of file diff --git a/src/dbghelp.rs b/src/dbghelp.rs index c3bec8d1..3083af29 100644 --- a/src/dbghelp.rs +++ b/src/dbghelp.rs @@ -291,8 +291,9 @@ pub fn init() -> Result { } } debug_assert!(!lock.is_null()); - let r = WaitForSingleObjectEx(lock, INFINITE, FALSE); - debug_assert_eq!(r, 0); + if WaitForSingleObject(lock, INFINITE) != 0 { + return Err(()); + } let ret = Init { lock }; // Ok, phew! Now that we're all safely synchronized, let's actually diff --git a/src/windows_sys.rs b/src/windows_sys.rs index ddd5393c..08e885f4 100644 --- a/src/windows_sys.rs +++ b/src/windows_sys.rs @@ -46,7 +46,7 @@ windows_link::link!("kernel32.dll" "system" fn RtlVirtualUnwind(handlertype : RT #[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] windows_link::link!("kernel32.dll" "system" fn RtlVirtualUnwind(handlertype : RTL_VIRTUAL_UNWIND_HANDLER_TYPE, imagebase : u64, controlpc : u64, functionentry : *const IMAGE_RUNTIME_FUNCTION_ENTRY, contextrecord : *mut CONTEXT, handlerdata : *mut *mut core::ffi::c_void, establisherframe : *mut u64, contextpointers : *mut KNONVOLATILE_CONTEXT_POINTERS) -> EXCEPTION_ROUTINE); windows_link::link!("kernel32.dll" "system" fn UnmapViewOfFile(lpbaseaddress : MEMORY_MAPPED_VIEW_ADDRESS) -> BOOL); -windows_link::link!("kernel32.dll" "system" fn WaitForSingleObjectEx(hhandle : HANDLE, dwmilliseconds : u32, balertable : BOOL) -> WAIT_EVENT); +windows_link::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT); windows_link::link!("kernel32.dll" "system" fn WideCharToMultiByte(codepage : u32, dwflags : u32, lpwidecharstr : PCWSTR, cchwidechar : i32, lpmultibytestr : PSTR, cbmultibyte : i32, lpdefaultchar : PCSTR, lpuseddefaultchar : *mut BOOL) -> i32); windows_link::link!("kernel32.dll" "system" fn lstrlenW(lpstring : PCWSTR) -> i32); #[repr(C)]