Merge pull request #205 from diamante0018/quick-ref-of-patch

Refactor quickpatch
This commit is contained in:
Dss0
2022-03-20 16:43:04 +01:00
committed by GitHub
3 changed files with 11 additions and 15 deletions

View File

@ -19,15 +19,9 @@ namespace Utils
return Library(handle);
}
Library::Library(const std::string& buffer, bool _freeOnDestroy) : _module(nullptr), freeOnDestroy(_freeOnDestroy)
Library::Library(const std::string& name, bool _freeOnDestroy) : _module(nullptr), freeOnDestroy(_freeOnDestroy)
{
this->_module = LoadLibraryExA(buffer.data(), nullptr, 0);
}
Library::Library(const std::string& buffer)
{
this->_module = GetModuleHandleA(buffer.data());
this->freeOnDestroy = true;
this->_module = LoadLibraryExA(name.data(), nullptr, 0);
}
Library::Library(const HMODULE handle)
@ -49,7 +43,7 @@ namespace Utils
return this->_module != nullptr;
}
HMODULE Library::getModule()
HMODULE Library::getModule() const
{
return this->_module;
}

View File

@ -9,14 +9,14 @@ namespace Utils
static Library Load(const std::filesystem::path& path);
static Library GetByAddress(void* address);
Library() : _module(nullptr), freeOnDestroy(false) {};
Library(const std::string& buffer, bool freeOnDestroy);
explicit Library(const std::string& name);
Library() : _module(GetModuleHandleA(nullptr)), freeOnDestroy(false) {};
explicit Library(const std::string& name, bool freeOnDestroy);
explicit Library(const std::string& name) : _module(GetModuleHandleA(name.data())), freeOnDestroy(true) {};
explicit Library(HMODULE handle);
~Library();
bool isValid() const;
HMODULE getModule();
HMODULE getModule() const;
template <typename T>
T getProc(const std::string& process) const