#pragma once namespace Utils { class Library { public: Library() : _module(nullptr), freeOnDestroy(false) {}; Library(const std::string& buffer, bool freeOnDestroy = true); ~Library(); bool valid(); HMODULE getModule(); template std::function get(const std::string& process) { if (!this->valid()) { throw std::runtime_error("Library not loaded!"); } return reinterpret_cast(GetProcAddress(this->getModule(), process.data())); } void free(); private: HMODULE _module; bool freeOnDestroy; }; }