Created
November 28, 2020 12:54
-
-
Save nrdmn/a405ac6f129542866ef1c21e19dfb5d0 to your computer and use it in GitHub Desktop.
LD_PRELOAD and varargs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <dlfcn.h> | |
#include <fcntl.h> | |
int fcntl(int fd, int cmd, ...) | |
{ | |
if (cmd == F_OFD_SETLKW || cmd == F_OFD_SETLK) { | |
return 0; | |
} | |
int (*orig)(int, int, ...) = dlsym(RTLD_NEXT, "fcntl"); | |
int *arg = __builtin_apply_args(); | |
void *ret = __builtin_apply((void *)orig, arg, 100); | |
__builtin_return(ret); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment