|
1 | 1 | /* |
2 | 2 | * Copyright (C) 2010-2022 Ole André Vadla Ravnås <oleavr@nowsecure.com> |
3 | 3 | * Copyright (C) 2015 Asger Hautop Drewsen <asgerdrewsen@gmail.com> |
| 4 | + * Copyright (C) 2022 Francesco Tamagni <mrmacete@protonmail.ch> |
4 | 5 | * |
5 | 6 | * Licence: wxWindows Library Licence, Version 3.1 |
6 | 7 | */ |
@@ -1894,17 +1895,23 @@ gum_emit_import (const GumImportDetails * details,
|
1894 | 1895 | |
1895 | 1896 | if (d.module == NULL) |
1896 | 1897 | { |
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)); |
1898 | 1902 | |
1899 | 1903 | if (d.address != 0) |
1900 | 1904 | { |
1901 | 1905 | const GumModuleDetails * module_details; |
| 1906 | +Dl_info info; |
1902 | 1907 | |
1903 | 1908 | if (ctx->module_map == NULL) |
1904 | 1909 | ctx->module_map = gum_module_map_new (); |
1905 | 1910 | module_details = gum_module_map_find (ctx->module_map, d.address); |
1906 | 1911 | if (module_details != NULL) |
1907 | 1912 | d.module = module_details->path; |
| 1913 | +else if (dladdr (GSIZE_TO_POINTER (d.address), &info) != 0) |
| 1914 | +d.module = info.dli_fname; |
1908 | 1915 | } |
1909 | 1916 | } |
1910 | 1917 | |
@@ -1936,6 +1943,12 @@ gum_resolve_export (const char * module_name,
|
1936 | 1943 | GumEnumerateImportsContext * ctx = user_data; |
1937 | 1944 | GumDarwinModule * module; |
1938 | 1945 | |
| 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 | + |
1939 | 1952 | module = gum_darwin_module_resolver_find_module (ctx->resolver, module_name); |
1940 | 1953 | if (module != NULL) |
1941 | 1954 | { |
|