| 3 |
tristanc |
1 |
#include "pch.h"
|
|
|
2 |
#pragma hdrstop
|
|
|
3 |
|
|
|
4 |
#include "ConsoleClient.h"
|
|
|
5 |
|
| 32 |
tristanc |
6 |
|
| 3 |
tristanc |
7 |
/****************************************************************************
|
|
|
8 |
*
|
| 31 |
tristanc |
9 |
* Client memory addresses
|
| 3 |
tristanc |
10 |
*
|
|
|
11 |
***/
|
|
|
12 |
|
| 31 |
tristanc |
13 |
#define CONSOLEWRITE_PTR 0x00765270
|
|
|
14 |
#define CONSOLEWRITEA_PTR 0x0063CD00
|
|
|
15 |
#define CONSOLESETHOTKEY_PTR 0x0063CB00
|
|
|
16 |
#define CONSOLESETTITLE_PTR 0x0063CB10
|
|
|
17 |
#define CONSOLECOMMANDEXECUTE_PTR 0x007658A0
|
|
|
18 |
#define CONSOLECOMMANDREGISTER_PTR 0x00769100
|
|
|
19 |
#define CONSOLECOMMANDWRITEHELP_PTR 0x0063FDB0
|
| 32 |
tristanc |
20 |
#define CONSOLECOMMANDUNREGISTER_PTR 0x007689E0
|
|
|
21 |
#define CONSOLEPRINTF_PTR 0x007653B0
|
| 3 |
tristanc |
22 |
|
| 31 |
tristanc |
23 |
#define G_EXECCREATEMODE_PTR 0x00ADBD48
|
|
|
24 |
#define G_EXECBUFFER_PTR 0x00CA1A28
|
| 3 |
tristanc |
25 |
|
| 31 |
tristanc |
26 |
#define S_ACTIVE_PTR 0x00C4EAC8
|
|
|
27 |
#define S_CONSOLEACCESSENABLED_PTR 0x00CABCC4
|
|
|
28 |
#define S_CONSOLEKEY_PTR 0x00864554
|
| 3 |
tristanc |
29 |
|
|
|
30 |
|
|
|
31 |
/****************************************************************************
|
|
|
32 |
*
|
| 31 |
tristanc |
33 |
* Client symbol pointers
|
| 3 |
tristanc |
34 |
*
|
|
|
35 |
***/
|
|
|
36 |
|
| 31 |
tristanc |
37 |
static BOOL* s_active = (BOOL*)S_ACTIVE_PTR;
|
| 3 |
tristanc |
38 |
|
| 31 |
tristanc |
39 |
static BOOL* s_consoleAccessEnabled = (BOOL*)S_CONSOLEACCESSENABLED_PTR;
|
| 3 |
tristanc |
40 |
|
| 31 |
tristanc |
41 |
static KEY* s_consoleKey = (KEY*)S_CONSOLEKEY_PTR;
|
| 3 |
tristanc |
42 |
|
| 31 |
tristanc |
43 |
|
|
|
44 |
void (*ConsoleWritePtr)(LPCSTR,COLOR_T) = *(void(*)(LPCSTR,COLOR_T))CONSOLEWRITE_PTR;
|
|
|
45 |
|
|
|
46 |
void (*ConsoleWriteAPtr)(LPCSTR,COLOR_T, ...) = *(void(*)(LPCSTR,COLOR_T,...))CONSOLEWRITEA_PTR;
|
|
|
47 |
|
|
|
48 |
void (*ConsoleSetHotkeyPtr)(KEY) = *(void(*)(KEY))CONSOLESETHOTKEY_PTR;
|
|
|
49 |
|
|
|
50 |
void (*ConsoleSetTitlePtr)(LPSTR) = *(void(*)(LPSTR))CONSOLESETTITLE_PTR;
|
|
|
51 |
|
|
|
52 |
void (*ConsoleCommandExecutePtr)(LPCSTR,BOOL) = *(void(*)(LPCSTR,BOOL))CONSOLECOMMANDEXECUTE_PTR;
|
|
|
53 |
|
|
|
54 |
BOOL (*ConsoleCommandRegisterPtr)(LPCSTR,BOOL(*)(LPCSTR,LPCSTR),CATEGORY,LPCSTR) = *(BOOL(*)(LPCSTR,BOOL(*)(LPCSTR,LPCSTR),CATEGORY,LPCSTR))CONSOLECOMMANDREGISTER_PTR;
|
|
|
55 |
|
|
|
56 |
void (*ConsoleCommandWriteHelpPtr)(LPCSTR) = *(void(*)(LPCSTR))CONSOLECOMMANDWRITEHELP_PTR;
|
|
|
57 |
|
|
|
58 |
void (*ConsoleCommandUnregisterPtr)(LPCSTR) = *(void(*)(LPCSTR))CONSOLECOMMANDUNREGISTER_PTR;
|
|
|
59 |
|
|
|
60 |
void (*ConsolePrintfPtr)(LPCSTR,...) = *(void(*)(LPCSTR,...))CONSOLEPRINTF_PTR;
|
|
|
61 |
|
|
|
62 |
|
| 3 |
tristanc |
63 |
/****************************************************************************
|
|
|
64 |
*
|
| 31 |
tristanc |
65 |
* Global variables
|
| 3 |
tristanc |
66 |
*
|
|
|
67 |
***/
|
|
|
68 |
|
|
|
69 |
EXECMODE& g_ExecCreateMode = *(EXECMODE*)G_EXECCREATEMODE_PTR;
|
|
|
70 |
|
| 31 |
tristanc |
71 |
char* g_ExecBuffer = (char *)G_EXECBUFFER_PTR;
|
| 3 |
tristanc |
72 |
|
| 31 |
tristanc |
73 |
|
| 3 |
tristanc |
74 |
/****************************************************************************
|
|
|
75 |
*
|
| 32 |
tristanc |
76 |
* External
|
| 3 |
tristanc |
77 |
*
|
|
|
78 |
***/
|
|
|
79 |
|
|
|
80 |
//===========================================================================
|
| 31 |
tristanc |
81 |
void ConsoleWrite (char const* str, COLOR_T color) {
|
|
|
82 |
ConsoleWritePtr(str,color);
|
| 3 |
tristanc |
83 |
}
|
|
|
84 |
|
|
|
85 |
//===========================================================================
|
| 31 |
tristanc |
86 |
void ConsoleWriteA (char const* str, COLOR_T color, ...) {
|
| 3 |
tristanc |
87 |
va_list va;
|
|
|
88 |
va_start(va,color);
|
| 31 |
tristanc |
89 |
|
| 3 |
tristanc |
90 |
if (str && *str) {
|
|
|
91 |
char buf[1024] = {};
|
|
|
92 |
vsnprintf(buf,sizeof(buf),str,va);
|
|
|
93 |
ConsoleWrite(buf,color);
|
|
|
94 |
}
|
| 31 |
tristanc |
95 |
|
| 3 |
tristanc |
96 |
va_end(va);
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
//===========================================================================
|
| 31 |
tristanc |
100 |
void ConsoleAccessSetEnabled (BOOL enable) {
|
|
|
101 |
*s_consoleAccessEnabled = enable;
|
| 3 |
tristanc |
102 |
}
|
|
|
103 |
|
|
|
104 |
//===========================================================================
|
| 31 |
tristanc |
105 |
BOOL ConsoleAccessGetEnabled () {
|
|
|
106 |
return *s_consoleAccessEnabled;
|
| 3 |
tristanc |
107 |
}
|
|
|
108 |
|
|
|
109 |
//===========================================================================
|
| 31 |
tristanc |
110 |
BOOL ConsoleIsActive () {
|
|
|
111 |
return *s_active;
|
| 3 |
tristanc |
112 |
}
|
|
|
113 |
|
|
|
114 |
//===========================================================================
|
| 31 |
tristanc |
115 |
void ConsoleSetHotkey (KEY key) {
|
|
|
116 |
ConsoleSetHotkeyPtr(key);
|
| 3 |
tristanc |
117 |
}
|
|
|
118 |
|
|
|
119 |
//===========================================================================
|
| 31 |
tristanc |
120 |
void ConsoleSetTitle (LPSTR windowTitle) {
|
|
|
121 |
ConsoleSetTitlePtr(windowTitle);
|
| 3 |
tristanc |
122 |
}
|
|
|
123 |
|
|
|
124 |
//===========================================================================
|
| 31 |
tristanc |
125 |
void ConsoleCommandExecute (LPCSTR command, BOOL addToHistory) {
|
|
|
126 |
ConsoleCommandExecutePtr(command,addToHistory);
|
| 3 |
tristanc |
127 |
}
|
|
|
128 |
|
|
|
129 |
//===========================================================================
|
| 31 |
tristanc |
130 |
BOOL ConsoleCommandRegister (LPCSTR command,
|
|
|
131 |
BOOL (*handler)(LPCSTR,LPCSTR),
|
|
|
132 |
CATEGORY category,
|
|
|
133 |
LPCSTR helpText) {
|
|
|
134 |
|
| 3 |
tristanc |
135 |
return ConsoleCommandRegisterPtr(command,handler,category,helpText);
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
//===========================================================================
|
| 31 |
tristanc |
139 |
void ConsoleCommandWriteHelp (LPCSTR str) {
|
| 3 |
tristanc |
140 |
ConsoleCommandWriteHelpPtr(str);
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
//===========================================================================
|
| 31 |
tristanc |
144 |
void ConsoleCommandUnregister (LPCSTR command) {
|
| 3 |
tristanc |
145 |
ConsoleCommandUnregisterPtr(command);
|
|
|
146 |
}
|
| 29 |
tristanc |
147 |
|
|
|
148 |
//===========================================================================
|
| 31 |
tristanc |
149 |
void ConsolePrintf (LPCSTR str, ...) {
|
| 29 |
tristanc |
150 |
va_list arglist;
|
|
|
151 |
va_start(arglist, str);
|
| 31 |
tristanc |
152 |
|
| 29 |
tristanc |
153 |
char const* token = va_arg(arglist, char const*);
|
| 32 |
tristanc |
154 |
|
|
|
155 |
ConsolePrintfPtr(str, token);
|
| 29 |
tristanc |
156 |
|
|
|
157 |
va_end(arglist);
|
| 31 |
tristanc |
158 |
}
|
| 32 |
tristanc |
159 |
|