|
|
dd89bb |
#ifndef _NT_EXCEPTION_H_
|
|
|
dd89bb |
#define _NT_EXCEPTION_H_
|
|
|
dd89bb |
|
|
|
414ad3 |
#include "nt_abi.h"
|
|
|
dd89bb |
#include "nt_object.h"
|
|
|
dd89bb |
#include "nt_thread.h"
|
|
|
dd89bb |
|
|
|
fb30a9 |
/* exception limits */
|
|
|
dd89bb |
#define NT_EXCEPTION_MAX_PARAMS (0x0F)
|
|
|
dd89bb |
|
|
|
fb30a9 |
/* exception flags */
|
|
|
fb30a9 |
#define NT_EXCEPTION_FLAG_NONCONTINUABLE (1 << 0)
|
|
|
fb30a9 |
#define NT_EXCEPTION_FLAG_UNWINDING (1 << 1)
|
|
|
fb30a9 |
#define NT_EXCEPTION_FLAG_EXIT_UNWIND (1 << 2)
|
|
|
fb30a9 |
#define NT_EXCEPTION_FLAG_STACK_INVALID (1 << 3)
|
|
|
fb30a9 |
#define NT_EXCEPTION_FLAG_NESTED_CALL (1 << 4)
|
|
|
fb30a9 |
#define NT_EXCEPTION_FLAG_TARGET_UNWIND (1 << 5)
|
|
|
fb30a9 |
#define NT_EXCEPTION_FLAG_COLLIDED_UNWIND (1 << 6)
|
|
|
fb30a9 |
#define NT_EXCEPTION_FLAG_UNWIND ( NT_EXCEPTION_UNWINDING \
|
|
|
fb30a9 |
|| NT_EXCEPTION_EXIT_UNWIND \
|
|
|
fb30a9 |
|| NT_EXCEPTION_TARGET_UNWIND \
|
|
|
fb30a9 |
|| NT_EXCEPTION_COLLIDED_UNWIND )
|
|
|
fb30a9 |
|
|
|
fb30a9 |
/* exception definitions */
|
|
|
fb30a9 |
typedef struct _nt_exception_record nt_exception_record;
|
|
|
fb30a9 |
typedef struct _nt_dispatcher_context nt_dispatcher_context;
|
|
|
fb30a9 |
typedef struct _nt_unwind_history_table nt_unwind_history_table;
|
|
|
fb30a9 |
|
|
|
08ce77 |
typedef enum _nt_exception_disposition {
|
|
|
08ce77 |
NT_EXCEPTION_CONTINUE_EXECUTION,
|
|
|
08ce77 |
NT_EXCEPTION_CONTINUE_SEARCH,
|
|
|
08ce77 |
NT_EXCEPTION_NESTED_EXCEPTION,
|
|
|
08ce77 |
NT_EXCEPTION_COLLIDED_UNWIND
|
|
|
08ce77 |
} nt_exception_disposition;
|
|
|
08ce77 |
|
|
|
dd89bb |
typedef struct _nt_exception_record {
|
|
|
dd89bb |
uint32_t exception_code;
|
|
|
dd89bb |
uint32_t exception_flags;
|
|
|
dd89bb |
struct _nt_exception_record * exception_record;
|
|
|
dd89bb |
void * exception_address;
|
|
|
dd89bb |
uint32_t number_of_params;
|
|
|
dd89bb |
uintptr_t exception_information[NT_EXCEPTION_MAX_PARAMS];
|
|
|
dd89bb |
} nt_exception_record;
|
|
|
dd89bb |
|
|
|
fb30a9 |
typedef struct _nt_runtime_function {
|
|
|
fb30a9 |
uint32_t raddr_fn_start;
|
|
|
fb30a9 |
uint32_t raddr_fn_end;
|
|
|
fb30a9 |
uint32_t raddr_uw_info;
|
|
|
fb30a9 |
} nt_runtime_function;
|
|
|
fb30a9 |
|
|
|
fb30a9 |
typedef nt_exception_disposition (*nt_exception_routine)(
|
|
|
fb30a9 |
nt_exception_record *,
|
|
|
fb30a9 |
uintptr_t,
|
|
|
fb30a9 |
nt_thread_context *,
|
|
|
fb30a9 |
nt_dispatcher_context *);
|
|
|
fb30a9 |
|
|
|
fb30a9 |
typedef struct _nt_dispatcher_context {
|
|
|
fb30a9 |
uintptr_t control_pc;
|
|
|
fb30a9 |
uintptr_t image_base;
|
|
|
fb30a9 |
nt_runtime_function * fn_entry;
|
|
|
fb30a9 |
uintptr_t establisher_frame;
|
|
|
fb30a9 |
uintptr_t target_ip;
|
|
|
fb30a9 |
nt_thread_context * tctx;
|
|
|
fb30a9 |
nt_exception_routine language_handler;
|
|
|
fb30a9 |
void * handler_data;
|
|
|
fb30a9 |
nt_unwind_history_table * history_table;
|
|
|
fb30a9 |
uint32_t scope_index;
|
|
|
fb30a9 |
uint32_t __pad;
|
|
|
fb30a9 |
} nt_dispatcher_context;
|
|
|
fb30a9 |
|
|
|
fb30a9 |
/* exception interfaces */
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_zw_raise_exception(
|
|
|
dd89bb |
__in nt_exception_record * exception_record,
|
|
|
dd89bb |
__in nt_thread_context * context,
|
|
|
dd89bb |
__in unsigned char search_frames);
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_zw_continue(
|
|
|
dd89bb |
__in nt_thread_context * context,
|
|
|
dd89bb |
__in unsigned char test_alert);
|
|
|
dd89bb |
|
|
|
dd89bb |
#endif
|