22 return GetModuleHandleA(
NULL);
26 return GetModuleHandleA(name.c_str());
34 if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
35 (LPCTSTR)adr, &hModule) == 0)
37 if (GetLastError() != ERROR_MOD_NOT_FOUND)
39 throw std::runtime_error(
"GetModuleHandleEx failed");
50 if (GetModuleFileNameA(hModule, path, MAX_PATH) == 0)
52 throw std::runtime_error(
"GetModuleFileName failed");
66 handle = dlopen(
NULL, RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
70 handle = dlopen(name.c_str(), RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
93 dladdr((
void *)adr, &info);
94 return info.dli_fbase;
100 if (dladdr((
void *)hModule, &info) == 0)
102 throw std::runtime_error(
"dladdr failed");
104 return info.dli_fname;
122 static std::string modulePath;
124 if (modulePath ==
"")
void * ModuleHandle
Represents a module handle. Analogous to Windows this represents the module base address,...
etiss::ModuleHandle GetModuleByAddress(uintptr_t adr)
std::string GetCurrentModulePath()
Returns the abolute path with filename to the own dynamic library.
etiss::ModuleHandle GetModuleByName(const std::string &name="")
static const ModuleHandle NullModuleHandle
Represents a null value for hl::ModuleHandle.
std::string GetModulePath(etiss::ModuleHandle hModule)
etiss::ModuleHandle GetCurrentModule()
Returns the module handle to the own dynamic library.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...