wz_mini_hacks/libcallback_wz_mod/freopen.c

19 lines
460 B
C
Raw Normal View History

2022-05-07 08:23:49 +00:00
#include <stdio.h>
#include <dlfcn.h>
#include <string.h>
static FILE * (*original_freopen)(const char *pathname, const char *mode, FILE *stream);
static void __attribute ((constructor)) freopen_hook_init(void) {
original_freopen = dlsym(dlopen ("/lib/libc.so.0", RTLD_LAZY), "freopen");
}
FILE *freopen(const char *pathname, const char *mode, FILE *stream) {
if(stream == stdout) return stdout;
return original_freopen(pathname, mode, stream);
}