Skip to content

Instantly share code, notes, and snippets.

@thaylongs
Created August 7, 2017 00:46
Show Gist options
  • Save thaylongs/b522caed5f66d928501a16d756f88d60 to your computer and use it in GitHub Desktop.
Save thaylongs/b522caed5f66d928501a16d756f88d60 to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <dlfcn.h>
#define _FCNTL_H
#include <stdio.h>
#include <stdlib.h>
int (*_open)(const char *name, int flags, ...);
int (*_open64)(const char *name, int flags, ...);
void __attribute__ ((constructor)) setup(void) {
_open = (int (*)(const char * pathname, int flags,...)) dlsym(RTLD_NEXT, "open");
_open64 = (int (*)(const char * pathname, int flags,...)) dlsym(RTLD_NEXT, "open64");
}
int open(const char * pathname, int flags,int perms)
{
return _open(pathname, flags,perms);
}
int open64(const char * pathname, int flags, int perms)
{
return _open64(pathname, flags,perms);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment