File tree Expand file tree Collapse file tree 4 files changed +20
-13
lines changed
library/std/src/sys/windows Expand file tree Collapse file tree 4 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -319,12 +319,27 @@ pub unsafe fn NtWriteFile(
319
319
compat_fn_with_fallback ! {
320
320
pub static KERNEL32 : & CStr = ansi_str!( "kernel32" ) ;
321
321
322
+ // >= XP
323
+ // https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-addvectoredexceptionhandler
324
+ pub fn AddVectoredExceptionHandler (
325
+ FirstHandler : ULONG ,
326
+ VectoredHandler : PVECTORED_EXCEPTION_HANDLER ,
327
+ ) -> LPVOID {
328
+ panic!( "unavailable" )
329
+ }
330
+
322
331
// >= Win10 1607
323
332
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
324
333
pub fn SetThreadDescription ( hthread: HANDLE , lpthreaddescription: PCWSTR ) -> HRESULT {
325
334
SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as DWORD ) ; E_NOTIMPL
326
335
}
327
336
337
+ // >= Vista / Server 2003
338
+ // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadstackguarantee
339
+ pub fn SetThreadStackGuarantee ( _size: * mut c_ulong) -> BOOL {
340
+ SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as DWORD ) ; 0
341
+ }
342
+
328
343
// >= Win8 / Server 2012
329
344
// https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
330
345
pub fn GetSystemTimePreciseAsFileTime ( lpsystemtimeasfiletime: * mut FILETIME ) -> ( ) {
Original file line number Diff line number Diff line change @@ -2418,7 +2418,6 @@ Windows.Win32.System.Console.STD_HANDLE
2418
2418
Windows.Win32.System.Console.STD_INPUT_HANDLE
2419
2419
Windows.Win32.System.Console.STD_OUTPUT_HANDLE
2420
2420
Windows.Win32.System.Console.WriteConsoleW
2421
- Windows.Win32.System.Diagnostics.Debug.AddVectoredExceptionHandler
2422
2421
Windows.Win32.System.Diagnostics.Debug.ARM64_NT_NEON128
2423
2422
Windows.Win32.System.Diagnostics.Debug.CONTEXT
2424
2423
Windows.Win32.System.Diagnostics.Debug.CONTEXT
@@ -2545,7 +2544,6 @@ Windows.Win32.System.Threading.ReleaseSRWLockShared
2545
2544
Windows.Win32.System.Threading.RTL_CONDITION_VARIABLE
2546
2545
Windows.Win32.System.Threading.RTL_RUN_ONCE
2547
2546
Windows.Win32.System.Threading.RTL_SRWLOCK
2548
- Windows.Win32.System.Threading.SetThreadStackGuarantee
2549
2547
Windows.Win32.System.Threading.Sleep
2550
2548
Windows.Win32.System.Threading.SleepConditionVariableSRW
2551
2549
Windows.Win32.System.Threading.SleepEx
Original file line number Diff line number Diff line change @@ -39,13 +39,6 @@ extern "system" {
39
39
pub fn AcquireSRWLockShared ( srwlock : * mut RTL_SRWLOCK ) -> ( ) ;
40
40
}
41
41
#[ link( name = "kernel32" ) ]
42
- extern "system" {
43
- pub fn AddVectoredExceptionHandler (
44
- first : u32 ,
45
- handler : PVECTORED_EXCEPTION_HANDLER ,
46
- ) -> * mut :: core:: ffi:: c_void ;
47
- }
48
- #[ link( name = "kernel32" ) ]
49
42
extern "system" {
50
43
pub fn CancelIo ( hfile : HANDLE ) -> BOOL ;
51
44
}
@@ -497,10 +490,6 @@ extern "system" {
497
490
pub fn SetLastError ( dwerrcode : WIN32_ERROR ) -> ( ) ;
498
491
}
499
492
#[ link( name = "kernel32" ) ]
500
- extern "system" {
501
- pub fn SetThreadStackGuarantee ( stacksizeinbytes : * mut u32 ) -> BOOL ;
502
- }
503
- #[ link( name = "kernel32" ) ]
504
493
extern "system" {
505
494
pub fn Sleep ( dwmilliseconds : u32 ) -> ( ) ;
506
495
}
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ unsafe extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POIN
34
34
}
35
35
36
36
pub unsafe fn init ( ) {
37
+ // This API was added in XP
38
+ if !c:: AddVectoredExceptionHandler :: available ( ) {
39
+ return ;
40
+ }
41
+
37
42
if c:: AddVectoredExceptionHandler ( 0 , Some ( vectored_handler) ) . is_null ( ) {
38
43
panic ! ( "failed to install exception handler" ) ;
39
44
}
You can’t perform that action at this time.
0 commit comments