Small reorganization
This commit is contained in:
parent
d8e23c1e93
commit
c896d70f79
@ -60,27 +60,6 @@ namespace detail {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else // Windows
|
#else // Windows
|
||||||
inline std::string get_module_name(HMODULE handle) {
|
|
||||||
static std::mutex mutex;
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
|
||||||
static std::unordered_map<HMODULE, std::string> 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) {
|
inline std::uintptr_t get_module_image_base(const std::string& object_path) {
|
||||||
static std::mutex mutex;
|
static std::mutex mutex;
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
|||||||
@ -68,6 +68,27 @@ namespace detail {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
inline std::string get_module_name(HMODULE handle) {
|
||||||
|
static std::mutex mutex;
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
static std::unordered_map<HMODULE, std::string> 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) {
|
inline object_frame get_frame_object_info(frame_ptr address) {
|
||||||
object_frame frame;
|
object_frame frame;
|
||||||
frame.raw_address = address;
|
frame.raw_address = address;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user