From 71ef00d29c76abafd00769860c8dbcb6f91cd8af Mon Sep 17 00:00:00 2001 From: quaK Date: Fri, 25 Apr 2025 21:47:52 +0300 Subject: [PATCH] Faster bootup Co-Authored-By: m <64374267+mjkzy@users.noreply.github.com> --- src/client/component/wmi.cpp | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/client/component/wmi.cpp diff --git a/src/client/component/wmi.cpp b/src/client/component/wmi.cpp new file mode 100644 index 00000000..37135a66 --- /dev/null +++ b/src/client/component/wmi.cpp @@ -0,0 +1,49 @@ +#include +#include "loader/component_loader.hpp" + +#include "game/game.hpp" + +#include "console/console.hpp" + +#include + +// Speeds up startup by disabling WMI + +namespace wmi +{ + namespace + { + HRESULT WINAPI co_initialize_ex_stub(LPVOID pvReserved, DWORD dwCoInit) + { + if ((uint64_t)_ReturnAddress() == 0x1412B36F2) + { + return E_FAIL; + } + + return CoInitializeEx(pvReserved, dwCoInit); + } + } + + class component final : public component_interface + { + public: + void* load_import(const std::string& library, const std::string& function) override + { + if (function == "CoInitializeEx") + { + return co_initialize_ex_stub; + } + + return nullptr; + } + + void post_unpack() override + { + // disable WMI and remove Hardware query(uses WMI) + utils::hook::set(0x140110260, 0xC3); // WMI + utils::hook::set(0x14002D808, 0xC3); // Hardware query + } + }; +} + +REGISTER_COMPONENT(wmi::component) \ No newline at end of file