-
Notifications
You must be signed in to change notification settings - Fork 227
/
Misc.h
191 lines (189 loc) · 9.92 KB
/
Misc.h
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
//---------------------------------------------------------------------------
#ifndef MiscH
#define MiscH
//---------------------------------------------------------------------------
#include <Clipbrd.hpp>
#include "Decompiler.h"
//---------------------------------------------------------------------------
//Float Type
#define FT_SINGLE 1
#define FT_DOUBLE 2
#define FT_EXTENDED 3
#define FT_REAL 4
#define FT_COMP 5
#define FT_CURRENCY 6
//---------------------------------------------------------------------------
typedef struct
{
int Offset;
int Size;
String Name;
String Type;
} FIELD_INFO, *PFIELD_INFO;
//Add by ZGL-----------------------------------------------------------------
class TUnicodeClipboard : public TClipboard
{
private:
WideString __fastcall GetAsUnicodeText();
void __fastcall SetAsUnicodeText(const WideString Value);
public:
__property WideString AsUnicodeText = {read=GetAsUnicodeText, write=SetAsUnicodeText};
};
//---------------------------------------------------------------------------
//global API
void __fastcall ScaleForm(TForm* AForm);
int __fastcall Adr2Pos(DWORD adr);
String __fastcall Val2Str0(DWORD Val);
String __fastcall Val2Str1(DWORD Val);
String __fastcall Val2Str2(DWORD Val);
String __fastcall Val2Str4(DWORD Val);
String __fastcall Val2Str5(DWORD Val);
String __fastcall Val2Str8(DWORD Val);
DWORD __fastcall Pos2Adr(int Pos);
PInfoRec __fastcall AddToBSSInfos(DWORD Adr, String AName, String ATypeName);
void __fastcall AddClassAdr(DWORD Adr, const String& AName);
void __fastcall AddFieldXref(PFIELDINFO fInfo, DWORD ProcAdr, int ProcOfs, char type);
void __fastcall AddPicode(int Pos, BYTE Op, String Name, int Ofs);
int __fastcall BranchGetPrevInstructionType(DWORD fromAdr, DWORD* jmpAdr, PLoopInfo loopInfo);
bool __fastcall CanReplace(const String& fromName, const String& toName);
void __fastcall ClearFlag(DWORD flag, int pos);
void __fastcall ClearFlags(DWORD flag, int pos, int num);
void __fastcall Copy2Clipboard(TStrings* items, int leftMargin, bool asmCode);
String __fastcall ExtractClassName(const String& AName);
String __fastcall ExtractProcName(const String& AName);
String __fastcall ExtractName(const String& AName);
String __fastcall ExtractType(const String& AName);
void __fastcall FillArgInfo(int k, BYTE callkind, PARGINFO argInfo, BYTE** p, int* s);
DWORD __fastcall FindClassAdrByName(const String& AName);
int __fastcall FloatNameToFloatType(String AName);
String __fastcall GetArrayElementType(String arrType);
int __fastcall GetArrayElementTypeSize(String arrType);
bool __fastcall GetArrayIndexes(String arrType, int ADim, int* LowIdx, int* HighIdx);
int __fastcall GetArraySize(String arrType);
DWORD __fastcall GetChildAdr(DWORD Adr);
DWORD __fastcall GetClassAdr(const String& AName);
int __fastcall GetClassSize(DWORD adr);
String __fastcall GetClsName(DWORD adr);
String __fastcall GetDefaultProcName(DWORD adr);
String __fastcall GetDynaInfo(DWORD adr, WORD id, DWORD* dynAdr);
String __fastcall GetDynArrayTypeName(DWORD adr);
String __fastcall GetEnumerationString(String TypeName, Variant Val);
String __fastcall GetImmString(int Val);
String __fastcall GetImmString(String TypeName, int Val);
PInfoRec __fastcall GetInfoRec(DWORD adr);
int __fastcall GetLastLocPos(int fromAdr);
String __fastcall GetModuleVersion(const String& module);
int __fastcall GetNearestArgA(int fromPos);
int __fastcall GetNearestDownInstruction(int fromPos);
int __fastcall GetNearestDownInstruction(int fromPos, char* Instruction);
int __fastcall GetNearestUpPrefixFs(int fromPos);
int __fastcall GetNearestUpInstruction(int fromPos);
int __fastcall GetNthUpInstruction(int fromPos, int N);
int __fastcall GetNearestUpInstruction(int fromPos, int toPos);
int __fastcall GetNearestUpInstruction(int fromPos, int toPos, int no);
int __fastcall GetNearestUpInstruction1(int fromPos, int toPos, char* Instruction);
int __fastcall GetNearestUpInstruction2(int fromPos, int toPos, char* Instruction1, char* Instruction2);
DWORD __fastcall GetParentAdr(DWORD Adr);
String __fastcall GetParentName(DWORD adr);
String __fastcall GetParentName(const String& ClassName);
int __fastcall GetParentSize(DWORD Adr);
int __fastcall GetProcRetBytes(MProcInfo* pInfo);
int __fastcall GetProcSize(DWORD fromAdr);
int __fastcall StrGetRecordSize(String str);
int __fastcall StrGetRecordFieldOffset(String str);
String __fastcall StrGetRecordFieldName(String str);
String __fastcall StrGetRecordFieldType(String str);
int __fastcall GetRecordSize(String AName);
String __fastcall GetRecordFields(int AOfs, String AType);
String __fastcall GetAsmRegisterName(int Idx);
String __fastcall GetDecompilerRegisterName(int Idx);
String __fastcall GetSetString(String TypeName, BYTE* ValAdr);
DWORD __fastcall GetStopAt(DWORD vmtAdr);
DWORD __fastcall GetOwnTypeAdr(String AName);
PTypeRec __fastcall GetOwnTypeByName(String AName);
String __fastcall GetTypeDeref(String ATypeName);
BYTE __fastcall GetTypeKind(DWORD Adr);
BYTE __fastcall GetTypeKind(String AName, int* size);
int __fastcall GetRTTIRecordSize(DWORD adr);
int __fastcall GetPackedTypeSize(String AName);
String __fastcall GetTypeName(DWORD TypeAdr);
int __fastcall GetTypeSize(String AName);
bool __fastcall IsADC(int Idx);
int __fastcall IsBoundErr(DWORD fromAdr);
bool __fastcall IsConnected(DWORD fromAdr, DWORD toAdr);
bool __fastcall IsBplByExport(const char* bpl);
bool __fastcall IsDefaultName(String AName);
DWORD __fastcall IsGeneralCase(DWORD fromAdr, int retAdr);
bool __fastcall IsExit(DWORD fromAdr);
bool __fastcall IsInheritsByAdr(const DWORD Adr1, const DWORD Adr2);
bool __fastcall IsInheritsByClassName(const String& Name1, const String& Name2);
bool __fastcall IsInheritsByProcName(const String& Name1, const String& Name2);
int __fastcall IsInitStackViaLoop(DWORD fromAdr, DWORD toAdr);
bool __fastcall IsSameRegister(int Idx1, int Idx2);
int __fastcall IsCopyDynArrayToStack(DWORD fromAdr);
bool __fastcall IsValidCodeAdr(DWORD Adr);
bool __fastcall IsValidCString(int pos);
bool __fastcall IsValidImageAdr(DWORD Adr);
bool __fastcall IsValidModuleName(int len, int pos);
bool __fastcall IsValidName(int len, int pos);
bool __fastcall IsValidString(int len, int pos);
bool __fastcall IsXorMayBeSkipped(DWORD fromAdr);
void __fastcall MakeGvar(PInfoRec recN, DWORD adr, DWORD xrefAdr);
String __fastcall MakeGvarName(DWORD adr);
void __fastcall OutputDecompilerHeader(FILE* f);
bool __fastcall IsFlagSet(DWORD flag, int pos);
void __fastcall SetFlag(DWORD flag, int pos);
void __fastcall SetFlags(DWORD flag, int pos, int num);
int __fastcall SortUnitsByAdr(void *item1, void* item2);
int __fastcall SortUnitsByNam(void *item1, void* item2);
int __fastcall SortUnitsByOrd(void *item1, void* item2);
bool __fastcall LineContainsShadowName(String line);
int __fastcall GetAdrOfsFromShadowName(String name);
String __fastcall SanitizeName(String name);
String __fastcall TransformShadowName(String name, BYTE typeKind, DWORD typeAdr);
String __fastcall TransformString(char* str, int len);
String __fastcall TransformUString(WORD codePage, wchar_t* data, int len);
String __fastcall TrimTypeName(const String& TypeName);
String __fastcall TypeKind2Name(BYTE kind);
//String __fastcall UnmangleName(String Name);
//Decompiler
int __fastcall IsAbs(DWORD fromAdr);
int _fastcall IsIntOver(DWORD fromAdr);
int __fastcall IsInlineLengthCmp(DWORD fromAdr);
int __fastcall IsInlineLengthTest(DWORD fromAdr);
int __fastcall IsInlineDiv(DWORD fromAdr, int* div);
int __fastcall IsInlineMod(DWORD fromAdr, int* mod);
int __fastcall ProcessInt64Equality(DWORD fromAdr, DWORD* maxAdr);
int __fastcall ProcessInt64NotEquality(DWORD fromAdr, DWORD* maxAdr);
int __fastcall ProcessInt64Comparison(DWORD fromAdr, DWORD* maxAdr);
int __fastcall ProcessInt64ComparisonViaStack1(DWORD fromAdr, DWORD* maxAdr);
int __fastcall ProcessInt64ComparisonViaStack2(DWORD fromAdr, DWORD* maxAdr);
int __fastcall IsInt64Equality(DWORD fromAdr, int* skip1, int* skip2, bool *immVal, __int64* Val);
int __fastcall IsInt64NotEquality(DWORD fromAdr, int* skip1, int* skip2, bool *immVal, __int64* Val);
int __fastcall IsInt64Comparison(DWORD fromAdr, int* skip1, int* skip2, bool *immVal, __int64* Val);
int __fastcall IsInt64ComparisonViaStack1(DWORD fromAdr, int* skip1, DWORD* simEnd);
int __fastcall IsInt64ComparisonViaStack2(DWORD fromAdr, int* skip1, int* skip2, DWORD* simEnd);
int __fastcall IsInt64Shr(DWORD fromAdr);
int __fastcall IsInt64Shl(DWORD fromAdr);
String __fastcall InputDialogExec(String caption, String labelText, String text);
String __fastcall ManualInput(DWORD procAdr, DWORD curAdr, String caption, String labelText);
bool __fastcall MatchCode(BYTE* code, MProcInfo* pInfo);
void __fastcall SaveCanvas(TCanvas* ACanvas);
void __fastcall RestoreCanvas(TCanvas* ACanvas);
void __fastcall DrawOneItem(String AItem, TCanvas* ACanvas, TRect &ARect, TColor AColor, int flags);
int __fastcall IsTryBegin(DWORD fromAdr, DWORD* endAdr);
int __fastcall IsTryBegin0(DWORD fromAdr, DWORD* endAdr);
int __fastcall IsTryEndPush(DWORD fromAdr, DWORD* endAdr);
int __fastcall IsTryEndJump(DWORD fromAdr, DWORD* endAdr);
PFIELDINFO __fastcall GetClassField(String TypeName, int Offset);
int __fastcall GetRecordField(String ARecType, int AOfs, String& name, String& type);
int __fastcall GetField(String TypeName, int Offset, String& name, String& type);
int __fastcall ArgsCmpFunction(void *item1, void *item2);
int __fastcall ExportsCmpFunction(void *item1, void *item2);
int __fastcall FieldInfoCmpFunction(void* item1, void* item2);
int __fastcall FieldsCmpFunction(void *item1, void *item2);
int __fastcall ImportsCmpFunction(void *item1, void *item2);
int __fastcall LocalsCmpFunction(void *item1, void *item2);
int __fastcall MethodsCmpFunction(void *item1, void *item2);
//---------------------------------------------------------------------------
#endif