Skip to content

Commit 21a314a

Browse files
BiTOkBiTOk
authored andcommitted
Allow target application to handle continuable exception
1 parent 2bc8c45 commit 21a314a

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

winafl.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,23 @@ dump_winafl_data()
209209

210210
static bool
211211
onexception(void *drcontext, dr_exception_t *excpt) {
212-
DWORD exception_code = excpt->record->ExceptionCode;
212+
EXCEPTION_RECORD *ex_rec = excpt->record;
213+
DWORD exception_code = ex_rec->ExceptionCode;
214+
DWORD exception_flags = ex_rec->ExceptionFlags;
215+
PVOID exception_address = ex_rec->ExceptionAddress;
213216

214217
if(options.debug_mode)
215-
dr_fprintf(winafl_data.log, "Exception caught: %x\n", exception_code);
216-
217-
if((exception_code == EXCEPTION_ACCESS_VIOLATION) ||
218-
(exception_code == EXCEPTION_ILLEGAL_INSTRUCTION) ||
219-
(exception_code == EXCEPTION_PRIV_INSTRUCTION) ||
220-
(exception_code == EXCEPTION_INT_DIVIDE_BY_ZERO) ||
221-
(exception_code == STATUS_HEAP_CORRUPTION) ||
222-
(exception_code == EXCEPTION_STACK_OVERFLOW) ||
223-
(exception_code == STATUS_STACK_BUFFER_OVERRUN) ||
224-
(exception_code == STATUS_FATAL_APP_EXIT)) {
218+
dr_fprintf(winafl_data.log, "Exception caught. Code: %x, address: %x\n", exception_code, exception_address);
219+
220+
if(exception_flags & EXCEPTION_NONCONTINUABLE &&
221+
((exception_code == EXCEPTION_ACCESS_VIOLATION) ||
222+
(exception_code == EXCEPTION_ILLEGAL_INSTRUCTION) ||
223+
(exception_code == EXCEPTION_PRIV_INSTRUCTION) ||
224+
(exception_code == EXCEPTION_INT_DIVIDE_BY_ZERO) ||
225+
(exception_code == STATUS_HEAP_CORRUPTION) ||
226+
(exception_code == EXCEPTION_STACK_OVERFLOW) ||
227+
(exception_code == STATUS_STACK_BUFFER_OVERRUN) ||
228+
(exception_code == STATUS_FATAL_APP_EXIT))) {
225229
if(options.debug_mode) {
226230
dr_fprintf(winafl_data.log, "crashed\n");
227231
} else {

0 commit comments

Comments
 (0)