mirror of
				https://github.com/rofl0r/proxychains-ng.git
				synced 2025-11-03 16:46:06 +00:00 
			
		
		
		
	add possibility to search for DLL in exe's path
This commit is contained in:
		
							
								
								
									
										15
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/main.c
									
									
									
									
									
								
							@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user