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