Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrea Gussoni
artifacts-asiaccs20
Commits
be2e4245
Commit
be2e4245
authored
Dec 10, 2020
by
Andrea Gussoni
Browse files
Add file with custom defs for IDA
parent
c0765a3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
scripting/ida-extraction-scripts/clang-parser/custom_defs.h
0 → 100644
View file @
be2e4245
#define __cdecl
#define __fastcall
#define __return_ptr
#define __struct_ptr
#define __usercall
//#define __noreturn
#define __spoils
#define const
#define _BOOL8 int
#define _OWORD _WORD
#define _TBYTE BYTE
#define size_t int
/*
This file has been generated by IDA.
It contains local type definitions from
the type library 'du.stripped'
*/
#define __int8 char
#define __int16 short
#define __int32 int
#define __int64 long long
// Added for parsing wc binary
struct
_obstack_chunk
/* Lives at front of each chunk. */
{
char
*
limit
;
/* 1 past end of this chunk */
struct
_obstack_chunk
*
prev
;
/* address of prior chunk or NULL */
char
contents
[
4
];
/* objects begin here */
};
struct
obstack
/* control current object in current chunk */
{
long
chunk_size
;
/* preferred size to allocate chunks in */
struct
_obstack_chunk
*
chunk
;
/* address of current struct obstack_chunk */
char
*
object_base
;
/* address of object we are building */
char
*
next_free
;
/* where to add next char to current object */
char
*
chunk_limit
;
/* address of char after current chunk */
//PTR_INT_TYPE temp; /* Temporary for some macros. */
int
alignment_mask
;
/* Mask of alignment for each object. */
/* These prototypes vary based on `use_extra_arg', and we use
casts to the prototypeless function type in all assignments,
but having prototypes here quiets -Wstrict-prototypes. */
struct
_obstack_chunk
*
(
*
chunkfun
)
(
void
*
,
long
);
void
(
*
freefun
)
(
void
*
,
struct
_obstack_chunk
*
);
void
*
extra_arg
;
/* first arg for chunk alloc/dealloc funcs */
unsigned
use_extra_arg
:
1
;
/* chunk alloc/dealloc funcs take extra arg */
unsigned
maybe_empty_object
:
1
;
/* There is a possibility that the current
chunk contains a zero-length object. This
prevents freeing the chunk if we allocate
a bigger chunk to replace it. */
unsigned
alloc_failed
:
1
;
/* No longer used, as we now call the failed
handler on error, but retained for binary
compatibility. */
};
/* 1 */
/*
enum $003F63A829E52477BDB4080710A1139D
{
preorder = 0x0,
postorder = 0x1,
endorder = 0x2,
leaf = 0x3,
};
*/
/* 2 */
struct
__attribute__
((
aligned
(
8
)))
Elf64_Sym
{
unsigned
__int32
st_name
;
unsigned
__int8
st_info
;
unsigned
__int8
st_other
;
unsigned
__int16
st_shndx
;
unsigned
__int64
st_value
;
unsigned
__int64
st_size
;
};
/* 3 */
struct
Elf64_Rela
{
unsigned
__int64
r_offset
;
unsigned
__int64
r_info
;
__int64
r_addend
;
};
/* 4 */
struct
Elf64_Dyn
{
unsigned
__int64
d_tag
;
unsigned
__int64
d_un
;
};
/* 5 */
union
__attribute__
((
aligned
(
8
)))
__m64
{
unsigned
__int64
m64_u64
;
float
m64_f32
[
2
];
__int8
m64_i8
[
8
];
__int16
m64_i16
[
4
];
__int32
m64_i32
[
2
];
__int64
m64_i64
;
unsigned
__int8
m64_u8
[
8
];
unsigned
__int16
m64_u16
[
4
];
unsigned
__int32
m64_u32
[
2
];
};
/* 6 */
union
__attribute__
((
aligned
(
16
)))
__m128
{
float
m128_f32
[
4
];
unsigned
__int64
m128_u64
[
2
];
__int8
m128_i8
[
16
];
__int16
m128_i16
[
8
];
__int32
m128_i32
[
4
];
__int64
m128_i64
[
2
];
unsigned
__int8
m128_u8
[
16
];
unsigned
__int16
m128_u16
[
8
];
unsigned
__int32
m128_u32
[
4
];
};
/* 7 */
struct
__m128d
{
double
m128d_f64
[
2
];
};
/* 8 */
union
__attribute__
((
aligned
(
16
)))
__m128i
{
__int8
m128i_i8
[
16
];
__int16
m128i_i16
[
8
];
__int32
m128i_i32
[
4
];
__int64
m128i_i64
[
2
];
unsigned
__int8
m128i_u8
[
16
];
unsigned
__int16
m128i_u16
[
8
];
unsigned
__int32
m128i_u32
[
4
];
unsigned
__int64
m128i_u64
[
2
];
};
/* 9 */
union
__attribute__
((
aligned
(
32
)))
__m256
{
float
m256_f32
[
8
];
};
/* 10 */
union
__attribute__
((
aligned
(
32
)))
__m256d
{
double
m256d_f64
[
4
];
};
/* 11 */
union
__attribute__
((
aligned
(
32
)))
__m256i
{
__int8
m256i_i8
[
32
];
__int16
m256i_i16
[
16
];
__int32
m256i_i32
[
8
];
__int64
m256i_i64
[
4
];
unsigned
__int8
m256i_u8
[
32
];
unsigned
__int16
m256i_u16
[
16
];
unsigned
__int32
m256i_u32
[
8
];
unsigned
__int64
m256i_u64
[
4
];
};
/* 12 */
struct
__va_list_tag
{
unsigned
int
gp_offset
;
unsigned
int
fp_offset
;
void
*
overflow_arg_area
;
void
*
reg_save_area
;
};
/* 13 */
//typedef __va_list_tag gcc_va_list[1];
/* 14 */
struct
LONG_DOUBLE_16
{
_TBYTE
value
;
char
padding
[
6
];
};
struct
$
E9F5FE92D7DB981290475B0A784F5155
;
/* 5 */
typedef
unsigned
__int64
__dev_t
;
/* 6 */
typedef
unsigned
__int64
__ino_t
;
/* 7 */
typedef
unsigned
__int64
__nlink_t
;
/* 8 */
typedef
unsigned
int
__mode_t
;
/* 9 */
typedef
unsigned
int
__uid_t
;
/* 10 */
typedef
unsigned
int
__gid_t
;
/* 11 */
typedef
__int64
__off_t
;
/* 12 */
typedef
__int64
__blksize_t
;
/* 13 */
typedef
__int64
__blkcnt_t
;
/* 15 */
typedef
__int64
__time_t
;
/* 16 */
typedef
__int64
__syscall_slong_t
;
/* 14 */
struct
timespec
{
__time_t
tv_sec
;
__syscall_slong_t
tv_nsec
;
};
/* 4 */
struct
stat
{
__dev_t
st_dev
;
__ino_t
st_ino
;
__nlink_t
st_nlink
;
__mode_t
st_mode
;
__uid_t
st_uid
;
__gid_t
st_gid
;
int
__pad0
;
__dev_t
st_rdev
;
__off_t
st_size
;
__blksize_t
st_blksize
;
__blkcnt_t
st_blocks
;
struct
timespec
st_atim
;
struct
timespec
st_mtim
;
struct
timespec
st_ctim
;
__syscall_slong_t
__unused
[
3
];
};
/* 18 */
typedef
struct
$
E9F5FE92D7DB981290475B0A784F5155
__mbstate_t
;
/* 17 */
typedef
__mbstate_t
mbstate_t
;
/* 20 */
/*
union $E9F5FE92D7DB981290475B0A784F5155::$BADCA52C29225A708D9C0115E5B974AC
{
unsigned int __wch;
char __wchb[4];
};
*/
/* 19 */
/*
struct $E9F5FE92D7DB981290475B0A784F5155
{
int __count;
$E9F5FE92D7DB981290475B0A784F5155::$BADCA52C29225A708D9C0115E5B974AC __value;
};
*/
/* 22 */
typedef
__int64
__suseconds_t
;
/* 21 */
struct
timeval
{
__time_t
tv_sec
;
__suseconds_t
tv_usec
;
};
/* 23 */
struct
utimbuf
{
__time_t
actime
;
__time_t
modtime
;
};
//#define __m128 int
//#define __m128i int
/*
#define u32 int
#define _OWORD int
//#define gcc_va_list int
#define __asm int
#define __m128i int
#define _TBYTE int
#define quoting_options int
#define quoting_style int
#define socklen_t int
#define core_regs int
#define _uw int
#define __EIT_entry_0 int
#define _Unwind_Reason_Code int
#define _Unwind_Control_Block_0 int
#define phase1_vrs int
#define _Unwind_Word int
#define _Unwind_Context_0 int
#define phase2_vrs int
#define _Unwind_Stop_Fn int
#define _Unwind_VRS_Result int
#define _Unwind_VRS_RegClass int
#define _Unwind_VRS_DataRepresentation int
#define _Unwind_Trace_Fn int
#define _Unwind_State int
#define _Unwind_Action int
#define _Unwind_Context int
#define _uw8 int
#define __gnu_unwind_state int
#define _Unwind_Ptr int
#define _Unwind_EHT_Header int
#define loff_t int
#define __syscall_slong_t int
#define __time_t int
#define __fsword_t int
#define $003F63A829E52477BDB4080710A1139D int
#define rlim64_t int
#define __m128 int
#define sigval_t int
#define __mode_t int
#define nfds_t int
#define __priority_which_t int
#define id_t int
#define __itimer_which_t int
#define Elf64_Dyn int
#define __blksize_t int
#define __ino_t int
#define DIR int
#define __compar_fn_t int
#define wctype_t int
#define iconv_t int
#define __sighandler_t int
#define nl_item int
#define cpu_set_t int
#define fld int
#define __locale_t int
#define speed_t int
#define tcflag_t int
#define fd_set int
#define __fd_mask int
#define _IO_lock_t int
#define _IO_marker int
#define _IO_FILE int
*/
extern
int
imperfetction_wrapper
(
void
);
scripting/ida-extraction-scripts/clang-parser/defs.h
0 → 100644
View file @
be2e4245
/*
This file contains definitions used by the Hex-Rays decompiler output.
It has type definitions and convenience macros to make the
output more readable.
Copyright (c) 2007-2018 Hex-Rays
*/
#ifndef HEXRAYS_DEFS_H
#define HEXRAYS_DEFS_H
#if defined(__GNUC__)
typedef
long
long
ll
;
typedef
unsigned
long
long
ull
;
#define __int64 long long
#define __int32 int
#define __int16 short
#define __int8 char
#define MAKELL(num) num ## LL
#define FMT_64 "ll"
#elif defined(_MSC_VER)
typedef
__int64
ll
;
typedef
unsigned
__int64
ull
;
#define MAKELL(num) num ## i64
#define FMT_64 "I64"
#elif defined (__BORLANDC__)
typedef
__int64
ll
;
typedef
unsigned
__int64
ull
;
#define MAKELL(num) num ## i64
#define FMT_64 "L"
#else
#error "unknown compiler"
#endif
typedef
unsigned
int
uint
;
typedef
unsigned
char
uchar
;
typedef
unsigned
short
ushort
;
typedef
unsigned
long
ulong
;
typedef
char
int8
;
typedef
signed
char
sint8
;
typedef
unsigned
char
uint8
;
typedef
short
int16
;
typedef
signed
short
sint16
;
typedef
unsigned
short
uint16
;
typedef
int
int32
;
typedef
signed
int
sint32
;
typedef
unsigned
int
uint32
;
typedef
ll
int64
;
typedef
ll
sint64
;
typedef
ull
uint64
;
// Partially defined types. They are used when the decompiler does not know
// anything about the type except its size.
#define _BYTE uint8
#define _WORD uint16
#define _DWORD uint32
#define _QWORD uint64
#if !defined(_MSC_VER)
#define _LONGLONG __int128
#endif
// Non-standard boolean types. They are used when the decompiler can not use
// the standard "bool" type because of the size mistmatch but the possible
// values are only 0 and 1. See also 'BOOL' type below.
typedef
int8
_BOOL1
;
typedef
int16
_BOOL2
;
typedef
int32
_BOOL4
;
#ifndef _WINDOWS_
typedef
int8
BYTE
;
typedef
int16
WORD
;
typedef
int32
DWORD
;
typedef
int32
LONG
;
typedef
int
BOOL
;
// uppercase BOOL is usually 4 bytes
#endif
typedef
int64
QWORD
;
#ifndef __cplusplus
typedef
int
bool
;
// we want to use bool in our C programs
#endif
#define __pure // pure function: always returns the same value, has no
// side effects
// Non-returning function
#if defined(__GNUC__)
#define __noreturn __attribute__((noreturn))
#else
#define __noreturn __declspec(noreturn)
#endif
#ifndef NULL
#define NULL 0
#endif
// Some convenience macros to make partial accesses nicer
#define LAST_IND(x,part_type) (sizeof(x)/sizeof(part_type) - 1)
#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
# define LOW_IND(x,part_type) LAST_IND(x,part_type)
# define HIGH_IND(x,part_type) 0
#else
# define HIGH_IND(x,part_type) LAST_IND(x,part_type)
# define LOW_IND(x,part_type) 0
#endif
// first unsigned macros:
#define BYTEn(x, n) (*((_BYTE*)&(x)+n))
#define WORDn(x, n) (*((_WORD*)&(x)+n))
#define DWORDn(x, n) (*((_DWORD*)&(x)+n))
#define LOBYTE(x) BYTEn(x,LOW_IND(x,_BYTE))
#define LOWORD(x) WORDn(x,LOW_IND(x,_WORD))
#define LODWORD(x) DWORDn(x,LOW_IND(x,_DWORD))
#define HIBYTE(x) BYTEn(x,HIGH_IND(x,_BYTE))
#define HIWORD(x) WORDn(x,HIGH_IND(x,_WORD))
#define HIDWORD(x) DWORDn(x,HIGH_IND(x,_DWORD))
#define BYTE1(x) BYTEn(x, 1) // byte 1 (counting from 0)
#define BYTE2(x) BYTEn(x, 2)
#define BYTE3(x) BYTEn(x, 3)
#define BYTE4(x) BYTEn(x, 4)
#define BYTE5(x) BYTEn(x, 5)
#define BYTE6(x) BYTEn(x, 6)
#define BYTE7(x) BYTEn(x, 7)
#define BYTE8(x) BYTEn(x, 8)
#define BYTE9(x) BYTEn(x, 9)
#define BYTE10(x) BYTEn(x, 10)
#define BYTE11(x) BYTEn(x, 11)
#define BYTE12(x) BYTEn(x, 12)
#define BYTE13(x) BYTEn(x, 13)
#define BYTE14(x) BYTEn(x, 14)
#define BYTE15(x) BYTEn(x, 15)
#define WORD1(x) WORDn(x, 1)
#define WORD2(x) WORDn(x, 2) // third word of the object, unsigned
#define WORD3(x) WORDn(x, 3)
#define WORD4(x) WORDn(x, 4)
#define WORD5(x) WORDn(x, 5)
#define WORD6(x) WORDn(x, 6)
#define WORD7(x) WORDn(x, 7)
// now signed macros (the same but with sign extension)
#define SBYTEn(x, n) (*((int8*)&(x)+n))
#define SWORDn(x, n) (*((int16*)&(x)+n))
#define SDWORDn(x, n) (*((int32*)&(x)+n))
#define SLOBYTE(x) SBYTEn(x,LOW_IND(x,int8))
#define SLOWORD(x) SWORDn(x,LOW_IND(x,int16))
#define SLODWORD(x) SDWORDn(x,LOW_IND(x,int32))
#define SHIBYTE(x) SBYTEn(x,HIGH_IND(x,int8))
#define SHIWORD(x) SWORDn(x,HIGH_IND(x,int16))
#define SHIDWORD(x) SDWORDn(x,HIGH_IND(x,int32))
#define SBYTE1(x) SBYTEn(x, 1)
#define SBYTE2(x) SBYTEn(x, 2)
#define SBYTE3(x) SBYTEn(x, 3)
#define SBYTE4(x) SBYTEn(x, 4)
#define SBYTE5(x) SBYTEn(x, 5)
#define SBYTE6(x) SBYTEn(x, 6)
#define SBYTE7(x) SBYTEn(x, 7)
#define SBYTE8(x) SBYTEn(x, 8)
#define SBYTE9(x) SBYTEn(x, 9)
#define SBYTE10(x) SBYTEn(x, 10)
#define SBYTE11(x) SBYTEn(x, 11)
#define SBYTE12(x) SBYTEn(x, 12)
#define SBYTE13(x) SBYTEn(x, 13)
#define SBYTE14(x) SBYTEn(x, 14)
#define SBYTE15(x) SBYTEn(x, 15)
#define SWORD1(x) SWORDn(x, 1)
#define SWORD2(x) SWORDn(x, 2)
#define SWORD3(x) SWORDn(x, 3)
#define SWORD4(x) SWORDn(x, 4)
#define SWORD5(x) SWORDn(x, 5)
#define SWORD6(x) SWORDn(x, 6)
#define SWORD7(x) SWORDn(x, 7)
// Helper functions to represent some assembly instructions.
#ifdef __cplusplus
// compile time assertion
#define __CASSERT_N0__(l) COMPILE_TIME_ASSERT_ ## l
#define __CASSERT_N1__(l) __CASSERT_N0__(l)
#define CASSERT(cnd) typedef char __CASSERT_N1__(__LINE__) [(cnd) ? 1 : -1]
// check that unsigned multiplication does not overflow
template
<
class
T
>
bool
is_mul_ok
(
T
count
,
T
elsize
)
{
CASSERT
((
T
)(
-
1
)
>
0
);
// make sure T is unsigned
if
(
elsize
==
0
||
count
==
0
)
return
true
;
return
count
<=
((
T
)(
-
1
))
/
elsize
;
}
// multiplication that saturates (yields the biggest value) instead of overflowing
// such a construct is useful in "operator new[]"
template
<
class
T
>
bool
saturated_mul
(
T
count
,
T
elsize
)
{
return
is_mul_ok
(
count
,
elsize
)
?
count
*
elsize
:
T
(
-
1
);
}
#include
<stddef.h>
// for size_t
// memcpy() with determined behavoir: it always copies
// from the start to the end of the buffer
// note: it copies byte by byte, so it is not equivalent to, for example, rep movsd
inline
void
*
qmemcpy
(
void
*
dst
,
const
void
*
src
,
size_t
cnt
)
{
char
*
out
=
(
char
*
)
dst
;
const
char
*
in
=
(
const
char
*
)
src
;
while
(
cnt
>
0
)
{
*
out
++
=
*
in
++
;
--
cnt
;
}
return
dst
;
}
// Generate a reference to pair of operands
template
<
class
T
>
int16
__PAIR__
(
int8
high
,
T
low
)
{
return
(((
int16
)
high
)
<<
sizeof
(
high
)
*
8
)
|
uint8
(
low
);
}
template
<
class
T
>
int32
__PAIR__
(
int16
high
,
T
low
)
{
return
(((
int32
)
high
)
<<
sizeof
(
high
)
*
8
)
|
uint16
(
low
);
}
template
<
class
T
>
int64
__PAIR__
(
int32
high
,
T
low
)
{
return
(((
int64
)
high
)
<<
sizeof
(
high
)
*
8
)
|
uint32
(
low
);
}
template
<
class
T
>
uint16
__PAIR__
(
uint8
high
,
T
low
)
{
return
(((
uint16
)
high
)
<<
sizeof
(
high
)
*
8
)
|
uint8
(
low
);
}
template
<
class
T
>
uint32
__PAIR__
(
uint16
high
,
T
low
)
{
return
(((
uint32
)
high
)
<<
sizeof
(
high
)
*
8
)
|
uint16
(
low
);
}
template
<
class
T
>
uint64
__PAIR__
(
uint32
high
,
T
low
)
{
return
(((
uint64
)
high
)
<<
sizeof
(
high
)
*
8
)
|
uint32
(
low
);
}
// rotate left
template
<
class
T
>
T
__ROL__
(
T
value
,
int
count
)
{
const
uint
nbits
=
sizeof
(
T
)
*
8
;
if
(
count
>
0
)
{
count
%=
nbits
;
T
high
=
value
>>
(
nbits
-
count
);
if
(
T
(
-
1
)
<
0
)
// signed value
high
&=
~
((
T
(
-
1
)
<<
count
));
value
<<=
count
;
value
|=
high
;
}
else
{
count
=
-
count
%
nbits
;
T
low
=
value
<<
(
nbits
-
count
);
value
>>=
count
;
value
|=
low
;
}
return
value
;
}
inline
uint8
__ROL1__
(
uint8
value
,
int
count
)
{
return
__ROL__
((
uint8
)
value