-
Notifications
You must be signed in to change notification settings - Fork 20
/
Def_know.pas
348 lines (313 loc) · 9.8 KB
/
Def_know.pas
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
unit Def_know;
(*
ModuleDataTable
---------------
//Ñîñòîèò èç ModuleCount çàïèñåé âèäà
WORD ID;
PSTR ModuleName;
PSTR Filename;
WORD UsesNum;
WORD UsesID[UsesNum]; //Ìàññèâ èäåíòèôèêàòîðîâ ìîäóëåé
PSTR UsesNames[UsesNum]; //Ìàññèâ èìåí ìîäóëåé
ConstDataTable
--------------
//Ñîñòîèò èç ModuleCount çàïèñåé âèäà
WORD ModuleID;
PSTR ConstName;
BYTE Type; //'C'-ConstDecl, 'P'-PDecl (VMT), 'V'-VarCDecl
PSTR TypeDef; //Òèï
PSTR Value; //Çíà÷åíèå
DWORD DumpTotal; //Îáùèé ðàçìåð äàìïà (äàìï+ðåëîêè+ôèêñàïû)
DWORD DumpSize; //Ðàçìåð áèíàðíîãî äàìïà (RTTI)
DWORD FixupNum; //Êîëè÷åñòâî ôèêñàïîâ äàìïà
BYTE Dump[DumpSize]; //Áèíàðíûé äàìï (RTTI)
BYTE Relocs[DumpSize];
FIXUPINFO Fixups[FixupNum]; //Ìàññèâ ôèêñàïîâ
TypeDataTable
-------------
//Ñîñòîèò èç TypeCount çàïèñåé âèäà
DWORD Size; //Size of Type
WORD ModuleID;
PSTR TypeName;
BYTE Kind; //drArrayDef,...,drVariantDef (ñì. íà÷àëî)
DWORD VMCnt; //Êîëè÷åñòâî ýëåìåíòîâ VMT (íà÷èíàÿ ñ 0)
PSTR Decl; //Äåêëàðàöèÿ
DWORD DumpTotal; //Îáùèé ðàçìåð äàìïà (äàìï+ðåëîêè+ôèêñàïû)
DWORD DumpSize; //Ðàçìåð áèíàðíîãî äàìïà (RTTI)
DWORD FixupNum; //Êîëè÷åñòâî ôèêñàïîâ äàìïà
BYTE Dump[DumpSize]; //Áèíàðíûé äàìï (RTTI)
BYTE Relocs[DumpSize];
FIXUPINFO Fixups[FixupNum]; //Ôèêñàïû
DWORD FieldsTotal; //Îáùèé ðàçìåð äàííûõ ïîëåé
WORD FieldsNum; //Êîëè÷åñòâî ïîëåé (class, interface, record)
FIELDINFO Fields[FieldNum]; //Ïîëÿ
DWORD PropsTotal; //Îáùèé ðàçìåð äàííûõ ñâîéñòâ
WORD PropsNum; //Êîëè÷åñòâî ñâîéñòâ (class, interface)
PROPERTYINFO Props[PropNum]; //Ñâîéñòâà
DWORD MethodsTotal; //Îáùèé ðàçìåð äàííûõ ìåòîäîâ
WORD MethodsNum; //Êîëè÷åñòâî ìåòîäîâ (class, interface)
METHODINFO Methods[MethodNum]; //Ìåòîäû
VarDataTable
------------
//Ñîñòîèò èç VarCount çàïèñåé âèäà
WORD ModuleID;
PSTR VarName;
BYTE Type; //'V'-Var;'A'-AbsVar;'S'-SpecVar;'T'-ThreadVar
PSTR TypeDef;
PSTR AbsName; //Äëÿ êëþ÷åâîãî ñëîâà absolute
ResStrDataTable
---------------
//Ñîñòîèò èç ResStrCount çàïèñåé âèäà
WORD ModuleID;
PSTR ResStrName;
PSTR TypeDef;
PSTR Context;
ProcDataTable
-------------
//Contains ProcCount structures:
WORD ModuleID;
PSTR ProcName;
BYTE Embedded; //Contains embedded procs
BYTE DumpType; //'C' - code, 'D' - data
BYTE MethodKind; //'M'-method,'P'-procedure,'F'-function,'C'-constructor,'D'-destructor
BYTE CallKind; //1-'cdecl', 2-'pascal', 3-'stdcall', 4-'safecall'
int VProc; //Flag for "overload" (if Delphi version > verD3 and VProc&0x1000 != 0)
PSTR TypeDef; //Type of Result for function
DWORD DumpTotal; //Total size of dump (dump+relocs+fixups)
DWORD DumpSz; //Dump size
DWORD FixupNum; //Dump fixups number
BYTE Dump[DumpSz]; //Binary dump
BYTE Relocs[DumpSize];
FIXUPINFO Fixups[FixupNum]; //Fixups
DWORD ArgsTotal; //Total size of arguments
WORD ArgsNum; //Arguments number
ARGINFO Args[ArgNum]; //Arguments
DWORD LocalsTotal; //Total size of local vars
WORD LocalsNum; //Local vars number
LOCALINFO Locals[LocalNum]; //Local vars
*)
interface
Uses Classes;
Type
// Flags about validity of the class info structures
TInfoFlags = (
INFO_DUMP, // 1;
INFO_ARGS, // 2;
INFO_LOCALS, // 4;
INFO_FIELDS, // 8;
INFO_PROPS, // 16;
INFO_METHODS, // 32;
INFO_ABSNAME // 64;
);
TInfoFlagSet = set of TInfoFlags;
TKBsection = (
//Sections of the Knowledge Base
//KB_NO_SECTION = 0;
KB_CONST_SECTION, // 1;
KB_TYPE_SECTION, // 2;
KB_VAR_SECTION, // 4;
KB_RESSTR_SECTION, // 8;
KB_PROC_SECTION // 16;
);
TKBset = set of TKBsection;
// Information about offsets of names and data
OffsetInfo = record
Offset,
Size,
ModId, //Modules
NamId:Integer; //Names
End;
POffsetInfo = ^OffsetInfo;
ArrOffsetInfo = Array Of OffsetInfo;
//Fixup info
FixupInfo = record
_Type:Byte; //'A' - ADR, 'J' - JMP, 'D' - DAT
Ofs:Integer; //Offset relative to the beginning of dump
Name:PAnsiChar;
End;
PFixupInfo = ^FixupInfo;
FieldInfo = class
//FIELDINFO():xrefs(0){}
//~FIELDINFO();
Scope:Byte; //9-private, 10-protected, 11-public, 12-published
Offset:Integer; //Offset in class instance
_Case:Integer; //case for record types (0xFFFFFFFF for the rest)
Name:AnsiString; //Field name
_Type:AnsiString; //Field type
xrefs:TList; //XRefs to this field from the CODE section
Constructor Create;
Destructor Destroy; Override;
End;
//PFieldInfo = ^FieldInfo;
PropInfo = record
Scope:Byte; //9-private, 10-protected, 11-public, 12-published
Index:Integer; //readonly, writeonly depending on bits 1 and 2
DispID:Integer; //???
Name:AnsiString; //Field name
TypeDef:AnsiString; //Field type
ReadName:AnsiString; //Name of getter method, or member field
WriteName:AnsiString; //Name of setter method, or member field
StoredName:AnsiString; //Name of method to check DEFAULT, or the boolean value itself
end;
PPropInfo = ^PropInfo;
MethodInfo = Record
Scope:Byte; //9-private, 10-protected, 11-public, 12-published
MethodKind:Byte; //'M'-method, 'P'-procedure, 'F'-function, 'C'-constructor, 'D'-destructor
Prototype:AnsiString; //Prototype full name
End;
PMethodInfo = ^MethodInfo;
ArgInfo = Record
Tag:Byte; //0x21-"val", 0x22-"var"
in_Reg:Boolean; //If true - argument is in register, else - in stack
Ndx:Integer; //Register number and offset (XX-number, XXXXXX-offset) (0-EAX, 1-ECX, 2-EDX)
Size:Integer; //Argument Size
Name:AnsiString; //Argument Name
TypeDef:AnsiString; //Argument Type
end;
PArgInfo = ^ArgInfo;
LocalInfo = Record
Ofs:Integer; //Offset of local var (from ebp or EP)
Size:Integer; //Size of local var
Name:AnsiString; //Local var Name
TypeDef:AnsiString; //Local var Type
end;
PLocalInfo = ^LocalInfo;
XrefRec = record
_type:Char; //'C'-call; 'J'-jmp; 'D'-data
adr:Integer; //address of procedure
offset:Integer; //offset in procedure
End;
PXrefRec = ^XrefRec;
MConstInfo = record
//public
ModuleID:WORD;
ConstName:AnsiString;
_Type:Byte; //'C'-ConstDecl, 'P'-PDecl (VMT), 'V'-VarCDecl
TypeDef:AnsiString;
Value:AnsiString;
DumpSz, //Size of the binary dump
FixupNum:Integer; //Number of fixups
Dump:PAnsiChar; //Binary dump
//Constructor Create;
end;
PMConstInfo = ^MConstInfo;
MTypeInfo = record
//public
Size:Integer;
ModuleID:WORD;
TypeName:AnsiString;
Kind:Byte; //drArrayDef,...,drVariantDef
VMCnt:WORD; //Number of elements in VMT (indexed from 0)
Decl:AnsiString; //Declaration
DumpSz, //Binary dump size
FixupNum:Integer; //Binary dump fixup number
Dump:PAnsiChar; //Binary dump
FieldsNum:WORD; //Number of fields (class, interface, record)
Fields:PAnsiChar;
PropsNum:WORD; //Number of properties (class, interface)
Props:PAnsiChar;
MethodsNum:WORD; //Number of methods (class, interface)
Methods:PAnsiChar;
//Constructor Create;
end;
PMTypeInfo = ^MTypeInfo;
MVarInfo = record
//public
ModuleID:WORD;
VarName:AnsiString;
_Type:Byte; //'V'-Var;'A'-AbsVar;'S'-SpecVar;'T'-ThreadVar
TypeDef:AnsiString;
AbsName:AnsiString; //for the "absolute" keyword
//Constructor Create;
end;
PMVarInfo = ^MVarInfo;
MResStrInfo = record
//public
ModuleID:WORD;
ResStrName:AnsiString;
TypeDef:AnsiString;
//Context:AnsiString;
//Constructor Create;
end;
PMResInfo = ^MResStrInfo;
MProcInfo = record
//public
ModuleID:WORD;
ProcName:AnsiString;
Embedded:Boolean; //true = contains nested procedures
DumpType:Char; //'C' - code, 'D' - data
MethodKind:Char; //'M'-method,'P'-procedure,'F'-function,'C'-constructor,'D'-destructor
CallKind:Byte; //1-'cdecl', 2-'pascal', 3-'stdcall', 4-'safecall'
VProc:Integer; //flag for "overload" (åñëè âåðñèÿ Äåëüôè > verD3 è VProc&0x1000 != 0)
TypeDef:AnsiString;
DumpSz, //Ðàçìåð áèíàðíîãî äàìïà
FixupNum:Integer; //Êîëè÷åñòâî ôèêñàïîâ äàìïà
Dump:PAnsiChar; //Áèíàðíûé äàìï (âêëþ÷àåò â ñåáÿ ñîáñòâåííî äàìï, ðåëîêè è ôèêñàïû)
ArgsNum:WORD; //Êîëè÷åñòâî àðãóìåíòîâ ïðîöåäóðû
Args:Pointer; //Ñïèñîê àðãóìåíòîâ
//LocalsNum:WORD; //Êîëè÷åñòâî ëîêàëüíûõ ïåðåìåííûõ ïðîöåäóðû
//Locals:Pointer; //Ñïèñîê ëîêàëüíûõ ïåðåìåííûõ
//Constructor Create;
end;
PMProcInfo = ^MProcInfo;
Const
SCOPE_TMP = 32; // Temp struct FIELDINFO, to be deleted
// Description of the Kind values
drArrayDef = $4C; //'L'
drClassDef = $46; //'F'
drFileDef = $4F; //'O'
drFloatDef = $49; //'I'
drInterfaceDef = $54; //'T'
drObjVMTDef = $47; //'G'
drProcTypeDef = $48; //'H'
drPtrDef = $45; //'E'
drRangeDef = $44; //'D'
drRecDef = $4D; //'M'
drSetDef = $4A; //'J'
drShortStrDef = $4B; //'K'
drStringDef = $52; //'R'
drTextDef = $50; //'P'
drVariantDef = $53; //'S'
drAliasDef = $41; //'Z'
//Var Type field
VT_VAR = 'V';
VT_ABSVAR = 'A';
VT_SPECVAR = 'S';
VT_THREADVAR = 'T';
implementation
Constructor FieldInfo.Create;
Begin
xrefs:=TList.Create;
end;
Destructor FieldInfo.Destroy;
var
i:Integer;
Begin
for i:=0 to xrefs.Count-1 do
Dispose(PXRefRec(xrefs[i]));
xrefs.Free;
end;
(*
Constructor MConstInfo.Create;
Begin
ModuleID:=$FFFF;
end;
Constructor MTypeInfo.Create;
Begin
ModuleID:=$FFFF;
Kind:=255;
end;
Constructor MVarInfo.Create;
Begin
ModuleID:=$FFFF;
end;
Constructor MResStrInfo.Create;
Begin
ModuleID:=$FFFF;
end;
Constructor MProcInfo.Create;
Begin
ModuleID:=$FFFF;
end;
*)
end.