main.c (460B)
1#include <dlfcn.h> 2 3#include <stdlib.h> 4#include <stdio.h> 5 6size_t 7fwrite(const void *src, size_t size, size_t count, FILE *file) 8{ 9 static size_t (*func)(const void *, size_t, size_t, FILE *) = NULL; 10 static void *libc = NULL; 11 size_t ret; 12 13 if (!libc) libc = dlopen("libc.so.6", RTLD_GLOBAL | RTLD_LAZY); 14 if (libc && !func) func = dlsym(libc, "fwrite"); 15 if (!libc || !func) exit(1); 16 17 ret = (*func)(src, size, count, file); 18 fflush(file); 19 20 return ret; 21} 22