2016-09-16 18:14:59 -04:00
|
|
|
#include "STDInclude.hpp"
|
|
|
|
|
|
|
|
namespace Utils
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
Library::Library(std::string buffer, bool _freeOnDestroy) : freeOnDestroy(_freeOnDestroy), module(nullptr)
|
2016-09-16 18:14:59 -04:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
this->module = LoadLibraryExA(buffer.data(), NULL, 0);
|
2016-09-16 18:14:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Library::~Library()
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
if (this->freeOnDestroy && this->valid())
|
2016-09-16 18:14:59 -04:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
FreeLibrary(this->getModule());
|
2016-09-16 18:14:59 -04:00
|
|
|
}
|
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
this->module = nullptr;
|
2016-09-16 18:14:59 -04:00
|
|
|
}
|
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
bool Library::valid()
|
2016-09-16 18:14:59 -04:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
return (this->getModule() != nullptr);
|
2016-09-16 18:14:59 -04:00
|
|
|
}
|
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
HMODULE Library::getModule()
|
2016-09-16 18:14:59 -04:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
return this->module;
|
2016-09-16 18:14:59 -04:00
|
|
|
}
|
|
|
|
}
|