-
Notifications
You must be signed in to change notification settings - Fork 4
/
d2_112a_asm.S
260 lines (215 loc) · 5.27 KB
/
d2_112a_asm.S
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
.globl _merc_inventory_modify_112a
_merc_inventory_modify_112a:
mov %eax, 4(%esp)
jmp _merc_inventory_modify@4
.globl _merc_store_location_112a
_merc_store_location_112a:
mov 0x10(%esp), %eax
movzbl 1(%eax), %ecx /* stuffed in client. */
mov %cl, (_last_chosen_loc)
ret
.globl _merc_loc_check_item_game_112a
_merc_loc_check_item_game_112a:
/* ebp = unit */
/* 0x30+4(%esp) = item */
/* ebx = old item */
/* ecx = destination location */
/* eax = other item */
/* edx = other location */
mov %ecx, 0x2C+4(%esp)
movzbl (_last_chosen_loc), %ecx
test %ecx, %ecx
jnz 1f
pushal
lea 4*5/*edx*/(%esp), %edx /* othloc pointer */
lea 4*7/*eax*/(%esp), %eax /* othitem pointer */
lea 4*6/*ecx*/(%esp), %ecx /* loc pointer */
lea 4*4/*ebx*/(%esp), %ebx /* olditem pointer */
push %edx
push %eax
push %ecx
push %ebx
pushl 4*4+4*8+0x30+4(%esp) /* item */
push %ebp /* unit */
call _merc_choose_item_loc@24
popal
jmp 2f
1:
mov %ebp, 0x14+4(%esp)
cmp %ecx, %edx
jne 2f
mov 0x2C+4(%esp), %edx
xchg %ebx, %eax
2:
mov %ecx, 0x14+4(%esp)
pushal
lea 4*8+0x2C+4(%esp), %edi
push %edi /* remove_item ptr */
push %edx /* othloc */
push %eax /* othitem */
push %ecx /* loc */
push %ebx /* olditem */
push 4*5+4*8+0x30+4(%esp) /* item */
push %ebp /* unit */
call _merc_check_item_remove@28
neg %eax
popal
mov 0x2C+4(%esp), %ebx
jl 1f /* allow */
jnz 2f /* Force deny */
/* Passthrough */
mov %eax, 0x14+4(%esp)
cmpl $0x167, 4(%ebp)
ret
1: /* allow */
addl $0x9a5a2-0x9a572, (%esp)
ret
2: /* Force deny */
addl $0x9a62a-0x9a572, (%esp)
ret
.globl _merc_check_item_compat_112a
_merc_check_item_compat_112a:
/* smashable: ebx, esi, edi, ebp */
/* stack: esp+4 = unit, esp+8 = other_location */
/* edi = unit */
/* edx = item to equip */
/* eax = equipped item */
/* ecx = other item */
/* esi = destination location */
/* ebp = other location */
mov 4(%esp), %edi
push %eax /* save equipped item */
push %ecx /* anti-clobber */
push %edx
push %ebp /* other location */
push %ecx /* other item */
push %esi /* destination location */
push %eax /* equipped item */
push %edx /* item */
push %edi /* unit */
call _merc_check_item_compat@24
pop %edx /* anti-clobber */
pop %ecx
neg %eax
jl 1f /* force allow */
jnz 1f /* force deny */
/* passthrough */
pop %eax /* restore equipped item */
jmp *(_original_merc_check_item_compat_112a)
1:
and $1, %eax
add $4, %esp /* don't need stored equipped item */
ret $0x8
.globl _merc_check_item_class_112a
_merc_check_item_class_112a:
/* smashable: ebx, esi */
/* stack: item (arg to class req getter) */
/* edi = item */
pushal
push %edi
call *(_item_get_required_class)
mov %eax, 4*7(%esp) /* for passthrough */
/* edi = item */
/* ebp = unit */
/* eax = required class (after call above) */
push %eax /* required class */
push %edi /* item */
push %ebp /* unit */
call _merc_check_item_class@12
neg %eax
popal
jl 1f /* force allow */
jnz 2f /* force deny */
/* passthrough */
ret $4
1: /* force allow */
mov $7, %eax
ret $4
2: /* force deny */
xor %ebp, %ebp
ret $4
.globl _merc_check_item_game_drop_112a
_merc_check_item_game_drop_112a:
/* stack: item $3 */
/* esi = item */
/* edi = merc */
/* smashable: (nothing) */
pushal
push %esi /* item */
call *(_item_get_required_class)
push %eax /* required class */
push %esi /* item */
push %edi /* unit */
call _merc_check_item_class@12
neg %eax
popal
jl 1f /* force allow */
jnz 2f /* force deny */
/* passthrough */
jmp *(_item_check_type)
1: /* force allow */
addl $0x9b290-0x9b1d7, (%esp)
mov $1, %ebx
ret $8
2: /* force deny */
addl $0x9b290-0x9b1d7, (%esp)
xor %ebx, %ebx
ret $8
.globl _merc_check_item_client_112a
_merc_check_item_client_112a:
/* stack: item $3 */
/* ebx = item */
/* ebp = merc */
/* smashable: esi, ecx */
pushal
push %ebx
call *(_item_get_required_class)
push %eax /* required class */
push %ebx /* item */
push %ebp /* unit */
call _merc_check_item_class@12
neg %eax
popal
jl 1f /* force allow */
jnz 2f /* force deny */
/* passthrough */
jmp *(_item_check_type)
1: /* force allow */
addl $0xa931f-0xa929b, (%esp)
mov $1, %esi
ret $8
2: /* force deny */
addl $0xa931f-0xa929b, (%esp)
xor %esi, %esi
ret $8
.globl _merc_check_item_client_drop_112a
_merc_check_item_client_drop_112a:
/* stack: item $3 */
/* edi = item */
/* ebx = merc id */
/* smashable: ecx, esi, ebp */
pushal
push %edi
call *(_item_get_required_class)
push %eax /* required class */
push %edi /* item */
push %ebx /* merc id */
call _merc_check_item_class_from_id@12
neg %eax
popal
jl 1f /* force allow */
jnz 2f /* force deny */
/* passthrough */
jmp *(_item_check_type)
1: /* force allow */
addl $0xbe1b0-0xbe06f, (%esp)
mov $1, %ebp
ret $8
2: /* force deny */
addl $0xbe1cf-0xbe06f, (%esp)
xor %ebp, %ebp
ret $8
.global _merc_inventory_mpq_load_112a
_merc_inventory_mpq_load_112a:
call _merc_inventory_mpq_load@0
ret $8