diff options
author | rofl0r <retnyg@gmx.net> | 2011-11-06 20:47:44 +0400 |
---|---|---|
committer | rofl0r <retnyg@gmx.net> | 2011-11-06 20:47:44 +0400 |
commit | 6ac6abd3deca47dd9e06fba58c415e0af098934e (patch) | |
tree | 4701153d54170ae92fc37a3e2efbadd3280d7eaf | |
parent | 41e73ab58d2fa2bf047b93fd88d65e4a888836e6 (diff) |
add possibility to search for DLL in exe's path
-rw-r--r-- | src/main.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -41,8 +41,10 @@ int check_path(char* path) { static const char* dll_name = "libproxychains4.so"; +static char own_dir[256]; static const char* dll_dirs[] = { ".", + own_dir, LIB_DIR, "/lib", "/usr/lib", @@ -51,6 +53,17 @@ static const char* dll_dirs[] = { NULL }; +static void set_own_dir(const char* argv0) { + size_t l = strlen(argv0); + while(l && argv0[l - 1] != '/') l--; + if(l == 0) + memcpy(own_dir, ".", 2); + else { + memcpy(own_dir, argv0, l - 1); + own_dir[l] = 0; + } +} + int main(int argc, char *argv[]) { char *path = NULL; char buf[256]; @@ -114,6 +127,8 @@ int main(int argc, char *argv[]) { size_t i = 0; const char* prefix = NULL; + set_own_dir(argv[0]); + while(dll_dirs[i]) { snprintf(buf, sizeof(buf), "%s/%s", dll_dirs[i], dll_name); if(access(buf, R_OK) != -1) { |