| 1 |
// Licensed under the Apache License, Version 2.0 |
| 2 |
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 3 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. |
| 4 |
// All files in the project carrying such notice may not be copied, modified, or distributed |
| 5 |
// except according to those terms. |
| 6 |
//! ApiSet Contract for api-ms-win-core-errorhandling-l1 |
| 7 |
use shared::basetsd::ULONG_PTR; |
| 8 |
use shared::minwindef::{BOOL, DWORD, LPDWORD, UINT, ULONG}; |
| 9 |
use um::winnt::{ |
| 10 |
EXCEPTION_POINTERS, LONG, LPCSTR, LPCWSTR, PCONTEXT, PEXCEPTION_RECORD, |
| 11 |
PVECTORED_EXCEPTION_HANDLER, PVOID, |
| 12 |
}; |
| 13 |
FN!{stdcall PTOP_LEVEL_EXCEPTION_FILTER( |
| 14 |
ExceptionInfo: *mut EXCEPTION_POINTERS, |
| 15 |
) -> LONG} |
| 16 |
pub type LPTOP_LEVEL_EXCEPTION_FILTER = PTOP_LEVEL_EXCEPTION_FILTER; |
| 17 |
extern "system" { |
| 18 |
pub fn RaiseException( |
| 19 |
dwExceptionCode: DWORD, |
| 20 |
dwExceptionFlags: DWORD, |
| 21 |
nNumberOfArguments: DWORD, |
| 22 |
lpArguments: *const ULONG_PTR, |
| 23 |
); |
| 24 |
pub fn UnhandledExceptionFilter( |
| 25 |
ExceptionInfo: *mut EXCEPTION_POINTERS, |
| 26 |
) -> LONG; |
| 27 |
pub fn SetUnhandledExceptionFilter( |
| 28 |
lpTopLevelExceptionFilter: LPTOP_LEVEL_EXCEPTION_FILTER, |
| 29 |
) -> LPTOP_LEVEL_EXCEPTION_FILTER; |
| 30 |
pub fn GetLastError() -> DWORD; |
| 31 |
pub fn SetLastError( |
| 32 |
dwErrCode: DWORD, |
| 33 |
); |
| 34 |
pub fn GetErrorMode() -> UINT; |
| 35 |
pub fn SetErrorMode( |
| 36 |
uMode: UINT, |
| 37 |
) -> UINT; |
| 38 |
pub fn AddVectoredExceptionHandler( |
| 39 |
First: ULONG, |
| 40 |
Handler: PVECTORED_EXCEPTION_HANDLER, |
| 41 |
) -> PVOID; |
| 42 |
pub fn RemoveVectoredExceptionHandler( |
| 43 |
Handle: PVOID, |
| 44 |
) -> ULONG; |
| 45 |
pub fn AddVectoredContinueHandler( |
| 46 |
First: ULONG, |
| 47 |
Handler: PVECTORED_EXCEPTION_HANDLER, |
| 48 |
) -> PVOID; |
| 49 |
pub fn RemoveVectoredContinueHandler( |
| 50 |
Handle: PVOID, |
| 51 |
) -> ULONG; |
| 52 |
} |
| 53 |
// RestoreLastError |
| 54 |
extern "system" { |
| 55 |
pub fn RaiseFailFastException( |
| 56 |
pExceptionRecord: PEXCEPTION_RECORD, |
| 57 |
pContextRecord: PCONTEXT, |
| 58 |
dwFlags: DWORD, |
| 59 |
); |
| 60 |
pub fn FatalAppExitA( |
| 61 |
uAction: UINT, |
| 62 |
lpMessageText: LPCSTR, |
| 63 |
); |
| 64 |
pub fn FatalAppExitW( |
| 65 |
uAction: UINT, |
| 66 |
lpMessageText: LPCWSTR, |
| 67 |
); |
| 68 |
pub fn GetThreadErrorMode() -> DWORD; |
| 69 |
pub fn SetThreadErrorMode( |
| 70 |
dwNewMode: DWORD, |
| 71 |
lpOldMode: LPDWORD, |
| 72 |
) -> BOOL; |
| 73 |
} |
| 74 |
// What library provides this function? |
| 75 |
// TerminateProcessOnMemoryExhaustion |