11void*
OpenModule(
const std::filesystem::path& path)
13 return LoadLibraryW(path.c_str());
16void*
FindExport(
void* module,
const char* name)
18 return reinterpret_cast<void*
>(GetProcAddress(
static_cast<HMODULE
>(module), name));
23 return std::system_category().message(
static_cast<int>(GetLastError()));
29 HMODULE module =
nullptr;
30 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
31 static_cast<LPCWSTR
>(address), &module);
37 static const char inThisModule = 0;
39 const DWORD length = GetModuleFileNameW(
ModuleAt(&inThisModule), path,
static_cast<DWORD
>(std::size(path)));
40 return std::filesystem::path(path, path + length);
46 return module != nullptr ? reinterpret_cast<InterfaceFactory>(GetProcAddress(module, "CreateInterface")) : nullptr;
void *(*)(const char *name, int *returnCode) InterfaceFactory
static std::string LastError()
std::filesystem::path OwnPath()
InterfaceFactory FactoryAt(const void *address)
void * OpenModule(const std::filesystem::path &path)
static HMODULE ModuleAt(const void *address)
static void * FindExport(void *handle, const char *name)