Rizin
unix-like reverse engineering framework and cli tools
common_windows.c File Reference
#include "common_windows.h"

Go to the source code of this file.

Macros

#define EXCEPTION_ACCESS_VIOLATION   0xC0000005
 
#define EXCEPTION_DATATYPE_MISALIGNMENT   0x80000002
 
#define EXCEPTION_BREAKPOINT   0x80000003
 
#define EXCEPTION_SINGLE_STEP   0x80000004
 
#define EXCEPTION_ARRAY_BOUNDS_EXCEEDED   0xC000008C
 
#define EXCEPTION_FLT_DENORMAL_OPERAND   0xC000008D
 
#define EXCEPTION_FLT_DIVIDE_BY_ZERO   0xC000008E
 
#define EXCEPTION_FLT_INEXACT_RESULT   0xC000008F
 
#define EXCEPTION_FLT_INVALID_OPERATION   0xC0000090
 
#define EXCEPTION_FLT_OVERFLOW   0xC0000091
 
#define EXCEPTION_FLT_STACK_CHECK   0xC0000092
 
#define EXCEPTION_FLT_UNDERFLOW   0xC0000093
 
#define EXCEPTION_INT_DIVIDE_BY_ZERO   0xC0000094
 
#define EXCEPTION_INT_OVERFLOW   0xC0000095
 
#define EXCEPTION_PRIV_INSTRUCTION   0xC0000096
 
#define EXCEPTION_IN_PAGE_ERROR   0xC0000006
 
#define EXCEPTION_ILLEGAL_INSTRUCTION   0xC000001D
 
#define EXCEPTION_NONCONTINUABLE_EXCEPTION   0xC0000025
 
#define EXCEPTION_STACK_OVERFLOW   0xC00000FD
 
#define EXCEPTION_INVALID_DISPOSITION   0xC0000026
 
#define EXCEPTION_GUARD_PAGE   0x80000001
 
#define EXCEPTION_INVALID_HANDLE   0xC0000008
 
#define EXCEPTION_POSSIBLE_DEADLOCK   0xC0000194
 
#define CONTROL_C_EXIT   0x40010005
 
#define DBG_CONTROL_BREAK   0x40010008
 
#define STATUS_UNWIND_CONSOLIDATE   0x80000029
 
#define EXCEPTION_STR(x)    case x: return #x
 

Functions

RzDebugReasonType windows_exception_to_reason (ut32 exception_code)
 
static const char * get_exception_name (ut32 ExceptionCode)
 
bool windows_is_exception_fatal (ut32 exception_code)
 
void windows_print_exception_event (ut32 pid, ut32 tid, ut32 exception_code, bool second_chance)
 

Macro Definition Documentation

◆ CONTROL_C_EXIT

#define CONTROL_C_EXIT   0x40010005

Definition at line 29 of file common_windows.c.

◆ DBG_CONTROL_BREAK

#define DBG_CONTROL_BREAK   0x40010008

Definition at line 30 of file common_windows.c.

◆ EXCEPTION_ACCESS_VIOLATION

#define EXCEPTION_ACCESS_VIOLATION   0xC0000005

Definition at line 6 of file common_windows.c.

◆ EXCEPTION_ARRAY_BOUNDS_EXCEEDED

#define EXCEPTION_ARRAY_BOUNDS_EXCEEDED   0xC000008C

Definition at line 10 of file common_windows.c.

◆ EXCEPTION_BREAKPOINT

#define EXCEPTION_BREAKPOINT   0x80000003

Definition at line 8 of file common_windows.c.

◆ EXCEPTION_DATATYPE_MISALIGNMENT

#define EXCEPTION_DATATYPE_MISALIGNMENT   0x80000002

Definition at line 7 of file common_windows.c.

◆ EXCEPTION_FLT_DENORMAL_OPERAND

#define EXCEPTION_FLT_DENORMAL_OPERAND   0xC000008D

Definition at line 11 of file common_windows.c.

◆ EXCEPTION_FLT_DIVIDE_BY_ZERO

#define EXCEPTION_FLT_DIVIDE_BY_ZERO   0xC000008E

Definition at line 12 of file common_windows.c.

◆ EXCEPTION_FLT_INEXACT_RESULT

#define EXCEPTION_FLT_INEXACT_RESULT   0xC000008F

Definition at line 13 of file common_windows.c.

◆ EXCEPTION_FLT_INVALID_OPERATION

#define EXCEPTION_FLT_INVALID_OPERATION   0xC0000090

Definition at line 14 of file common_windows.c.

◆ EXCEPTION_FLT_OVERFLOW

#define EXCEPTION_FLT_OVERFLOW   0xC0000091

Definition at line 15 of file common_windows.c.

◆ EXCEPTION_FLT_STACK_CHECK

#define EXCEPTION_FLT_STACK_CHECK   0xC0000092

Definition at line 16 of file common_windows.c.

◆ EXCEPTION_FLT_UNDERFLOW

