18 #include "ur_win_proxy_loader.hpp"
21 inline namespace _V1 {
25 return (
void *)GetProcAddress((HMODULE)module, funcName);
36 UINT SavedMode = SetErrorMode(SEM_FAILCRITICALERRORS);
38 if (!SetDllDirectoryA(
"")) {
39 assert(
false &&
"Failed to update DLL search path");
42 auto Result = (
void *)LoadLibraryExA(LibraryPath.c_str(), NULL, NULL);
43 (void)SetErrorMode(SavedMode);
44 if (!SetDllDirectoryA(
nullptr)) {
45 assert(
false &&
"Failed to restore DLL search path");
52 return (
int)FreeLibrary((HMODULE)Library);
56 return reinterpret_cast<void *
>(
57 GetProcAddress((HMODULE)Library, FunctionName.c_str()));
61 wchar_t Path[MAX_PATH];
64 DWORD Ret = GetModuleFileName(
65 reinterpret_cast<HMODULE
>(
ExeModuleHandle == Handle ? 0 : Handle), Path,
67 assert(Ret < MAX_PATH &&
"Path is longer than MAX_PATH?");
68 assert(Ret > 0 &&
"GetModuleFileName failed");
71 BOOL RetCode = PathRemoveFileSpec(Path);
72 assert(RetCode &&
"PathRemoveFileSpec failed");
75 return std::filesystem::path(Path);
void * getOsLibraryFuncAddress(void *Library, const std::string &FunctionName)
void * getURLoaderLibrary()
static std::filesystem::path getCurrentDSODirPath()
void * loadOsLibrary(const std::string &Library)
int unloadOsLibrary(void *Library)
void * GetWinProcAddress(void *module, const char *funcName)
OSModuleHandle getOSModuleHandle(const void *VirtAddr)
constexpr OSModuleHandle ExeModuleHandle