upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/registry.cpp
diff options
context:
space:
mode:
authoromardev29 <154835571+omardev29@users.noreply.github.com>2026-11-22 05:27:51 +0100
committeromardev29 <154835571+omardev29@users.noreply.github.com>2026-11-22 12:29:52 +0100
commit5b9782f68d574b7774ea3dca794d1367bb52ba2a (patch)
tree9f20803e1facef8ae9f5f07948cbe0b4ee0ec937 /runtime/shims/registry.cpp
parent21b920bfb0579f242c2f1069971b238beaedeae6 (diff)
shims: mapped_image_base, the base of the mapped module holding an address
Answers from the same per-Loader lookups the unimplemented-import report uses, under the same lock. Used by the next commit.
Diffstat (limited to 'runtime/shims/registry.cpp')
-rw-r--r--runtime/shims/registry.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/runtime/shims/registry.cpp b/runtime/shims/registry.cpp
index d6f989fae..4c6a0d60b 100644
--- a/runtime/shims/registry.cpp
+++ b/runtime/shims/registry.cpp
@@ -302,6 +302,18 @@ void add_module_lookup(void* ctx, ModuleLookup fn) {
302 g_lookups.push_back({ctx, fn}); 302 g_lookups.push_back({ctx, fn});
303} 303}
304 304
305bool mapped_image_base(uint64_t address, uint64_t& base) {
306 std::string module;
307 uint32_t rva = 0;
308 std::lock_guard lock(g_lookup_mutex);
309 for (auto& l : g_lookups)
310 if (l.fn(l.ctx, address, module, rva)) {
311 base = address - rva;
312 return true;
313 }
314 return false;
315}
316
305void remove_module_lookup(void* ctx) { 317void remove_module_lookup(void* ctx) {
306 std::lock_guard lock(g_lookup_mutex); 318 std::lock_guard lock(g_lookup_mutex);
307 for (auto it = g_lookups.begin(); it != g_lookups.end(); ++it) 319 for (auto it = g_lookups.begin(); it != g_lookups.end(); ++it)