#define EXCEPTION_FLT_UNDERFLOW   0xC0000093

Definition at line 17 of file common_windows.c.

◆ EXCEPTION_GUARD_PAGE

#define EXCEPTION_GUARD_PAGE   0x80000001

Definition at line 26 of file common_windows.c.

◆ EXCEPTION_ILLEGAL_INSTRUCTION

#define EXCEPTION_ILLEGAL_INSTRUCTION   0xC000001D

Definition at line 22 of file common_windows.c.

◆ EXCEPTION_IN_PAGE_ERROR

#define EXCEPTION_IN_PAGE_ERROR   0xC0000006

Definition at line 21 of file common_windows.c.

◆ EXCEPTION_INT_DIVIDE_BY_ZERO

#define EXCEPTION_INT_DIVIDE_BY_ZERO   0xC0000094

Definition at line 18 of file common_windows.c.

◆ EXCEPTION_INT_OVERFLOW

#define EXCEPTION_INT_OVERFLOW   0xC0000095

Definition at line 19 of file common_windows.c.

◆ EXCEPTION_INVALID_DISPOSITION

#define EXCEPTION_INVALID_DISPOSITION   0xC0000026

Definition at line 25 of file common_windows.c.

◆ EXCEPTION_INVALID_HANDLE

#define EXCEPTION_INVALID_HANDLE   0xC0000008

Definition at line 27 of file common_windows.c.

◆ EXCEPTION_NONCONTINUABLE_EXCEPTION

#define EXCEPTION_NONCONTINUABLE_EXCEPTION   0xC0000025

Definition at line 23 of file common_windows.c.

◆ EXCEPTION_POSSIBLE_DEADLOCK

#define EXCEPTION_POSSIBLE_DEADLOCK   0xC0000194

Definition at line 28 of file common_windows.c.

◆ EXCEPTION_PRIV_INSTRUCTION

#define EXCEPTION_PRIV_INSTRUCTION   0xC0000096

Definition at line 20 of file common_windows.c.

◆ EXCEPTION_SINGLE_STEP

#define EXCEPTION_SINGLE_STEP   0x80000004

Definition at line 9 of file common_windows.c.

◆ EXCEPTION_STACK_OVERFLOW

#define EXCEPTION_STACK_OVERFLOW   0xC00000FD

Definition at line 24 of file common_windows.c.

◆ EXCEPTION_STR

#define EXCEPTION_STR (   x)     case x: return #x

◆ STATUS_UNWIND_CONSOLIDATE

#define STATUS_UNWIND_CONSOLIDATE   0x80000029

Definition at line 31 of file common_windows.c.

Function Documentation

◆ get_exception_name()

static const char* get_exception_name ( ut32  ExceptionCode)
static

Definition at line 59 of file common_windows.c.

59  {
60 #define EXCEPTION_STR(x) \
61  case x: return #x
62  switch (ExceptionCode) {
89  case 0x6BA: return "FILE_DIALOG_EXCEPTION";
90  case 0x406D1388: return "MS_VC_EXCEPTION";
91  default:
92  return "Unknown";
93  }
94 #undef EXCEPTION_STR
95 }
#define EXCEPTION_SINGLE_STEP
Definition: common_windows.c:9
#define EXCEPTION_NONCONTINUABLE_EXCEPTION
#define EXCEPTION_GUARD_PAGE
#define EXCEPTION_FLT_STACK_CHECK
#define EXCEPTION_STACK_OVERFLOW
#define EXCEPTION_POSSIBLE_DEADLOCK
#define CONTROL_C_EXIT
#define EXCEPTION_INT_DIVIDE_BY_ZERO
#define EXCEPTION_IN_PAGE_ERROR
#define EXCEPTION_FLT_UNDERFLOW
#define EXCEPTION_INT_OVERFLOW
#define EXCEPTION_INVALID_HANDLE
#define STATUS_UNWIND_CONSOLIDATE
#define DBG_CONTROL_BREAK
#define EXCEPTION_INVALID_DISPOSITION
#define EXCEPTION_FLT_OVERFLOW
#define EXCEPTION_ARRAY_BOUNDS_EXCEEDED
#define EXCEPTION_DATATYPE_MISALIGNMENT
Definition: common_windows.c:7
#define EXCEPTION_FLT_DENORMAL_OPERAND
#define EXCEPTION_FLT_INEXACT_RESULT
#define EXCEPTION_ILLEGAL_INSTRUCTION
#define EXCEPTION_ACCESS_VIOLATION
Definition: common_windows.c:6
#define EXCEPTION_BREAKPOINT
Definition: common_windows.c:8
#define EXCEPTION_FLT_INVALID_OPERATION
#define EXCEPTION_STR(x)
#define EXCEPTION_PRIV_INSTRUCTION
#define EXCEPTION_FLT_DIVIDE_BY_ZERO

