diff --git a/Source/Endpoints.h b/Source/Endpoints.h index 63d57e0c1ea..4172916728e 100644 --- a/Source/Endpoints.h +++ b/Source/Endpoints.h @@ -30,15 +30,15 @@ inline int PeepEventsHook::SDL_PeepEvents(void* events, int numevents, hudFeatures().killfeedPreserver.run(); GlobalContext::instance().panoramaGUI->run(); - GlobalContext::instance().loopModeGameHook->update(); - GlobalContext::instance().viewRenderHook->update(); + GlobalContext::instance().hooks->loopModeGameHook.update(); + GlobalContext::instance().hooks->viewRenderHook.update(); visuals().scopeOverlayRemover.updatePanelVisibility(); if (GlobalContext::instance().unloadFlag) { const auto originalPeepEvents = GlobalContext::instance().peepEventsHook.original; GlobalContext::instance().peepEventsHook.disable(); - GlobalContext::instance().loopModeGameHook->forceUninstall(); - GlobalContext::instance().viewRenderHook->forceUninstall(); + GlobalContext::instance().hooks->loopModeGameHook.forceUninstall(); + GlobalContext::instance().hooks->viewRenderHook.forceUninstall(); GlobalContext::destroyInstance(); return originalPeepEvents(events, numevents, action, minType, maxType); } @@ -48,10 +48,10 @@ inline int PeepEventsHook::SDL_PeepEvents(void* events, int numevents, inline void* LoopModeGameHook::getWorldSession(cs2::CLoopModeGame* thisptr) noexcept { visuals().scopeOverlayRemover.getWorldSessionHook(RETURN_ADDRESS()); - return GlobalContext::instance().loopModeGameHook->originalGetWorldSession(thisptr); + return GlobalContext::instance().hooks->loopModeGameHook.originalGetWorldSession(thisptr); } inline void ViewRenderHook::onRenderStart(cs2::CViewRender* thisptr) noexcept { - GlobalContext::instance().viewRenderHook->originalOnRenderStart(thisptr); + GlobalContext::instance().hooks->viewRenderHook.originalOnRenderStart(thisptr); } diff --git a/Source/GlobalContext.h b/Source/GlobalContext.h index f4574087768..66483f4f2b3 100644 --- a/Source/GlobalContext.h +++ b/Source/GlobalContext.h @@ -3,6 +3,7 @@ #include #include "CS2/Constants/DllNames.h" +#include "Hooks/Hooks.h" #include "Hooks/PeepEventsHook.h" #include "Hooks/ViewRenderHook.h" @@ -23,8 +24,7 @@ struct GlobalContext { PatternFinder clientPatternFinder{ DynamicLibrary{cs2::CLIENT_DLL}.getCodeSection().raw(), PatternNotFoundLogger{} }; PatternFinder panoramaPatternFinder{ DynamicLibrary{cs2::PANORAMA_DLL}.getCodeSection().raw(), PatternNotFoundLogger{} }; std::optional gameClasses; - std::optional loopModeGameHook; - std::optional viewRenderHook; + std::optional hooks; std::optional features; std::optional panoramaGUI; @@ -52,9 +52,9 @@ struct GlobalContext { return; gameClasses.emplace(); - loopModeGameHook.emplace(VmtLengthCalculator{ DynamicLibrary{cs2::CLIENT_DLL}.getCodeSection(), DynamicLibrary{cs2::CLIENT_DLL}.getVmtSection() }); - viewRenderHook.emplace(VmtLengthCalculator{ DynamicLibrary{cs2::CLIENT_DLL}.getCodeSection(), DynamicLibrary{cs2::CLIENT_DLL}.getVmtSection() }); - features.emplace(HudProvider{}, *loopModeGameHook); + const VmtLengthCalculator clientVmtLengthCalculator{ DynamicLibrary{cs2::CLIENT_DLL}.getCodeSection(), DynamicLibrary{cs2::CLIENT_DLL}.getVmtSection() }; + hooks.emplace(clientVmtLengthCalculator); + features.emplace(HudProvider{}, hooks->loopModeGameHook, hooks->viewRenderHook); panoramaGUI.emplace(*features, unloadFlag); initializedFromGameThread = true; diff --git a/Source/Hooks/Hooks.h b/Source/Hooks/Hooks.h new file mode 100644 index 00000000000..8b201cfbcb6 --- /dev/null +++ b/Source/Hooks/Hooks.h @@ -0,0 +1,17 @@ +#pragma once + +#include "LoopModeGameHook.h" +#include "ViewRenderHook.h" + +#include + +struct Hooks { + explicit Hooks(const VmtLengthCalculator& clientVmtLengthCalculator) noexcept + : loopModeGameHook{ clientVmtLengthCalculator } + , viewRenderHook{ clientVmtLengthCalculator } + { + } + + LoopModeGameHook loopModeGameHook; + ViewRenderHook viewRenderHook; +}; diff --git a/Source/Osiris.vcxproj b/Source/Osiris.vcxproj index a954abc9f56..cc4f153781b 100644 --- a/Source/Osiris.vcxproj +++ b/Source/Osiris.vcxproj @@ -68,6 +68,7 @@ + diff --git a/Source/Osiris.vcxproj.filters b/Source/Osiris.vcxproj.filters index c276ab9a60e..c96e19c8364 100644 --- a/Source/Osiris.vcxproj.filters +++ b/Source/Osiris.vcxproj.filters @@ -531,6 +531,9 @@ Hooks + + Hooks +