| 3 |
tristanc |
1 |
#include "pch.h"
|
|
|
2 |
#pragma hdrstop
|
|
|
3 |
|
|
|
4 |
#include "CGlueMgr.h"
|
|
|
5 |
#include <Engine/Base/CDataStore.h>
|
|
|
6 |
#include <Console/ConsoleClient.h>
|
|
|
7 |
#include <FrameScript/FrameScript.h>
|
|
|
8 |
#include <WowSvcs/ClientServices.h>
|
| 7 |
tristanc |
9 |
#include <DB/WowClientDB.h>
|
| 3 |
tristanc |
10 |
|
| 7 |
tristanc |
11 |
|
|
|
12 |
CVar* g_password = NULL;
|
|
|
13 |
|
|
|
14 |
|
| 3 |
tristanc |
15 |
/****************************************************************************
|
|
|
16 |
*
|
|
|
17 |
* Memory addresses
|
|
|
18 |
*
|
|
|
19 |
***/
|
|
|
20 |
|
| 7 |
tristanc |
21 |
#define CGLUEMGR_NETDISCONNECTHANDLER 0x004DA9D0
|
|
|
22 |
#define CGLUEMGR__RESUME 0x004DA5F0
|
|
|
23 |
#define CGLUEMGR__SUSPEND 0x004D8930
|
|
|
24 |
#define CGLUEMGR__SHUTDOWN 0x004DBBC0
|
| 3 |
tristanc |
25 |
|
|
|
26 |
|
|
|
27 |
/****************************************************************************
|
|
|
28 |
*
|
|
|
29 |
* Function pointers
|
|
|
30 |
*
|
|
|
31 |
***/
|
|
|
32 |
|
| 7 |
tristanc |
33 |
void (*NetDisconnectHandlerPtr) (void const *, void *) = *(void(*)(void const *, void *))CGLUEMGR_NETDISCONNECTHANDLER;
|
| 3 |
tristanc |
34 |
void (__cdecl* ResumePtr) (int unknown) = *(void (__cdecl*)(int))CGLUEMGR__RESUME;
|
|
|
35 |
void (__cdecl* SuspendPtr) () = *(void (__cdecl*)())CGLUEMGR__SUSPEND;
|
|
|
36 |
void (__cdecl* ShutdownPtr) () = *(void (__cdecl*)())CGLUEMGR__SHUTDOWN;
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
/****************************************************************************
|
|
|
40 |
*
|
|
|
41 |
* Detours setup
|
|
|
42 |
*
|
|
|
43 |
***/
|
|
|
44 |
|
|
|
45 |
//===========================================================================
|
|
|
46 |
void WowGM::CGlueMgr::Initialize () {
|
|
|
47 |
DETOUR_INIT;
|
|
|
48 |
|
| 7 |
tristanc |
49 |
DETOUR_ATTACH(NetDisconnectHandlerPtr,::CGlueMgr::NetDisconnectHandler);
|
| 3 |
tristanc |
50 |
DETOUR_ATTACH(ResumePtr,::CGlueMgr::Resume);
|
|
|
51 |
DETOUR_ATTACH(SuspendPtr,::CGlueMgr::Suspend);
|
|
|
52 |
DETOUR_ATTACH(ShutdownPtr,::CGlueMgr::Shutdown);
|
|
|
53 |
|
|
|
54 |
DETOUR_COMMIT;
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
//===========================================================================
|
|
|
58 |
void WowGM::CGlueMgr::Shutdown () {
|
|
|
59 |
DETOUR_INIT;
|
|
|
60 |
|
| 7 |
tristanc |
61 |
DETOUR_DETACH(NetDisconnectHandlerPtr,::CGlueMgr::NetDisconnectHandler);
|
| 3 |
tristanc |
62 |
DETOUR_DETACH(ResumePtr,::CGlueMgr::Resume);
|
|
|
63 |
DETOUR_DETACH(SuspendPtr,::CGlueMgr::Suspend);
|
|
|
64 |
DETOUR_DETACH(ShutdownPtr,::CGlueMgr::Shutdown);
|
|
|
65 |
|
|
|
66 |
DETOUR_COMMIT;
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
//===========================================================================
|
|
|
70 |
void WowGM::CGlueMgr::RegisterConsoleCommands() {
|
|
|
71 |
::CGlueMgr::RegisterConsoleCommands();
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
//===========================================================================
|
|
|
75 |
void WowGM::CGlueMgr::UnregisterConsoleCommands () {
|
|
|
76 |
::CGlueMgr::UnregisterConsoleCommands();
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
/****************************************************************************
|
|
|
81 |
*
|
|
|
82 |
* Commands
|
|
|
83 |
*
|
|
|
84 |
***/
|
|
|
85 |
|
|
|
86 |
//===========================================================================
|
|
|
87 |
int __cdecl CCommand_Script2 (const char* cmd,
|
|
|
88 |
const char* arguments) {
|
|
|
89 |
FrameScript_Execute(arguments, arguments, NULL);
|
|
|
90 |
return 0;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
int __cdecl CCommand_MoveCharacter (const char* command, const char* arguments) {
|
|
|
94 |
if ((*(int*)0x00B6A9E0)) { // CGlueMgr::m_currentScreen == 2
|
|
|
95 |
int characterIndex = (*(int*)0x00AC436C); //CCharacterSelection::s_selectionIndex
|
|
|
96 |
int numCharacters = (*(int*)0x00B6B23C);
|
|
|
97 |
int sumtingwong = (*(int*)0xB6B240);
|
|
|
98 |
|
|
|
99 |
unsigned long long guid = *(unsigned long long*)(sumtingwong + 408 * characterIndex);
|
|
|
100 |
|
|
|
101 |
CDataStore netMsg;
|
|
|
102 |
netMsg.Put(CMSG_MOVE_CHARACTER_CHEAT);
|
|
|
103 |
netMsg.Put(NULL);
|
|
|
104 |
netMsg.Put(1);
|
|
|
105 |
netMsg.Put(guid);
|
|
|
106 |
netMsg.Put(16310.325195f);
|
|
|
107 |
netMsg.Put(16268.939453f);
|
|
|
108 |
netMsg.Put(69.444290f);
|
|
|
109 |
netMsg.Put(0.00f);
|
|
|
110 |
netMsg.Finalize();
|
|
|
111 |
ClientServices_SendOnConnection(&netMsg);
|
|
|
112 |
FrameScript_Execute("GetCharacterListUpdate()", "GetCharacterListUpdate()", NULL);
|
|
|
113 |
//ClientConnection::GetCharacterList();
|
|
|
114 |
}
|
|
|
115 |
else {
|
|
|
116 |
ConsoleWrite("You can only use this command on the character selection screen", ERROR_COLOR);
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
return 0;
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
//===========================================================================
|
|
|
123 |
int __cdecl Script_DebugTest (lua_State* L) {
|
| 7 |
tristanc |
124 |
ConsoleWrite("Hello from Script_DebugTest!",DEFAULT_COLOR);
|
| 3 |
tristanc |
125 |
return TRUE;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
/****************************************************************************
|
|
|
130 |
*
|
|
|
131 |
* CGlueMgr class implementation
|
|
|
132 |
*
|
|
|
133 |
***/
|
|
|
134 |
|
|
|
135 |
//===========================================================================
|
| 7 |
tristanc |
136 |
int CGlueMgr::NetDisconnectHandler(void const *a1, void *a2) {
|
|
|
137 |
NetDisconnectHandlerPtr(a1, a2);
|
|
|
138 |
WowGM::CGlueMgr::SetLoginPassword();
|
|
|
139 |
return 1;
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
//===========================================================================
|
| 3 |
tristanc |
143 |
void __cdecl CGlueMgr::Resume (int initialized) {
|
|
|
144 |
ResumePtr(initialized);
|
|
|
145 |
RegisterConsoleCommands();
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
//===========================================================================
|
| 7 |
tristanc |
149 |
void WowGM::CGlueMgr::SetLoginPassword()
|
|
|
150 |
{
|
|
|
151 |
char command[256] = {};
|
|
|
152 |
|
|
|
153 |
// TODO: Call SStrPrintF here
|
|
|
154 |
sprintf_s(command,
|
|
|
155 |
sizeof(command),
|
|
|
156 |
"AccountLoginPasswordEdit:SetText(\"%s\")",
|
|
|
157 |
g_password->m_stringValue.m_string);
|
|
|
158 |
FrameScript_Execute(command,command,NULL);
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
//===========================================================================
|
| 3 |
tristanc |
162 |
void __cdecl CGlueMgr::Suspend () {
|
|
|
163 |
SuspendPtr();
|
|
|
164 |
UnregisterConsoleCommands();
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
//===========================================================================
|
|
|
168 |
void __cdecl CGlueMgr::Shutdown () {
|
|
|
169 |
ShutdownPtr();
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
//===========================================================================
|
|
|
173 |
void __cdecl CGlueMgr::RegisterConsoleCommands()
|
|
|
174 |
{
|
|
|
175 |
ConsoleCommandRegister("script", CCommand_Script2, DEFAULT, 0);
|
|
|
176 |
ConsoleCommandRegister("movecharacter", CCommand_MoveCharacter, GAME, NOHELP);
|
|
|
177 |
ConsoleCommandRegister("worldport", CCommand_MoveCharacter, GAME, NOHELP);
|
|
|
178 |
|
|
|
179 |
// TODO: Move the below line under FrameScript.cpp (see FrameScript_Initialize)
|
|
|
180 |
//ConsoleCommandRegister("signalevent", CCommand_SignalEvent, DEFAULT, 0);
|
|
|
181 |
FrameScript_RegisterFunction("debugtest",Script_DebugTest);
|
|
|
182 |
}
|
|
|
183 |
|
|
|
184 |
//===========================================================================
|
|
|
185 |
void __cdecl CGlueMgr::UnregisterConsoleCommands() {
|
|
|
186 |
ConsoleCommandUnregister("script");
|
|
|
187 |
ConsoleCommandUnregister("movecharacter");
|
|
|
188 |
ConsoleCommandUnregister("worldport");
|
|
|
189 |
|
|
|
190 |
//ConsoleCommandUnregister("signalevent");
|
|
|
191 |
FrameScript_UnregisterFunction("debugtest");
|
|
|
192 |
}
|