iw4x-client/src/Utils/Library.cpp

38 lines
552 B
C++
Raw Normal View History

2017-01-19 16:23:59 -05:00
#include "STDInclude.hpp"
namespace Utils
{
Library::Library(std::string buffer, bool _freeOnDestroy) : module(nullptr), freeOnDestroy(_freeOnDestroy)
2017-01-19 16:23:59 -05:00
{
this->module = LoadLibraryExA(buffer.data(), nullptr, 0);
2017-01-19 16:23:59 -05:00
}
Library::~Library()
{
2017-03-26 12:00:06 -04:00
if (this->freeOnDestroy)
2017-01-19 16:23:59 -05:00
{
2017-03-26 12:00:06 -04:00
this->free();
2017-01-19 16:23:59 -05:00
}
}
bool Library::valid()
{
return (this->getModule() != nullptr);
}
HMODULE Library::getModule()
{
return this->module;
}
2017-03-26 12:00:06 -04:00
void Library::free()
{
if (this->valid())
{
FreeLibrary(this->getModule());
}
this->module = nullptr;
}
2017-01-19 16:23:59 -05:00
}