make umod able to load and unload per dll export call

This commit is contained in:
DubbleClick
2026-05-01 16:31:40 +07:00
parent 23a2c38935
commit 5be00dd712
2 changed files with 298 additions and 54 deletions
+48
View File
@@ -252,6 +252,54 @@ void InitInstance(HINSTANCE hModule)
}
}
extern "C" __declspec(dllexport) int __cdecl AddFile(const wchar_t* path)
{
if (!path) return RETURN_BAD_ARGUMENT;
try {
return TextureClient::AddFile(std::filesystem::path(path));
}
catch (...) {
return RETURN_FATAL_ERROR;
}
}
extern "C" __declspec(dllexport) int __cdecl RemoveFile(const wchar_t* path)
{
if (!path) return RETURN_BAD_ARGUMENT;
try {
return TextureClient::RemoveFile(std::filesystem::path(path));
}
catch (...) {
return RETURN_FATAL_ERROR;
}
}
extern "C" __declspec(dllexport) int __cdecl GetFiles(wchar_t* buffer, int buffer_size_chars)
{
try {
const auto files = TextureClient::GetFiles();
size_t required = 1;
for (const auto& path : files) {
required += path.native().size() + 1;
}
if (buffer && buffer_size_chars > 0 && static_cast<size_t>(buffer_size_chars) >= required) {
wchar_t* out = buffer;
for (const auto& path : files) {
const auto& native = path.native();
std::ranges::copy(native, out);
out += native.size();
*out++ = L'\0';
}
*out = L'\0';
}
return static_cast<int>(required);
}
catch (...) {
return RETURN_FATAL_ERROR;
}
}
void ExitInstance()
{
DISABLE_HOOK(GetProcAddress_fn);