forked from igroglaz/a2mgr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zxmgr.cpp
324 lines (299 loc) · 4.9 KB
/
zxmgr.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#include <cstdlib>
#include "zxmgr.h"
#include <cstdarg>
#include <cstring>
#include <cstdio>
unsigned long _memcpy = (unsigned long)memcpy;
namespace zxmgr
{
unsigned long AfxGetMainWnd()
{
unsigned long retv = 0;
__asm
{
mov edx, 0x00401870
call edx
mov retv, eax
}
return retv;
}
namespace GUI
{
unsigned long _stdcall GetWindowLong(unsigned long cptr, unsigned long which)
{
unsigned long retval;
__asm
{
push [which]
mov ecx, [cptr]
mov edx, [ecx]
call [edx+0x20]
mov [retval], eax
}
return retval;
}
void _stdcall RepaintWindow(unsigned long cptr)
{
__asm
{
mov ecx, [cptr]
mov edx, [ecx]
call [edx+0x34]
}
}
void _stdcall RepaintWindowIndirect(unsigned long cptr)
{
__asm
{
push 1
push [cptr]
mov ecx, [cptr]
add ecx, 0x48
mov edx, 0x004DC126
call edx
}
}
void _declspec(naked) GetClientRect(unsigned long cptr, RECT* rec)
{
__asm
{
push ebp
mov ebp, esp
push [ebp+0x0C]
mov edx, 0x00402800
call edx
mov eax, [ebp+0x08]
add eax, 0x08
push eax
push [ebp+0x0C]
mov ecx, [cptr]
mov edx, 0x004DBB93
call edx
mov esp, ebp
pop ebp
retn
}
}
}
namespace Font
{
unsigned long __declspec(naked) GetColor(unsigned long t)
{
__asm
{
/*push 0
mov ecx, dword_62B088
call sub_420440
*/
push ebp
mov ebp, esp
push 0
mov ecx, [ebp+0x08]
//mov ecx, 0x0062B088
mov ecx, [ecx]
mov edx, 0x00420440
call edx
mov esp, ebp
pop ebp
retn
}
}
void DrawText(unsigned long cptr, int x, int y, const char* string, unsigned long align, unsigned long color, unsigned long shadowpos)
{
__asm
{
push [shadowpos]
push [color]
push [align]
push [string]
push [y]
push [x]
mov ecx, [cptr]
mov ecx, [ecx]
mov edx, 0x004627F6
call edx
}
}
unsigned long MeasureTextWidth(unsigned long cptr, const char* string)
{
unsigned long retval;
__asm
{
push [string]
mov ecx, [cptr]
mov edx, 0x00461E19
call edx
mov [retval], eax
}
return retval;
}
}
void __declspec(naked) WriteChatRaw(const char* msg)
{
__asm
{
push ebp
mov ebp, esp
sub esp, 0x08
mov edx, 0x00401870
call edx
mov [ebp-0x08], eax
test eax, eax
jz skipsend
push 0x7530
push 0x0062AAF0
push [ebp+0x08]
mov ecx, [ebp-0x08]
mov ecx, [ecx+0xD0] // chat?
add ecx, 0x0A28
mov edx, 0x004021FE
call edx
skipsend:
mov esp, ebp
pop ebp
retn
}
}
void WriteChat(const char* s, ...)
{
char line[2048];
va_list va;
va_start(va, s);
_vsnprintf(line, 1255, s, va);
WriteChatRaw(line);
va_end(va);
}
void WriteChatA(const char* s, ...)
{
char line[2048];
va_list va;
va_start(va, s);
_vsnprintf(line, 1255, s, va);
AnsiToOem(line, line);
WriteChatRaw(line);
va_end(va);
}
void __declspec(naked) FillRect(int left, int top, int right, int bottom, unsigned long color)
{
__asm
{
push ebp
mov ebp, esp
push [ebp+0x18]
push [ebp+0x14]
push [ebp+0x10]
push [ebp+0x0C]
push [ebp+0x08]
mov edx, 0x0045B618
call edx
mov esp, ebp
pop ebp
retn
}
}
void __declspec(naked) UpdateScreen()
{
__asm
{
mov edx, 0x00458A58
call edx
retn
}
}
char* GetPatchString(unsigned long idx)
{
char* retv;
__asm
{
push [idx]
mov ecx, 0x0062BA40
mov edx, 0x00479BA3
call edx
mov retv, eax
}
return retv;
}
void LockBuffer()
{
__asm
{
mov edx, 0x00457EAE
call edx
}
}
void UnlockBuffer()
{
__asm
{
mov edx, 0x00457F0A
call edx
}
}
int __declspec(naked) GlobalReceive()
{
__asm
{
push ebp
mov ebp, esp
push 0x064
call AfxGetMainWnd
mov ecx, [eax+0xD0]
mov edx, 0x0040DAC9
call edx
mov esp, ebp
pop ebp
retn
}
}
void __declspec(naked) DisplayMouse()
{
__asm
{
mov ecx, 0x0060E6C0
mov edx, 0x00429114
call edx
retn
}
}
HWND GetHWND()
{
HWND hWnd;
unsigned long mainwnd = zxmgr::AfxGetMainWnd();
if(!mainwnd) return 0;
hWnd = *(HWND*)(mainwnd + 0x1C);
return hWnd;
}
void DoMessageLoop()
{
MSG msg;
while(PeekMessage(&msg, 0, 0, 0, 1))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
void LockHighSurface()
{
__asm
{
mov edx, 0x00457F5C
call edx
}
}
void UnlockHighSurface()
{
__asm
{
mov edx, 0x00457FB8
call edx
}
}
void AfxAbort()
{
__asm
{
mov edx, 0x005A8B96
call edx
}
}
}