1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
15 use libc::{c_long, c_ulong, c_void};
17 pub type DWORD = c_ulong;
18 pub type LONG = c_long;
19 pub type ULONG_PTR = usize;
20 pub type LPVOID = *mut c_void;
22 pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
23 pub const EXCEPTION_NONCONTINUABLE: DWORD = 0x1; // Noncontinuable exception
24 pub const EXCEPTION_UNWINDING: DWORD = 0x2; // Unwind is in progress
25 pub const EXCEPTION_EXIT_UNWIND: DWORD = 0x4; // Exit unwind is in progress
26 pub const EXCEPTION_TARGET_UNWIND: DWORD = 0x20; // Target unwind in progress
27 pub const EXCEPTION_COLLIDED_UNWIND: DWORD = 0x40; // Collided exception handler call
28 pub const EXCEPTION_UNWIND: DWORD = EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND |
29 EXCEPTION_TARGET_UNWIND |
30 EXCEPTION_COLLIDED_UNWIND;
33 pub struct EXCEPTION_RECORD {
34 pub ExceptionCode: DWORD,
35 pub ExceptionFlags: DWORD,
36 pub ExceptionRecord: *mut EXCEPTION_RECORD,
37 pub ExceptionAddress: LPVOID,
38 pub NumberParameters: DWORD,
39 pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS],
43 pub struct EXCEPTION_POINTERS {
44 pub ExceptionRecord: *mut EXCEPTION_RECORD,
45 pub ContextRecord: *mut CONTEXT,
48 pub enum UNWIND_HISTORY_TABLE {}
51 pub struct RUNTIME_FUNCTION {
52 pub BeginAddress: DWORD,
53 pub EndAddress: DWORD,
54 pub UnwindData: DWORD,
60 pub struct DISPATCHER_CONTEXT {
61 pub ControlPc: LPVOID,
62 pub ImageBase: LPVOID,
63 pub FunctionEntry: *const RUNTIME_FUNCTION,
64 pub EstablisherFrame: LPVOID,
66 pub ContextRecord: *const CONTEXT,
67 pub LanguageHandler: LPVOID,
68 pub HandlerData: *const u8,
69 pub HistoryTable: *const UNWIND_HISTORY_TABLE,
73 pub enum EXCEPTION_DISPOSITION {
74 ExceptionContinueExecution,
75 ExceptionContinueSearch,
76 ExceptionNestedException,
77 ExceptionCollidedUnwind,
79 pub use self::EXCEPTION_DISPOSITION::*;
83 pub fn RaiseException(dwExceptionCode: DWORD,
84 dwExceptionFlags: DWORD,
85 nNumberOfArguments: DWORD,
86 lpArguments: *const ULONG_PTR);
88 pub fn RtlUnwindEx(TargetFrame: LPVOID,
90 ExceptionRecord: *const EXCEPTION_RECORD,
92 OriginalContext: *const CONTEXT,
93 HistoryTable: *const UNWIND_HISTORY_TABLE);
95 pub fn _CxxThrowException(pExceptionObject: *mut c_void, pThrowInfo: *mut u8);