forked from igroglaz/a2mgr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crash.cpp
357 lines (309 loc) · 4.99 KB
/
crash.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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#include <windows.h>
#include "a2mgr.h"
DWORD _stdcall CheckValid(LPVOID what, DWORD count = 4)
{
if(!IsBadReadPtr(what, count)) return (DWORD)what;
return 0;
}
DWORD _stdcall CheckValidW(LPVOID what, DWORD count = 4)
{
if(!IsBadWritePtr(what, count)) return (DWORD)what;
return 0;
}
void __declspec(naked) CRASH_fix_414994()
{
__asm
{
push 4
push eax
call CheckValid
test eax, eax
jz ret_bad
mov eax, [eax]
push 0x38
push eax
call CheckValid
test eax, eax
jz ret_bad
mov ecx, [eax+0x34]
and ecx, 1
mov edx, 0x0041499C
jmp edx
ret_bad:
mov edx, 0x00417BE5
jmp edx
}
}
void __declspec(naked) CRASH_fix_42353A()
{
__asm
{
push 8
push eax
call CheckValid
test eax, eax
jz ret_bad
mov ecx, [eax+4]
mov edx, [ebp+0x08]
lea eax, [ecx+edx*4]
mov esp, ebp
pop ebp
retn 4
ret_bad:
xor eax, eax
mov esp, ebp
pop ebp
retn 4
}
}
void __declspec(naked) CRASH_fix_523295()
{
__asm
{
push 4
push eax
call CheckValid
test eax, eax
jz ret_bad
mov ecx, [ebp-0x0C]
mov dl, [eax]
mov [ecx+0x09], dl
mov eax, [ebp-0x0C]
xor ecx, ecx
mov cl, [eax+0x08]
cmp ecx, 0x17
mov edx, 0x005232A5
jmp edx
ret_bad:
mov edx, 0x005234A3
jmp edx
}
}
void __declspec(naked) CRASH_fix_46AD10()
{
__asm
{
mov edx, [ebp-0x58]
movsx eax, word ptr [edx+0x104]
movsx ecx, word ptr [edx+0x108]
cmp eax, ecx
jle skip_replace
mov word ptr [edx+0x104], cx
skip_replace:
mov edx, [ebp-0x58]
movsx eax, word ptr [edx+0x104]
mov ecx, [ebp-0x20]
sub ecx, [ebp-0x18]
sub ecx, 8
imul eax, ecx
mov edx, [ebp-0x58]
movsx ecx, word ptr [edx+0x108]
cdq
cmp ecx, 0
jz skip_div
idiv ecx
mov [ebp-0x08], eax
jmp retc
skip_div:
mov [ebp-0x08], 0
retc:
cmp [ebp-0x08], 0
mov edx, 0x0046AD3A
jmp edx
}
}
void __declspec(naked) CRASH_fix_420450()
{
__asm
{
push 0x0C
push ecx
call CheckValid
test eax, eax
jz ret_bad
mov edx, [eax+0x08]
mov eax, [ebp+0x08]
shl eax, 8
lea eax, [edx+eax*2]
mov esp, ebp
pop ebp
retn 4
ret_bad:
xor eax, eax
mov esp, ebp
pop ebp
retn 4
}
}
void __declspec(naked) CRASH_fix_45FC3B()
{
__asm
{
push 0x14
push ecx
call CheckValid
test eax, eax
jz ret_bad
mov [ebp-0x10], eax
mov eax, 0x006297E4
cmp [eax], 0
jz loc_45FC4E
mov edx, 0x0045FC47
jmp edx
ret_bad:
loc_45FC4E:
mov edx, 0x0045FC4E
jmp edx
}
}
void __declspec(naked) CRASH_fix_458CF9()
{
__asm
{
push [ebp-0x04]
push [ebp-0x08]
call CheckValidW
test eax, eax
jz ret_bad
push [ebp-0x04]
push [ebp-0x0C]
call CheckValid
test eax, eax
jz ret_bad
push [ebp-0x04]
push [ebp-0x0C]
push [ebp-0x08]
mov edx, 0x00458D05
jmp edx
ret_bad:
xor eax, eax
mov edx, 0x00458D24
jmp edx
}
}
void __declspec(naked) CRASH_fix_4657AD()
{
__asm
{
push 1
push ecx
call CheckValid
test eax, eax
jz ret_bad
movsx edx, byte ptr [eax]
mov [ebp-0x10], edx
mov eax, [ebp-0x28]
add eax, 1
mov [ebp-0x28], eax
mov edx, 0x004657BC
jmp edx
ret_bad:
xor eax, eax
mov edx, 0x0046584C
jmp edx
}
}
void __declspec(naked) CRASH_fix_46B685()
{
__asm
{
push 0x2C
push ecx
call CheckValid
test eax, eax
jz ret_bad
cmp dword ptr [eax+0x28], 0
jle loc_46B698
mov edx, 0x0046B68B
jmp edx
loc_46B698:
mov edx, 0x0046B698
jmp edx
ret_bad:
xor eax, eax
mov edx, 0x0046C246
jmp edx
}
}
void __declspec(naked) shop_init_2(void)
{
_asm
{
mov dword ptr [edx+0x164], 0
mov dword ptr [edx+0x168], 0
mov dword ptr [edx+0x16C], 0
mov dword ptr [edx+0x170], 0
mov dword ptr [edx+0x174], 0
mov dword ptr [edx+0x178], 0
mov dword ptr [edx+0x17C], 0
retn
}
}
void __declspec(naked) CRASH_fix_4BEE2D()
{
__asm
{
call shop_init_2
mov edx, 0x004BEE34
jmp edx
}
}
void __declspec(naked) CRASH_fix_4AAB7E()
{
__asm
{
test ecx, ecx
jz ret_bad
mov edx, [ecx]
mov ecx, [ebp-0x114]
mov ebx, 0x004AAB86
jmp ebx
ret_bad:
mov edx, 0x004AAD31
jmp edx
}
}
void __declspec(naked) CRASH_fix_multiwindow_1()
{
__asm
{
push u_pid_string
lea edx, [ebp-0x230]
push edx
mov edx, 0x0049C15F
jmp edx
}
}
void __declspec(naked) CRASH_fix_multiwindow_2()
{
__asm
{
push u_pid_string
lea ecx, [ebp-0x66C]
push ecx
mov edx, 0x0049C66D
jmp edx
}
}
void __declspec(naked) CRASH_fix_multiwindow_3()
{
__asm
{
push u_pid_string
lea edx, [ebp-0x288]
push edx
mov edx, 0x004B7BA0
jmp edx
}
}
void __declspec(naked) CRASH_fix_multiwindow_4()
{
__asm
{
push u_pid_string_delete
lea ecx, [ebp-0x340]
push ecx
mov edx, 0x0048724A
jmp edx
}
}