-
-
Save 0xc010d/4265781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <dlfcn.h> | |
#include <execinfo.h> | |
typedef void (*cxa_throw_type)(void *, void *, void (*) (void *)); | |
cxa_throw_type orig_cxa_throw = 0; | |
void load_orig_throw_code() | |
{ | |
orig_cxa_throw = (cxa_throw_type) dlsym(RTLD_NEXT, "__cxa_throw"); | |
} | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
void __cxa_throw (void *thrown_exception, void *pvtinfo, void (*dest)(void *)) { | |
printf(" ################ DETECT A THROWN !!!!! #############\n"); | |
if (orig_cxa_throw == 0) | |
load_orig_throw_code(); | |
{ | |
static int throw_count = 0; | |
void *array[10]; | |
int size; | |
size = backtrace(array, 10); | |
fprintf(stderr, "#### EXCEPTION THROWN (#%d) ####\n", ++throw_count); | |
backtrace_symbols_fd(array, size, 2); // 2 == stderr | |
} | |
orig_cxa_throw(thrown_exception, pvtinfo, dest); | |
} | |
#ifdef __cplusplus | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment