4
4
#include " Games\AlphaMW2\MenuFunctions.h"
5
5
6
6
7
+ Detour *AlphaMW2Title::s_pScr_NotifyDetour = nullptr ;
8
+ Detour *AlphaMW2Title::s_pSV_ExecuteClientCommandDetour = nullptr ;
9
+
10
+
11
+ AlphaMW2Title::~AlphaMW2Title ()
12
+ {
13
+ delete s_pScr_NotifyDetour;
14
+ delete s_pSV_ExecuteClientCommandDetour;
15
+ }
16
+
7
17
void AlphaMW2Title::Init ()
8
18
{
9
19
Xam::XNotify (" Hayzen - MW2 Alpha Multiplayer Detected" );
@@ -28,9 +38,9 @@ void AlphaMW2Title::Init()
28
38
CreateStructure ();
29
39
30
40
// Set up the function hooks
31
- Memory::HookFunctionStart ( reinterpret_cast <DWORD *>( 0x8218B5F0 ), reinterpret_cast <DWORD *>(SCR_DrawScreenFieldStub), reinterpret_cast <DWORD>( SCR_DrawScreenFieldHook) );
32
- Memory::HookFunctionStart ( reinterpret_cast <DWORD *>( 0x822539C0 ), reinterpret_cast <DWORD *>(Scr_NotifyStub), reinterpret_cast <DWORD>( Scr_NotifyHook) );
33
- Memory::HookFunctionStart ( reinterpret_cast <DWORD *>( 0x822B4700 ), reinterpret_cast <DWORD *>(SV_ExecuteClientCommandStub), reinterpret_cast <DWORD>( SV_ExecuteClientCommandHook) );
41
+ s_pSCR_DrawScreenFieldDetour = new Detour ( 0x8218B5F0 , SCR_DrawScreenFieldHook);
42
+ s_pScr_NotifyDetour = new Detour ( 0x822539C0 , Scr_NotifyHook);
43
+ s_pSV_ExecuteClientCommandDetour = new Detour ( 0x822B4700 , SV_ExecuteClientCommandHook);
34
44
}
35
45
36
46
void AlphaMW2Title::CreateStructure ()
@@ -65,7 +75,7 @@ void AlphaMW2Title::CreateStructure()
65
75
void AlphaMW2Title::Scr_NotifyHook (AlphaMW2::Game::gentity_s *entity, uint16_t stringValue, uint32_t paramCount)
66
76
{
67
77
// Call the original Scr_Notify function
68
- Scr_NotifyStub (entity, stringValue, paramCount);
78
+ s_pScr_NotifyDetour-> GetOriginal < decltype (&Scr_NotifyHook)>() (entity, stringValue, paramCount);
69
79
70
80
// If the client is not host, no need to go further
71
81
int iClientNum = entity->state .number ;
@@ -91,7 +101,7 @@ void AlphaMW2Title::Scr_NotifyHook(AlphaMW2::Game::gentity_s *entity, uint16_t s
91
101
void AlphaMW2Title::SV_ExecuteClientCommandHook (int client, const char *s, int clientOK, int fromOldServer)
92
102
{
93
103
// Call the original Scr_Notify SV_ExecuteClientCommand
94
- SV_ExecuteClientCommandStub (client, s, clientOK, fromOldServer);
104
+ s_pSV_ExecuteClientCommandDetour-> GetOriginal < decltype (&SV_ExecuteClientCommandHook)>() (client, s, clientOK, fromOldServer);
95
105
96
106
// If the client is not host, no need to go further
97
107
int iClientNum = (client - Memory::Read<int >(0x83577D98 )) / 0x97F80 ;
@@ -102,33 +112,3 @@ void AlphaMW2Title::SV_ExecuteClientCommandHook(int client, const char *s, int c
102
112
if (!strcmp (s, " matchdatadone" ))
103
113
s_Menu.Stop ();
104
114
}
105
-
106
- void __declspec (naked) AlphaMW2Title::Scr_NotifyStub(AlphaMW2::Game::gentity_s *entity, uint16_t stringValue, uint32_t paramCount)
107
- {
108
- __asm
109
- {
110
- nop
111
- nop
112
- nop
113
- nop
114
- nop
115
- nop
116
- nop
117
- li r3, 1
118
- }
119
- }
120
-
121
- void __declspec (naked) AlphaMW2Title::SV_ExecuteClientCommandStub(int client, const char *s, int clientOK, int fromOldServer)
122
- {
123
- __asm
124
- {
125
- nop
126
- nop
127
- nop
128
- nop
129
- nop
130
- nop
131
- nop
132
- li r3, 2
133
- }
134
- }
0 commit comments