References CONTROL_C_EXIT, DBG_CONTROL_BREAK, EXCEPTION_ACCESS_VIOLATION, EXCEPTION_ARRAY_BOUNDS_EXCEEDED, EXCEPTION_BREAKPOINT, EXCEPTION_DATATYPE_MISALIGNMENT, EXCEPTION_FLT_DENORMAL_OPERAND, EXCEPTION_FLT_DIVIDE_BY_ZERO, EXCEPTION_FLT_INEXACT_RESULT, EXCEPTION_FLT_INVALID_OPERATION, EXCEPTION_FLT_OVERFLOW, EXCEPTION_FLT_STACK_CHECK, EXCEPTION_FLT_UNDERFLOW, EXCEPTION_GUARD_PAGE, EXCEPTION_ILLEGAL_INSTRUCTION, EXCEPTION_IN_PAGE_ERROR, EXCEPTION_INT_DIVIDE_BY_ZERO, EXCEPTION_INT_OVERFLOW, EXCEPTION_INVALID_DISPOSITION, EXCEPTION_INVALID_HANDLE, EXCEPTION_NONCONTINUABLE_EXCEPTION, EXCEPTION_POSSIBLE_DEADLOCK, EXCEPTION_PRIV_INSTRUCTION, EXCEPTION_SINGLE_STEP, EXCEPTION_STACK_OVERFLOW, EXCEPTION_STR, and STATUS_UNWIND_CONSOLIDATE.

Referenced by windows_print_exception_event().

◆ windows_exception_to_reason()

RzDebugReasonType windows_exception_to_reason ( ut32  exception_code)

Definition at line 33 of file common_windows.c.

33  {
34  switch (exception_code) {
47  return RZ_DEBUG_REASON_FPU;
53  return RZ_DEBUG_REASON_STEP;
54  default:
55  return RZ_DEBUG_REASON_TRAP;
56  }
57 }
@ RZ_DEBUG_REASON_STEP
Definition: rz_debug.h:98
@ RZ_DEBUG_REASON_ILLEGAL
Definition: rz_debug.h:102
@ RZ_DEBUG_REASON_BREAKPOINT
Definition: rz_debug.h:94
@ RZ_DEBUG_REASON_TRAP
Definition: rz_debug.h:111
@ RZ_DEBUG_REASON_FPU
Definition: rz_debug.h:114
@ RZ_DEBUG_REASON_SEGFAULT
Definition: rz_debug.h:93
@ RZ_DEBUG_REASON_DIVBYZERO
Definition: rz_debug.h:101

References EXCEPTION_ACCESS_VIOLATION, EXCEPTION_BREAKPOINT, EXCEPTION_FLT_DENORMAL_OPERAND, EXCEPTION_FLT_DIVIDE_BY_ZERO, EXCEPTION_FLT_INEXACT_RESULT, EXCEPTION_FLT_INVALID_OPERATION, EXCEPTION_FLT_OVERFLOW, EXCEPTION_FLT_STACK_CHECK, EXCEPTION_FLT_UNDERFLOW, EXCEPTION_GUARD_PAGE, EXCEPTION_ILLEGAL_INSTRUCTION, EXCEPTION_INT_DIVIDE_BY_ZERO, EXCEPTION_SINGLE_STEP, RZ_DEBUG_REASON_BREAKPOINT, RZ_DEBUG_REASON_DIVBYZERO, RZ_DEBUG_REASON_FPU, RZ_DEBUG_REASON_ILLEGAL, RZ_DEBUG_REASON_SEGFAULT, RZ_DEBUG_REASON_STEP, and RZ_DEBUG_REASON_TRAP.

Referenced by rz_debug_winkd_wait(), and w32_dbg_wait().

◆ windows_is_exception_fatal()

◆ windows_print_exception_event()

void windows_print_exception_event ( ut32  pid,
ut32  tid,
ut32  exception_code,
bool  second_chance 
)

Definition at line 115 of file common_windows.c.

115  {
116  bool is_fatal = windows_is_exception_fatal(exception_code);
117  RZ_LOG_INFO("(%" PFMT32u ") %s Exception %04X (%s) in thread %" PFMT32u "\n",
118  pid,
119  is_fatal ? "Fatal" : "Non-fatal",
120  exception_code, get_exception_name(exception_code),
121  tid);
122  if (second_chance) {
123  RZ_LOG_WARN("A second-chance exception has ocurred!\n");
124  }
125  if (is_fatal) {
126  RZ_LOG_INFO("Use 'dce' continue into exception handler\n");
127  }
128 }
static const char * get_exception_name(ut32 ExceptionCode)
bool windows_is_exception_fatal(ut32 exception_code)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
Definition: sflib.h:64
#define RZ_LOG_INFO(fmtstr,...)
Definition: rz_log.h:54
#define RZ_LOG_WARN(fmtstr,...)
Definition: rz_log.h:56
#define PFMT32u
Definition: rz_types.h:409

References get_exception_name(), PFMT32u, pid, RZ_LOG_INFO, RZ_LOG_WARN, and windows_is_exception_fatal().

Referenced by rz_debug_winkd_wait(), and w32_dbg_wait().