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
commit bb59c10c92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 15 deletions

View File

@ -356,8 +356,8 @@ namespace Components
QuickPatch::QuickPatch()
{
// quit_hard
Command::Add("quit_hard", [](Command::Params*)
// quitHard
Command::Add("quitHard", [](Command::Params*)
{
int data = false;
const Utils::Library ntdll("ntdll.dll");
@ -841,6 +841,7 @@ namespace Components
}
});
#ifdef DEBUG
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& /*name*/, bool* /*restrict*/)
{
if (type == Game::XAssetType::ASSET_TYPE_GFXWORLD)
@ -855,6 +856,7 @@ namespace Components
Utils::IO::WriteFile("userraw/logs/matlog.txt", buffer);
}
});
#endif
// Dvars
Dvar::Register<bool>("ui_streamFriendly", false, Game::DVAR_FLAG_SAVED, "Stream friendly UI");

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