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