linux: Improve injector to handle faux .so mappings

So frida_find_library_base() still does the right thing if the target
process has a shared mapping for e.g. “libc.so”.

Co-authored-by: Ole André Vadla Ravnås <[email protected]>
This commit is contained in:
lx866andOle André Vadla Ravnås authored and Ole André Vadla Ravnås committed 2022-11-14 18:41:47 +01:00
1 parent b5001c88fb
commit 5e8314ffc0
1 file changed
+5 -4
+5 -4
View File
@@ -3067,14 +3067,15 @@ frida_find_library_base (pid_t pid, const gchar * library_name, gchar ** library
while (result == 0 && fgets (line, line_size, fp) != NULL)
{
GumAddress start;
gchar perms[5];
gint n;
n = sscanf (line, "%" G_GINT64_MODIFIER "x-%*x %*s %*x %*s %*s %s", &start, path);
if (n == 1)
n = sscanf (line, "%" G_GINT64_MODIFIER "x-%*x %s %*x %*s %*s %s", &start, perms, path);
if (n == 2)
continue;
g_assert (n == 2);
g_assert (n == 3);
if (path[0] == '[')
if (perms[3] == 's' || path[0] == '[')
continue;
if (strcmp (path, library_name) == 0)