Skip to content

Commit

Permalink
nall: Retrieve executable path more reliably
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm93 authored and LukeUsher committed Feb 21, 2025
1 parent 7a5174a commit 2c940b0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nall/nall/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ NALL_HEADER_INLINE auto program() -> string {
return Path::real(path);
}
#endif
Dl_info info;
dladdr((void*)&program, &info);
return Path::real(info.dli_fname);
char exe[PATH_MAX];
ssize_t count = readlink("/proc/self/exe", exe, PATH_MAX - 1);
if(count >= 0) {
exe[count] = '\0';
return Path::real(exe);
} else {
Dl_info info;
dladdr((void*)&program, &info);
return Path::real(info.dli_fname);
}
#endif
}

Expand Down

0 comments on commit 2c940b0

Please sign in to comment.