X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fwindows%2Fmodule.cpp;fp=source%2Fcore%2Fwindows%2Fmodule.cpp;h=a0301c10b54b6a7b5a9e9d00807c5489d9271d0a;hp=0000000000000000000000000000000000000000;hb=37e49590062c96cfa5f32509a88d5371a4dd83f2;hpb=2b6b7d97cb2b68c72299dcedc2dc986e775c8953 diff --git a/source/core/windows/module.cpp b/source/core/windows/module.cpp new file mode 100644 index 0000000..a0301c1 --- /dev/null +++ b/source/core/windows/module.cpp @@ -0,0 +1,34 @@ +#include "module.h" +#include "module_private.h" +#include "systemerror.h" + +using namespace std; + +namespace Msp { + +Module::Module(const string &name) +{ + ModuleHandle handle = LoadLibrary(name.c_str()); + if(!handle) + throw system_error("LoadLibrary"); + + priv = new Private; + priv->handle = handle; +} + +Module::~Module() +{ + FreeLibrary(priv->handle); + delete priv; +} + +void *Module::get_symbol(const string &name) const +{ + FARPROC result = GetProcAddress(priv->handle, name.c_str()); + if(!result) + throw system_error("GetProcAddress"); + + return reinterpret_cast(result); +} + +} // namespace Msp