Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * this define is important
- * do not delete it or gcc will complain that RTLD_NEXT is undefined
- * http://stackoverflow.com/questions/1777397/rtld-next-undeclared
- */
- #define _GNU_SOURCE
- #include <stdio.h>
- #include <dlfcn.h>
- #include <stdlib.h>
- #include <stdarg.h>
- int printf(const char *format, ...)
- {
- va_list list;
- char *parg;
- /* function pointer for original printf */
- typeof(printf) *old_printf;
- /* get the parameters */
- va_start(list, format);
- vasprintf(&parg, format, list);
- va_end(list);
- /* what the log function should be */
- puts("hooked printf success\n");
- /* call the original printf */
- old_printf = dlsym(RTLD_NEXT, "printf");
- (*old_printf)("%s", parg);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement