impr: Get rid of cimgui shared library by hooking pinvoke handler

This commit is contained in:
WerWolv
2024-03-12 23:17:49 +01:00
parent 876f091244
commit fdf01dfb50
15 changed files with 135 additions and 57 deletions

View File

@@ -16,9 +16,11 @@
#include <wolv/utils/guards.hpp>
#elif defined(OS_LINUX)
#include <unistd.h>
#include <dlfcn.h>
#include <hex/helpers/utils_linux.hpp>
#elif defined(OS_MACOS)
#include <unistd.h>
#include <dlfcn.h>
#include <hex/helpers/utils_macos.hpp>
#elif defined(OS_WEB)
#include "emscripten.h"
@@ -784,4 +786,23 @@ namespace hex {
#endif
}
void* getContainingModule(void* symbol) {
#if defined(OS_WINDOWS)
MEMORY_BASIC_INFORMATION mbi;
if (VirtualQuery(symbol, &mbi, sizeof(mbi)))
return mbi.AllocationBase;
return nullptr;
#elif !defined(OS_WEB)
Dl_info info;
if (dladdr(symbol, nullptr) == 0)
return nullptr;
return dlopen(info.dli_fname, RTLD_LAZY);
#else
return nullptr;
#endif
}
}