IDA C++ SDK 9.2
Loading...
Searching...
No Matches
demangle.hpp
Go to the documentation of this file.
1/*
2 * CPP/D/Swift Demangler.
3 * Copyright (c) 2000-2018 by Iouri Kharon.
4 * E-mail: yjh@styx.cabel.net
5 *
6 * ALL RIGHTS RESERVED.
7 *
8 */
9
10#ifndef _DEMANGLE_HPP
11#define _DEMANGLE_HPP
12
13// int32 result code
14#define ME_INTERR -1
15#define ME_PARAMERR -2
16#define ME_ILLSTR -3
17#define ME_SMALLANS -4
22#define ME_FRAME -5
24#define ME_NOCOMP -6
25#define ME_ERRAUTO -7
26#define ME_NOHASHMEM -8
27#define ME_NOSTRMEM -9
28
29#define ME_NOERROR_LIMIT -10
32
33#define M_PRCMSK 0x0000000F
34#define MT_DEFAULT 0x00000001
35#define MT_CDECL 0x00000002
36#define MT_PASCAL 0x00000003
37#define MT_STDCALL 0x00000004
38#define MT_FASTCALL 0x00000005
39#define MT_THISCALL 0x00000006
40#define MT_FORTRAN 0x00000007
41#define MT_SYSCALL 0x00000008
42#define MT_INTERRUPT 0x00000009
43#define MT_MSFASTCALL 0x0000000A
44#define MT_CLRCALL 0x0000000B
45#define MT_DMDCALL 0x0000000C
46#define MT_VECTORCALL 0x0000000D
47#define MT_REGCALL 0x0000000E
48
49// reserved
50#define MT_LOCALNAME 0x0000000F
53
54#define M_SAVEREGS 0x00000010
55
56#define M_CLASS 0x000000E0
57#define MT_PUBLIC 0x00000020
58#define MT_PRIVATE 0x00000040
59#define MT_PROTECT 0x00000060
60#define MT_MEMBER 0x00000080
61#define MT_VTABLE 0x000000A0
62#define MT_RTTI 0x000000C0
63// reserved
64
65#define M_PARMSK 0x0000FF00
67#define MT_PARSHF 8
68#define MT_PARMAX 0xFF
73#define M_ELLIPSIS 0x00010000
74#define MT_VOIDARG 0x0001FF00
75#define M_STATIC 0x00020000
79#define M_VIRTUAL 0x00040000
81#define M_AUTOCRT 0x00080000
83
84#define M_TYPMASK 0x00700000
85#define MT_OPERAT 0x00100000
86#define MT_CONSTR 0x00200000
87#define MT_DESTR 0x00300000
88#define MT_CASTING 0x00400000
89#define MT_CLRCDTOR 0x00500000
90// reserved
91
92#define M_TRUNCATE 0x00800000
93#define M_THUNK 0x01000000
94#define M_ANONNSP 0x02000000
103#define M_TMPLNAM 0x04000000
107#define M_DBGNAME 0x08000000
112
113#define M_COMPILER 0x70000000
114#define MT_MSCOMP 0x10000000
115#define MT_BORLAN 0x20000000
116#define MT_WATCOM 0x30000000
117#define MT_OTHER 0x40000000
119// !!! The following definitions must be last and in this order!
120#define MT_GNU 0x50000000
121#define MT_GCC3 0x60000000
126#define MT_VISAGE 0x70000000
130//---------------------------------------------------------------------------
131// Flags to inhibit different parts of the demangled name
132#define MNG_PTRMSK 0x7
133// DO NOT change order in this group (PtrType)
134#define MNG_DEFNEAR 0x0
135#define MNG_DEFNEARANY 0x1
136#define MNG_DEFFAR 0x2
137#define MNG_NOPTRTYP16 0x3
138#define MNG_DEFHUGE 0x4
139#define MNG_DEFPTR64 0x5
141#define MNG_DEFNONE 0x6
142#define MNG_NOPTRTYP 0x7
143//
144#define MNG_NODEFINIT 0x00000008
151//
152#define MNG_NOUNDERSCORE 0x00000010
153#define MNG_NOTYPE 0x00000020
154#define MNG_NORETTYPE 0x00000040
155#define MNG_NOBASEDT 0x00000080
158#define MNG_NOCALLC 0x00000100
160#define MNG_NOPOSTFC 0x00000200
161#define MNG_NOSCTYP 0x00000400
164#define MNG_NOTHROW 0x00000800
166#define MNG_NOSTVIR 0x00001000
168#define MNG_NOECSU 0x00002000
169#define MNG_NOCSVOL 0x00004000
174#define MNG_NOCLOSUR 0x00008000
176#define MNG_NOUNALG 0x00010000
178#define MNG_NOMANAGE 0x00020000
181#define MNG_NOMODULE 0x00040000
182// 0x00080000
183//
184#define MNG_SHORT_S 0x00100000
185#define MNG_SHORT_U 0x00200000
186#define MNG_ZPT_SPACE 0x00400000
189#define MNG_DROP_IMP 0x00800000
190//
191// 0x01000000
192#define MNG_IGN_ANYWAY 0x02000000
193#define MNG_IGN_JMP 0x04000000
194#define MNG_MOVE_JMP 0x08000000
195 // If both MNG_IGN_JMP and MNG_MOVE_JMP
196 // are set then move the prefix only if
197 // the name was not truncated
198//
199#define MNG_COMPILER_MSK 0x70000000 // Compiler mask (0-autodetect)
200
201#define MNG_SHORT_FORM (MNG_NOTYPE|MNG_NORETTYPE|MNG_NOPOSTFC|MNG_NOPTRTYP \
202 | MNG_NOSCTYP|MNG_NOTHROW|MNG_NOSTVIR|MNG_NOECSU|MNG_NOCLOSUR \
203 | MNG_SHORT_U|MNG_DROP_IMP|MNG_NOUNALG|MNG_NOMANAGE \
204 | MNG_IGN_JMP|MNG_MOVE_JMP|MNG_IGN_ANYWAY)
205#define MNG_LONG_FORM (MNG_ZPT_SPACE | MNG_IGN_JMP | MNG_IGN_ANYWAY | MNG_NOPTRTYP)
206
207// The description of the following symbol is in the notes
208#define MNG_CALC_VALID (MNG_COMPILER_MSK|MNG_IGN_JMP|MNG_IGN_ANYWAY)
209
210//---------------------------------------------------------------------------
211//---------------------------------------------------------------------------
212#ifndef H2ASH
213
214#if !defined(NO_OBSOLETE_FUNCS) || defined(__DEFINE_DEMANGLE__)
215typedef int32 ida_export demangler_t(
216 char *answer,
217 uint answer_length,
218 const char *str,
219 uint32 disable_mask);
221#endif
222
223// If answer_length == 0 then no demangling is performed neither. The function
224// will check if demangling is possible and what compiler is used to mangle
225// the name. If the name cannot be demangled then the function will return 0.
226// NOTE: the answer MT_MSCOMP+1 means __msfastcall
227// (or borland class name with "_4" suffix) and the demangling is possible
228// either as MS (__fastcall) or as bc (__msfastcall)
229// NOTE: the answer MT_GCC3+1 means POSSIBLE mingw/cygwin with
230// __stdcall/__fastcall but it might also mean ms-stdcall.
231// In essense it means that the demangler cannot determine the compiler
232// precisely.
233// It also means that the demangling is possible in the gcc3 mode
234// ONLY when the compiler is explicitly set to gcc3 and MNG_NODEFINIT
235// bit is not set.
236
237// If answer == NULL then the demangler will return check if the demangling
238// is possible and only return the flags.
239// In this case answer_length should be enough to hold the demangled name.
240
241// NOTE: If int32(answer_length) < 0 then the demangler will calcuate the
242// the number of purged bytes for the given name. In this case
243// disable_mask may contain only bits included in MNG_CALC_VALID,
244// and -answer_length must be equal to the register size (e.g.
245// sizeof(uint16/uint32/uint64)). The value of the register size
246// is used to check the numeric value in the ms stdcall/fastcall
247// encoding (it is used in the gcc mode too).
248// if return value <= 0 - no purged bytes or valid information.
249// If (value & 1) != 0 - ms stdcall (definite npurged is value-1.
250// If (value & 1) == 0 - 'encoded' counter (not implemented yet).
251
252// If answer != NULL (and answer_length != 0) - perform demangling and fill out.
253// NOTE: if int32(answer_length) < 0 then the buffer size will be -answer_length
254// but 'answer' is interpreted not as a pointer to the output buffer but
255// as a pointer to pointer to the output buffer (char**).
256// In this case if the function succeeds,a pointer to the answer end
257// will be returned in the pointer (like stpcpy). In this form 'answer'
258// cannot be NULL and *(char**)answer cannot be NULL.
259// answer_length must be greater than 9 for the 'truncated' answer.
260
265
266idaman mangled_name_type_t ida_export get_mangled_name_type(const char *name);
267
268#endif // H2ASH
269#endif // _DEMANGLE_HPP
const mangled_name_type_t MANGLED_CODE
Definition demangle.hpp:262
int32 ida_export demangler_t(char *answer, uint answer_length, const char *str, uint32 disable_mask)
Definition demangle.hpp:215
int mangled_name_type_t
Definition demangle.hpp:261
const mangled_name_type_t MANGLED_DATA
Definition demangle.hpp:263
idaman mangled_name_type_t ida_export get_mangled_name_type(const char *name)
idaman demangler_t demangle
Definition demangle.hpp:220
const mangled_name_type_t MANGLED_UNKNOWN
Definition demangle.hpp:264
char * answer
Definition kernwin.hpp:8023
unsigned int uint32
unsigned 32 bit value
Definition pro.h:348
int int32
signed 32 bit value
Definition pro.h:347
unsigned int uint
unsigned 32 bit value
Definition pro.h:339