GitHub

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

/*

22

* Copyright (C) 2010-2022 Ole André Vadla Ravnås <oleavr@nowsecure.com>

33

* Copyright (C) 2015 Asger Hautop Drewsen <asgerdrewsen@gmail.com>

4+

* Copyright (C) 2022 Francesco Tamagni <mrmacete@protonmail.ch>

45

*

56

* Licence: wxWindows Library Licence, Version 3.1

67

*/

@@ -1894,17 +1895,23 @@ gum_emit_import (const GumImportDetails * details,

18941895
18951896

if (d.module == NULL)

18961897

{

1897-

d.address = GUM_ADDRESS (dlsym (RTLD_DEFAULT, d.name));

1898+

if (details->address != 0)

1899+

d.address = details->address;

1900+

else

1901+

d.address = GUM_ADDRESS (dlsym (RTLD_DEFAULT, d.name));

18981902
18991903

if (d.address != 0)

19001904

{

19011905

const GumModuleDetails * module_details;

1906+

Dl_info info;

19021907
19031908

if (ctx->module_map == NULL)

19041909

ctx->module_map = gum_module_map_new ();

19051910

module_details = gum_module_map_find (ctx->module_map, d.address);

19061911

if (module_details != NULL)

19071912

d.module = module_details->path;

1913+

else if (dladdr (GSIZE_TO_POINTER (d.address), &info) != 0)

1914+

d.module = info.dli_fname;

19081915

}

19091916

}

19101917

@@ -1936,6 +1943,12 @@ gum_resolve_export (const char * module_name,

19361943

GumEnumerateImportsContext * ctx = user_data;

19371944

GumDarwinModule * module;

19381945
1946+

if (module_name == NULL)

1947+

{

1948+

const char * name = gum_symbol_name_from_darwin (symbol_name);

1949+

return GUM_ADDRESS (dlsym (RTLD_DEFAULT, name));

1950+

}

1951+
19391952

module = gum_darwin_module_resolver_find_module (ctx->resolver, module_name);

19401953

if (module != NULL)

19411954

{

Read the original on github.com ↗