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())
|
|
|
|
{
|
|
|
|
throw new std::runtime_error("Library not loaded!");
|
|
|
|
}
|
|
|
|
|
|
|
|
return reinterpret_cast<T*>(GetProcAddress(this->getModule(), process.data()));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
HMODULE module;
|
|
|
|
bool freeOnDestroy;
|
|
|
|
};
|
|
|
|
}
|