-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
691dc66
commit 733f810
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "common.h" | ||
#include "config.h" | ||
#include <dlfcn.h> | ||
#include <sys/types.h> | ||
#include "hooks.h" | ||
|
||
|
||
void *(*enhancer_real_dlopen)(const char *filename, int flag)=NULL; | ||
int (*enhancer_real_dlclose)(void *handle)=NULL; | ||
|
||
void *dlopen(const char *path, int flags) | ||
{ | ||
char *Redirect=NULL; | ||
int Flags; | ||
void *handle; | ||
|
||
if (! enhancer_real_dlclose) enhancer_get_real_functions(); | ||
|
||
Flags=enhancer_checkconfig_with_redirect(FUNC_DLOPEN, "dlopen", path, "", flags, 0, &Redirect); | ||
|
||
if (Flags & FLAG_DENY) | ||
{ | ||
destroy(Redirect); | ||
return(NULL); | ||
} | ||
|
||
handle=enhancer_real_dlopen(Redirect, flags); | ||
destroy(Redirect); | ||
|
||
return(handle); | ||
} | ||
|
||
|
||
|
||
|
||
int dlclose(void *handle) | ||
{ | ||
int Flags; | ||
|
||
if (! enhancer_real_dlclose) enhancer_get_real_functions(); | ||
|
||
Flags=enhancer_checkconfig_default(FUNC_DLCLOSE, "dlclose", "", "", 0, 0); | ||
if (Flags & FLAG_DENY) return(-1); | ||
if (Flags & FLAG_PRETEND) return(0); | ||
|
||
return(enhancer_real_dlclose(handle)); | ||
} | ||
|
||
|
||
|
||
|
||
void enhancer_dl_hooks() | ||
{ | ||
if (! enhancer_real_dlopen) enhancer_real_dlopen = dlsym(RTLD_NEXT, "dlopen"); | ||
if (! enhancer_real_dlclose) enhancer_real_dlclose = dlsym(RTLD_NEXT, "dlclose"); | ||
} |