@@ -11,19 +11,11 @@ class HideHUDImplH1 : public GenericScopedServiceProvider
1111private:
1212 GameState mGame ;
1313
14- static inline std::shared_ptr<ModuleMidHook> hideHUDFlagHook1 ;
15- static inline std::shared_ptr< MidhookFlagInterpreter> hideHUDFlagInterpreter1 ;
16- static void hideHUDFlagHookFunction1 (SafetyHookContext& ctx) { hideHUDFlagInterpreter1-> setFlag (ctx); }
14+ static inline std::shared_ptr<ModulePatch> hideHUDPatchHook1 ;
15+ static inline std::shared_ptr<ModulePatch> hideHUDPatchHook2 ;
16+ static inline std::shared_ptr<ModulePatch> hideHUDPatchHook3;
1717
1818
19- static inline std::shared_ptr<ModuleMidHook> hideHUDFlagHook2;
20- static inline std::shared_ptr< MidhookFlagInterpreter> hideHUDFlagInterpreter2;
21- static void hideHUDFlagHookFunction2 (SafetyHookContext& ctx) { hideHUDFlagInterpreter2->setFlag (ctx); }
22-
23-
24- static inline std::shared_ptr<ModuleMidHook> hideHUDFlagHook3;
25- static inline std::shared_ptr< MidhookFlagInterpreter> hideHUDFlagInterpreter3;
26- static void hideHUDFlagHookFunction3 (SafetyHookContext& ctx) { hideHUDFlagInterpreter3->setFlag (ctx); }
2719
2820public:
2921 HideHUDImplH1 (GameState gameImpl, IDIContainer& dicon)
@@ -32,27 +24,33 @@ class HideHUDImplH1 : public GenericScopedServiceProvider
3224 {
3325 auto ptr = dicon.Resolve <PointerManager>().lock ();
3426
35- auto hideHUDFlagFunction1 = ptr->getData <std::shared_ptr<MultilevelPointer>>(nameof (hideHUDFlagFunction1 ), mGame );
36- hideHUDFlagInterpreter1 = ptr->getData <std::shared_ptr<MidhookFlagInterpreter>> (nameof (hideHUDFlagInterpreter1 ), mGame );
37- hideHUDFlagHook1 = ModuleMidHook ::make (GameState ( mGame ) .toModuleName (), hideHUDFlagFunction1, hideHUDFlagHookFunction1 );
27+ auto hideHUDPatchFunction1 = ptr->getData <std::shared_ptr<MultilevelPointer>>(nameof (hideHUDPatchFunction1 ), gameImpl);
28+ auto hideHUDPatchCode1 = ptr->getVectorData <byte> (nameof (hideHUDPatchCode1 ), gameImpl );
29+ hideHUDPatchHook1 = ModulePatch ::make (gameImpl .toModuleName (), hideHUDPatchFunction1, *hideHUDPatchCode1. get () );
3830
39- auto hideHUDFlagFunction2 = ptr->getData <std::shared_ptr<MultilevelPointer>>(nameof (hideHUDFlagFunction2), mGame );
40- hideHUDFlagInterpreter2 = ptr->getData <std::shared_ptr<MidhookFlagInterpreter>>(nameof (hideHUDFlagInterpreter2), mGame );
41- hideHUDFlagHook2 = ModuleMidHook::make (GameState (mGame ).toModuleName (), hideHUDFlagFunction2, hideHUDFlagHookFunction2);
31+ auto hideHUDPatchFunction2 = ptr->getData <std::shared_ptr<MultilevelPointer>>(nameof (hideHUDPatchFunction2), gameImpl);
32+ auto hideHUDPatchCode2 = ptr->getVectorData <byte>(nameof (hideHUDPatchCode2), gameImpl);
33+ hideHUDPatchHook2 = ModulePatch::make (gameImpl.toModuleName (), hideHUDPatchFunction2, *hideHUDPatchCode2.get ());
34+
35+ auto hideHUDPatchFunction3 = ptr->getData <std::shared_ptr<MultilevelPointer>>(nameof (hideHUDPatchFunction3), gameImpl);
36+ auto hideHUDPatchCode3 = ptr->getVectorData <byte>(nameof (hideHUDPatchCode3), gameImpl);
37+ hideHUDPatchHook3 = ModulePatch::make (gameImpl.toModuleName (), hideHUDPatchFunction3, *hideHUDPatchCode3.get ());
4238
43- auto hideHUDFlagFunction3 = ptr->getData <std::shared_ptr<MultilevelPointer>>(nameof (hideHUDFlagFunction3), mGame );
44- hideHUDFlagInterpreter3 = ptr->getData <std::shared_ptr<MidhookFlagInterpreter>>(nameof (hideHUDFlagInterpreter3), mGame );
45- hideHUDFlagHook3 = ModuleMidHook::make (GameState (mGame ).toModuleName (), hideHUDFlagFunction3, hideHUDFlagHookFunction3);
4639 }
4740
4841 virtual void updateService () override
4942 {
5043 // attach if requested
5144 PLOG_VERBOSE << " HideHUDImplH1::updateService" ;
5245 safetyhook::ThreadFreezer freezeThreads;
53- hideHUDFlagHook1->setWantsToBeAttached (serviceIsRequested ());
54- hideHUDFlagHook2->setWantsToBeAttached (serviceIsRequested ());
55- hideHUDFlagHook3->setWantsToBeAttached (serviceIsRequested ());
46+ Sleep (1 );
47+
48+
49+ bool newState = serviceIsRequested ();
50+ safetyhook::ThreadFreezer freeze{};
51+ hideHUDPatchHook1->setWantsToBeAttached (newState);
52+ hideHUDPatchHook2->setWantsToBeAttached (newState);
53+ hideHUDPatchHook3->setWantsToBeAttached (newState);
5654 PLOG_VERBOSE << " HideHUDImplH1::updateService DONE" ;
5755 }
5856};
@@ -64,9 +62,9 @@ class HideHUDImplH2 : public GenericScopedServiceProvider
6462private:
6563 GameState mGame ;
6664
67- static inline std::shared_ptr<ModuleMidHook> hideHUDFlagHook1;
68- static inline std::shared_ptr< MidhookFlagInterpreter> hideHUDFlagInterpreter1 ;
69- static void hideHUDFlagHookFunction1 (SafetyHookContext& ctx) { hideHUDFlagInterpreter1-> setFlag (ctx); }
65+
66+ static inline std::shared_ptr<ModulePatch> hideHUDPatchHook1 ;
67+
7068
7169
7270
@@ -77,18 +75,18 @@ class HideHUDImplH2 : public GenericScopedServiceProvider
7775 {
7876 auto ptr = dicon.Resolve <PointerManager>().lock ();
7977
80- auto hideHUDFlagFunction1 = ptr->getData <std::shared_ptr<MultilevelPointer>>(nameof (hideHUDFlagFunction1 ), mGame );
81- hideHUDFlagInterpreter1 = ptr->getData <std::shared_ptr<MidhookFlagInterpreter>> (nameof (hideHUDFlagInterpreter1 ), mGame );
82- hideHUDFlagHook1 = ModuleMidHook ::make (GameState ( mGame ) .toModuleName (), hideHUDFlagFunction1, hideHUDFlagHookFunction1 );
78+ auto hideHUDPatchFunction1 = ptr->getData <std::shared_ptr<MultilevelPointer>>(nameof (hideHUDPatchFunction1 ), gameImpl );
79+ auto hideHUDPatchCode1 = ptr->getVectorData <byte> (nameof (hideHUDPatchCode1 ), gameImpl );
80+ hideHUDPatchHook1 = ModulePatch ::make (gameImpl .toModuleName (), hideHUDPatchFunction1, *hideHUDPatchCode1. get () );
8381
8482 }
8583
8684 virtual void updateService () override
8785 {
8886 // attach if requested
8987 PLOG_VERBOSE << " HideHUDImplH2::updateService" ;
90- safetyhook::ThreadFreezer freezeThreads;
91- hideHUDFlagHook1 ->setWantsToBeAttached (serviceIsRequested ());
88+ safetyhook::ThreadFreezer freezeThreads{} ;
89+ hideHUDPatchHook1 ->setWantsToBeAttached (serviceIsRequested ());
9290 PLOG_VERBOSE << " HideHUDImplH2::updateService DONE" ;
9391 }
9492};
0 commit comments