From 99b615ba75f24e48b713e9b23ae596d7ddf1c59b Mon Sep 17 00:00:00 2001 From: cnlohr Date: Tue, 14 Mar 2017 21:25:53 -0400 Subject: Handle autoregistration of startup functions. --- src/survive.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/survive.c b/src/survive.c index d786d3d..0e567ad 100755 --- a/src/survive.c +++ b/src/survive.c @@ -9,6 +9,23 @@ #include "survive_config.h" +#ifdef RUNTIME_SYMNUM +#include +static int did_runtime_symnum; +int SymnumCheck( const char * path, const char * name, void * location, long size ) +{ + printf( "--->%s\n", name ); + if( strncmp( name, "REGISTER", 8 ) == 0 ) + { + typedef void (*sf)(); + sf fn = (sf)location; + fn(); + } + return 0; +} + +#endif + static void survivefault( struct SurviveContext * ctx, const char * fault ) { fprintf( stderr, "Error: %s\n", fault ); @@ -23,6 +40,10 @@ static void survivenote( struct SurviveContext * ctx, const char * fault ) SurviveContext * survive_init( int headless ) { +#ifdef RUNTIME_SYMNUM + EnumerateSymbols( SymnumCheck ); +#endif + int r = 0; int i = 0; SurviveContext * ctx = calloc( 1, sizeof( SurviveContext ) ); @@ -266,4 +287,4 @@ int survive_simple_inflate( struct SurviveContext * ctx, const char * input, int return len; } -#endif \ No newline at end of file +#endif -- cgit v1.2.3