2004-09-09 21:47:32 +00:00
|
|
|
/* by David "BAILOPAN" Anderson
|
|
|
|
* No warranties of any kind
|
|
|
|
* License: I hereby grant this work to the public domain and make no copyright claims.
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <dlfcn.h>
|
2007-03-21 20:24:01 +00:00
|
|
|
#include <limits.h>
|
2004-09-09 21:47:32 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
char *file=NULL;
|
|
|
|
void *dl= NULL;
|
|
|
|
FILE *fp = NULL;
|
2007-03-21 20:24:01 +00:00
|
|
|
char path[PATH_MAX];
|
2004-09-09 21:47:32 +00:00
|
|
|
if (argc != 2)
|
|
|
|
{
|
|
|
|
printf("Usage: dlsym <file>\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
file = argv[1];
|
2007-03-21 20:24:01 +00:00
|
|
|
realpath(file, path);
|
|
|
|
fp = fopen(path, "rb");
|
2004-09-09 21:47:32 +00:00
|
|
|
if (!fp)
|
|
|
|
{
|
2007-03-21 20:24:01 +00:00
|
|
|
printf("File not found.\n");
|
2004-09-09 21:47:32 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2007-03-21 20:24:01 +00:00
|
|
|
dl = dlopen(path, RTLD_NOW);
|
2004-09-09 21:47:32 +00:00
|
|
|
|
|
|
|
if (dl)
|
|
|
|
{
|
|
|
|
printf("Shared module loaded. Handle: %p\n", dl);
|
|
|
|
dlclose(dl);
|
|
|
|
dl = NULL;
|
|
|
|
} else {
|
|
|
|
printf("Shared module failed to load: %s\n", dlerror());
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|