From c896d70f79ff1e69a654d6d584979b0aba94eb21 Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Tue, 5 Mar 2024 17:47:40 -0600 Subject: [PATCH] Small reorganization --- src/binary/module_base.hpp | 21 --------------------- src/binary/object.hpp | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/binary/module_base.hpp b/src/binary/module_base.hpp index 2dfccc2..15c701b 100644 --- a/src/binary/module_base.hpp +++ b/src/binary/module_base.hpp @@ -60,27 +60,6 @@ namespace detail { } } #else // Windows - inline std::string get_module_name(HMODULE handle) { - static std::mutex mutex; - std::lock_guard lock(mutex); - static std::unordered_map cache; - auto it = cache.find(handle); - if(it == cache.end()) { - char path[MAX_PATH]; - if(GetModuleFileNameA(handle, path, sizeof(path))) { - ///std::fprintf(stderr, "path: %s base: %p\n", path, handle); - cache.insert(it, {handle, path}); - return path; - } else { - std::fprintf(stderr, "%s\n", std::system_error(GetLastError(), std::system_category()).what()); - cache.insert(it, {handle, ""}); - return ""; - } - } else { - return it->second; - } - } - inline std::uintptr_t get_module_image_base(const std::string& object_path) { static std::mutex mutex; std::lock_guard lock(mutex); diff --git a/src/binary/object.hpp b/src/binary/object.hpp index a4cf17f..bbc59f3 100644 --- a/src/binary/object.hpp +++ b/src/binary/object.hpp @@ -68,6 +68,27 @@ namespace detail { } #endif #else + inline std::string get_module_name(HMODULE handle) { + static std::mutex mutex; + std::lock_guard lock(mutex); + static std::unordered_map cache; + auto it = cache.find(handle); + if(it == cache.end()) { + char path[MAX_PATH]; + if(GetModuleFileNameA(handle, path, sizeof(path))) { + ///std::fprintf(stderr, "path: %s base: %p\n", path, handle); + cache.insert(it, {handle, path}); + return path; + } else { + std::fprintf(stderr, "%s\n", std::system_error(GetLastError(), std::system_category()).what()); + cache.insert(it, {handle, ""}); + return ""; + } + } else { + return it->second; + } + } + inline object_frame get_frame_object_info(frame_ptr address) { object_frame frame; frame.raw_address = address;