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