Files

40 lines
616 B
C++
Raw Permalink Normal View History

2014-01-31 08:23:00 +13:00
2019-01-18 15:55:06 +01:00
#include "bbsys.hpp"
2019-01-18 17:04:17 +01:00
#include "std.hpp"
2014-01-31 08:23:00 +13:00
#include <windows.h>
static vector<HMODULE> _mods;
2019-01-18 17:04:17 +01:00
static void procNotFound()
{
ThrowRuntimeException("User lib function not found");
2014-01-31 08:23:00 +13:00
}
2019-01-18 17:04:17 +01:00
void _bbLoadLibs(char* p)
{
while (*p) {
HMODULE mod = LoadLibrary(p);
if (!mod) {
2014-01-31 08:23:00 +13:00
continue;
}
_mods.push_back(mod);
2019-01-18 17:04:17 +01:00
p += strlen(p) + 1;
while (*p) {
void* proc = GetProcAddress(mod, p);
p += strlen(p) + 1;
void* ptr = *(void**)p;
p += 4;
if (!proc)
proc = procNotFound;
*(void**)ptr = proc;
2014-01-31 08:23:00 +13:00
}
}
}
2019-01-18 17:04:17 +01:00
void _bbUnloadLibs()
{
for (; _mods.size(); _mods.pop_back())
FreeLibrary(_mods.back());
2014-01-31 08:23:00 +13:00
}