2017-01-20 08:36:52 -05:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
namespace Utils
|
|
|
|
{
|
|
|
|
class Library
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Library() : module(nullptr), freeOnDestroy(false) {};
|
|
|
|
Library(std::string buffer, bool freeOnDestroy = true);
|
|
|
|
~Library();
|
|
|
|
|
|
|
|
bool valid();
|
|
|
|
HMODULE getModule();
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
std::function<T> get(std::string process)
|
|
|
|
{
|
|
|
|
if (!this->valid())
|
|
|
|
{
|
2017-01-20 16:41:03 -05:00
|
|
|
throw std::runtime_error("Library not loaded!");
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return reinterpret_cast<T*>(GetProcAddress(this->getModule(), process.data()));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
HMODULE module;
|
|
|
|
bool freeOnDestroy;
|
|
|
|
};
|
|
|
|
}
|