/* * (C) 2009 Patrik Lembke * Licensed under GNU GPLv3 or newer as defined at * http://www.gnu.org/licenses/gpl.txt * * An example hack that reverses all that is sent to printf (sadly * with no regard to what it reverses, so it both places newline oddly * and breakes widechars). * * gcc -o ld_printf.so -fpic -shared ld_printf.c * LD_PRELOAD="$( pwd )/ld_printf.so" * export LD_PRELOAD */ #define _GNU_SOURCE #include #include #include int printf( const char* fmt, ... ) { char* buff; char temp; int ret, x; va_list ap; va_start( ap, fmt ); ret = vasprintf( &buff, fmt, ap ); va_end( ap ); /* flipp */ for( x = 0; x < ret / 2; x++ ) { temp = buff[(ret - x) -1]; buff[(ret - x) -1] = buff[x]; buff[x] = temp; } fprintf( stdout, buff ); free( buff ); return ret; }