17 return GetModuleHandleA(
NULL);
21 return GetModuleHandleA(name.c_str());
29 if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
30 (LPCTSTR)
adr, &hModule) == 0)
32 if (GetLastError() != ERROR_MOD_NOT_FOUND)
34 throw std::runtime_error(
"GetModuleHandleEx failed");
45 if (GetModuleFileNameA(hModule, path, MAX_PATH) == 0)
47 throw std::runtime_error(
"GetModuleFileName failed");
61 handle = dlopen(
NULL, RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
65 handle = dlopen(name.c_str(), RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
88 dladdr((
void *)
adr, &info);
89 return info.dli_fbase;
95 if (dladdr((
void *)hModule, &info) == 0)
97 throw std::runtime_error(
"dladdr failed");
99 return info.dli_fname;
119 static std::string modulePath;
121 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...