-
Notifications
You must be signed in to change notification settings - Fork 4
/
lpdisassembler_doinvoke.inc
245 lines (214 loc) · 10.2 KB
/
lpdisassembler_doinvoke.inc
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
{
Author: Niels A.D
Project: Lape (http://code.google.com/p/la-pe/)
License: GNU Lesser GPL (http://www.gnu.org/licenses/lgpl.html)
This include prints all the invoke related opcodes in the bytecode.
}
{%MainUnit lpdisassembler.pas}
procedure DoIncCall_Stk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Stk(PtrUInt(Code) + ocSize)^ do
begin
_WriteLn('IncCall Stack[StackPos - '+IntToStr(SOffset)+'] '+IntToStr(ParamSize));
_WriteLn('StackDec '+IntToStr(SOffset - ParamSize));
end;
Inc(Code, SizeOf(TOC_Invoke_Stk) + ocSize);
end;
procedure DoIncCall_PStk; {$IFDEF Lape_Inline}inline;{$ENDIF}
var
ParamSize: TParamSize;
begin
ParamSize := PParamSize(PtrUInt(Code) + ocSize)^;
_WriteLn('IncCall (Stack[StackPos - '+IntToStr(ParamSize - SizeOf(Pointer))+'])^ '+IntToStr(ParamSize));
_WriteLn('StackDec '+IntToStr(SizeOf(Pointer)));
Inc(Code, SizeOf(TParamSize) + ocSize);
end;
procedure DoIncCall_Var; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Var(PtrUInt(Code) + ocSize)^ do
_WriteLn('IncCall VarStack[VarStackPos + '+IntToStr(VOffset)+'] '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Var) + ocSize);
end;
procedure DoIncCall_PVar; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_PVar(PtrUInt(Code) + ocSize)^ do
_WriteLn('IncCall (VarStack[VarStackPos + '+IntToStr(VOffset)+'] + '+IntToStr(POffset)+')^ '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_PVar) + ocSize);
end;
procedure DoIncCall_Ptr; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Ptr(PtrUInt(Code) + ocSize)^ do
_WriteLn('IncCall '+IntToStr(Ptr)+' ($' + IntToHex(PCodePos(Ptr)^, 0) + ') ' +IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Ptr) + ocSize);
end;
procedure DoInvokeImported_Stk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Stk(PtrUInt(Code) + ocSize)^ do
begin
_WriteLn('InvokeImportedProc Stack[StackPos - '+IntToStr(SOffset)+'] '+IntToStr(ParamSize));
_WriteLn('StackDec '+IntToStr(SOffset - ParamSize));
end;
Inc(Code, SizeOf(TOC_Invoke_Stk) + ocSize);
end;
procedure DoInvokeImported_PStk; {$IFDEF Lape_Inline}inline;{$ENDIF}
var
ParamSize: TParamSize;
begin
ParamSize := PParamSize(PtrUInt(Code) + ocSize)^;
_WriteLn('InvokeImportedProc (Stack[StackPos - '+IntToStr(ParamSize - SizeOf(Pointer))+'])^ '+IntToStr(ParamSize));
_WriteLn('StackDec '+IntToStr(SizeOf(Pointer)));
Inc(Code, SizeOf(TParamSize) + ocSize);
end;
procedure DoInvokeImported_Var; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Var(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedProc VarStack[VarStackPos + '+IntToStr(VOffset)+'] '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Var) + ocSize);
end;
procedure DoInvokeImported_PVar; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_PVar(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedProc (VarStack[VarStackPos + '+IntToStr(VOffset)+'] + '+IntToStr(POffset)+')^ '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_PVar) + ocSize);
end;
procedure DoInvokeImported_Ptr; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Ptr(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedProc '+IntToStr(Ptr)+' '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Ptr) + ocSize);
end;
procedure DoInvokeImported_Stk_Stk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Stk_Stk(PtrUInt(Code) + ocSize)^ do
begin
_WriteLn('InvokeImportedFunc Stack[StackPos - '+IntToStr(SOffset)+'] Stack[StackPos - '+IntToStr(SOffset)+'] '+IntToStr(ParamSize));
_WriteLn('StackInc '+IntToStr(ParamSize - SOffset + UInt32(StackInc)));
end;
Inc(Code, SizeOf(TOC_Invoke_Stk_Stk) + ocSize);
end;
procedure DoInvokeImported_Stk_PStk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Stk_PStk(PtrUInt(Code) + ocSize)^ do
begin
_WriteLn('InvokeImportedFunc Stack[StackPos - '+IntToStr(SOffset)+'] (Stack[StackPos - '+IntToStr(SOffset)+'])^ '+IntToStr(ParamSize));
_WriteLn('StackInc '+IntToStr(ParamSize - SOffset));
end;
Inc(Code, SizeOf(TOC_Invoke_Stk_PStk) + ocSize);
end;
procedure DoInvokeImported_Stk_Var; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Stk_Var(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc Stack[StackPos - '+IntToStr(SOffset)+'] VarStack[VarStackPos + '+IntToStr(VOffsetD)+'] '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Stk_Var) + ocSize);
end;
procedure DoInvokeImported_Stk_PVar; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Stk_PVar(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc Stack[StackPos - '+IntToStr(SOffset)+'] (VarStack[VarStackPos + '+IntToStr(VOffsetD)+'] + '+IntToStr(POffset)+')^ '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Stk_PVar) + ocSize);
end;
procedure DoInvokeImported_Stk_Ptr; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Stk_Ptr(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc Stack[StackPos - '+IntToStr(SOffset)+'] '+IntToStr(PtrD)+' '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Stk_Ptr) + ocSize);
end;
procedure DoInvokeImported_Var_Stk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Var_Stk(PtrUInt(Code) + ocSize)^ do
begin
_WriteLn('InvokeImportedFunc VarStack[VarStackPos + '+IntToStr(VOffsetS)+'] Stack[StackPos - '+IntToStr(ParamSize)+'] '+IntToStr(ParamSize));
_WriteLn('StackInc '+IntToStr(StackInc));
end;
Inc(Code, SizeOf(TOC_Invoke_Var_Stk) + ocSize);
end;
procedure DoInvokeImported_Var_PStk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Var_PStk(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc VarStack[VarStackPos + '+IntToStr(VOffsetS)+'] (Stack[StackPos - '+IntToStr(ParamSize)+'])^ '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Var_PStk) + ocSize);
end;
procedure DoInvokeImported_Var_Var; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Var_Var(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc VarStack[VarStackPos + '+IntToStr(VOffsetS)+']) VarStack[VarStackPos + '+IntToStr(VOffsetD)+'] '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Var_Var) + ocSize);
end;
procedure DoInvokeImported_Var_PVar; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Var_PVar(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc VarStack[VarStackPos + '+IntToStr(VOffsetS)+'] (VarStack[VarStackPos + '+IntToStr(VOffsetD)+'] + '+IntToStr(POffset)+')^ '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Var_PVar) + ocSize);
end;
procedure DoInvokeImported_Var_Ptr; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Var_Ptr(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc VarStack[VarStackPos + '+IntToStr(VOffsetS)+'] '+IntToStr(PtrD)+' '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Var_Ptr) + ocSize);
end;
procedure DoInvokeImported_PVar_Stk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_PVar_Stk(PtrUInt(Code) + ocSize)^ do
begin
_WriteLn('InvokeImportedFunc (VarStack[VarStackPos + '+IntToStr(VOffsetS)+'] + '+IntToStr(POffsetS)+')^ Stack[StackPos - '+IntToStr(ParamSize)+'] '+IntToStr(ParamSize));
_WriteLn('StackInc '+IntToStr(StackInc));
end;
Inc(Code, SizeOf(TOC_Invoke_PVar_Stk) + ocSize);
end;
procedure DoInvokeImported_PVar_PStk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_PVar_PStk(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc (VarStack[VarStackPos + '+IntToStr(VOffsetS)+'] + '+IntToStr(POffsetS)+')^ (Stack[StackPos - '+IntToStr(ParamSize)+'])^ '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_PVar_PStk) + ocSize);
end;
procedure DoInvokeImported_PVar_Var; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_PVar_Var(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc (VarStack[VarStackPos + '+IntToStr(VOffsetS)+'] + '+IntToStr(POffsetS)+')^ VarStack[VarStackPos + '+IntToStr(VOffsetD)+'] '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_PVar_Var) + ocSize);
end;
procedure DoInvokeImported_PVar_PVar; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_PVar_PVar(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc (VarStack[VarStackPos + '+IntToStr(VOffsetS)+'] + '+IntToStr(POffsetS)+')^ (VarStack[VarStackPos + '+IntToStr(VOffsetD)+'] + '+IntToStr(POffsetD)+')^ '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_PVar_PVar) + ocSize);
end;
procedure DoInvokeImported_PVar_Ptr; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_PVar_Ptr(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc (VarStack[VarStackPos + '+IntToStr(VOffsetS)+'] + '+IntToStr(POffsetS)+')^ '+IntToStr(PtrD)+' '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_PVar_Ptr) + ocSize);
end;
procedure DoInvokeImported_Ptr_Stk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Ptr_Stk(PtrUInt(Code) + ocSize)^ do
begin
_WriteLn('InvokeImportedFunc '+IntToStr(PtrS)+' Stack[StackPos - '+IntToStr(ParamSize)+'] '+IntToStr(ParamSize));
_WriteLn('StackInc '+IntToStr(StackInc));
end;
Inc(Code, SizeOf(TOC_Invoke_Ptr_Stk) + ocSize);
end;
procedure DoInvokeImported_Ptr_PStk; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Ptr_PStk(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc '+IntToStr(PtrS)+' (Stack[StackPos - '+IntToStr(ParamSize)+'])^ '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Ptr_PStk) + ocSize);
end;
procedure DoInvokeImported_Ptr_Var; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Ptr_Var(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc '+IntToStr(PtrS)+' VarStack[VarStackPos + '+IntToStr(VOffsetD)+'] '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Ptr_Var) + ocSize);
end;
procedure DoInvokeImported_Ptr_PVar; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Ptr_PVar(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc '+IntToStr(PtrS)+' (VarStack[VarStackPos + '+IntToStr(VOffsetD)+'] + '+IntToStr(POffset)+')^ '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Ptr_PVar) + ocSize);
end;
procedure DoInvokeImported_Ptr_Ptr; {$IFDEF Lape_Inline}inline;{$ENDIF}
begin
with POC_Invoke_Ptr_Ptr(PtrUInt(Code) + ocSize)^ do
_WriteLn('InvokeImportedFunc '+IntToStr(PtrS)+' '+IntToStr(PtrD)+' '+IntToStr(ParamSize));
Inc(Code, SizeOf(TOC_Invoke_Ptr_Ptr) + ocSize);
end;