Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
target
disasm.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011-2013 The University of Utah
3
*
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of
7
* the License, or (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17
*/
18
19
#ifndef __DISASM_H__
20
#define __DISASM_H__
21
22
#include <mnemonics.h>
23
#include <distorm.h>
24
#include "
common.h
"
25
26
typedef
_InstructionType
dis_inst_t
;
27
typedef
_RegisterType
dis_reg_t
;
28
29
typedef
enum
{
30
DECODE_TYPE_NONE
= 0,
31
DECODE_TYPE_CONTROL
= 1,
32
}
decode_t
;
33
34
struct
inst_data
{
35
SMOFFSET
offset
;
36
dis_inst_t
type
;
37
decode_t
dtype
;
38
uint8_t
size
;
39
};
40
41
#define INST_NAME(inst_type) GET_MNEMONIC_NAME((inst_type))
42
#define REG_NAME(reg_type) GET_REGISTER_NAME((reg_type))
43
44
extern
char
*
const
inst_type_names
[];
45
46
typedef
enum
{
47
INST_NONE
= 0,
48
INST_RET
,
49
INST_IRET
,
50
INST_CALL
,
51
INST_SYSCALL
,
52
INST_SYSRET
,
53
INST_SYSENTER
,
54
INST_SYSEXIT
,
55
INST_INT
,
56
INST_INT3
,
57
INST_INTO
,
58
INST_JMP
,
59
INST_JCC
,
60
INST_CMOV
,
61
}
inst_type_t
;
62
63
#define INST_TYPE_NAME(inst_type) (((inst_type) < (sizeof(inst_type_names) \
64
/ sizeof(inst_type_names[0]))) \
65
? inst_type_names[(inst_type)] : "UNKNOWN")
66
67
typedef
enum
{
68
INST_CF_ANY
= 0,
69
INST_CF_RET
= 1 <<
INST_RET
,
70
INST_CF_IRET
= 1 <<
INST_IRET
,
71
INST_CF_CALL
= 1 <<
INST_CALL
,
72
INST_CF_SYSCALL
= 1 <<
INST_SYSCALL
,
73
INST_CF_SYSRET
= 1 <<
INST_SYSRET
,
74
INST_CF_SYSENTER
= 1 <<
INST_SYSENTER
,
75
INST_CF_SYSEXIT
= 1 <<
INST_SYSEXIT
,
76
INST_CF_INT
= 1 <<
INST_INT
,
77
INST_CF_INT3
= 1 <<
INST_INT3
,
78
INST_CF_INTO
= 1 <<
INST_INTO
,
79
INST_CF_JMP
= 1 <<
INST_JMP
,
80
INST_CF_JCC
= 1 <<
INST_JCC
,
81
INST_CF_CMOV
= 1 <<
INST_CMOV
,
82
}
inst_cf_flags_t
;
83
84
#define INST_TO_CF_FLAG(inst) (1 << (inst))
85
86
#define LOGDUMPDISASMCFIDATA(dl,lt,idata) \
87
vdebugc((dl),(lt), \
88
"cf_inst_data(%s:+%"PRIdOFFSET":%s%s%s%s:disp=%"PRIu64"," \
89
"target=0x%"PRIxADDR")\n", \
90
INST_TYPE_NAME((idata)->type),(idata)->offset, \
91
((idata)->cf.is_relative) ? "relative," : "", \
92
((idata)->cf.is_mem) ? "mem," : "", \
93
((idata)->cf.is_reg) ? "reg," : "", \
94
((idata)->cf.target_in_segment) ? "target_in_segment," : "", \
95
((idata)->cf.target_is_valid) ? "target_is_valid," : "", \
96
(idata)->cf.disp,(idata)->target);
97
98
struct
cf_inst_data
{
99
inst_type_t
type
;
100
OFFSET
offset
;
101
uint8_t
size
;
102
103
struct
{
104
int
is_relative
:1,
105
is_mem
:1,
106
is_reg
:1,
107
target_in_segment
:1,
108
target_is_valid
:1;
109
110
uint64_t
disp
;
111
union
{
112
/* If it's an interrupt, which number. */
113
uint8_t
intnum
;
114
/* If it's an indirect jump/call, which register or mem
115
* contains the target address.
116
*/
117
struct
{
118
dis_reg_t
base_reg
;
119
dis_reg_t
index_reg
;
120
uint8_t
scale
;
121
};
122
ADDR
mem
;
123
/* If it's a relative branch, the offset. */
124
OFFSET
reloffset
;
125
/* If it's an absolute branch, the dest addr. */
126
ADDR
addr
;
127
};
128
/* If the base address of the bytes to disasm is available, and the
129
* branch is an absolute branch, we can compute the actual
130
* destination.
131
*/
132
ADDR
target
;
133
}
cf
;
134
};
135
136
struct
disasm_data
{
137
struct
bsymbol
*
bsymbol
;
138
ADDR
start
;
139
unsigned
int
len
;
140
unsigned
char
*
code
;
141
};
142
143
#endif
/* __DISASM_H__ */
cf_inst_data::intnum
uint8_t intnum
Definition:
disasm.h:113
inst_data::offset
SMOFFSET offset
Definition:
disasm.h:35
inst_data::size
uint8_t size
Definition:
disasm.h:38
decode_t
decode_t
Definition:
disasm.h:29
disasm_data::bsymbol
struct bsymbol * bsymbol
Definition:
disasm.h:137
cf_inst_data::size
uint8_t size
Definition:
disasm.h:101
cf_inst_data::is_mem
int is_mem
Definition:
disasm.h:104
cf_inst_data::offset
OFFSET offset
Definition:
disasm.h:100
inst_data
Definition:
disasm.h:34
cf_inst_data::scale
uint8_t scale
Definition:
disasm.h:120
INST_CF_RET
Definition:
disasm.h:69
cf_inst_data::disp
uint64_t disp
Definition:
disasm.h:110
cf_inst_data::type
inst_type_t type
Definition:
disasm.h:99
INST_CF_SYSENTER
Definition:
disasm.h:74
cf_inst_data::is_relative
int is_relative
Definition:
disasm.h:104
SMOFFSET
int32_t SMOFFSET
Definition:
common.h:100
cf_inst_data::target_in_segment
int target_in_segment
Definition:
disasm.h:104
INST_CF_INTO
Definition:
disasm.h:78
INST_CF_IRET
Definition:
disasm.h:70
DECODE_TYPE_NONE
Definition:
disasm.h:30
cf_inst_data::reloffset
OFFSET reloffset
Definition:
disasm.h:124
OFFSET
int32_t OFFSET
Definition:
common.h:65
INST_CF_CMOV
Definition:
disasm.h:81
disasm_data::start
ADDR start
Definition:
disasm.h:138
INST_SYSENTER
Definition:
disasm.h:53
cf_inst_data::index_reg
dis_reg_t index_reg
Definition:
disasm.h:119
INST_SYSEXIT
Definition:
disasm.h:54
INST_CF_CALL
Definition:
disasm.h:71
dis_inst_t
_InstructionType dis_inst_t
Definition:
disasm.h:26
INST_INT3
Definition:
disasm.h:56
cf_inst_data::target_is_valid
int target_is_valid
Definition:
disasm.h:104
disasm_data::len
unsigned int len
Definition:
disasm.h:139
INST_NONE
Definition:
disasm.h:47
inst_cf_flags_t
inst_cf_flags_t
Definition:
disasm.h:67
INST_JCC
Definition:
disasm.h:59
INST_CF_SYSCALL
Definition:
disasm.h:72
INST_CALL
Definition:
disasm.h:50
cf_inst_data::is_reg
int is_reg
Definition:
disasm.h:104
cf_inst_data::cf
struct cf_inst_data::@12 cf
DECODE_TYPE_CONTROL
Definition:
disasm.h:31
cf_inst_data::target
ADDR target
Definition:
disasm.h:132
cf_inst_data
Definition:
disasm.h:98
inst_type_names
char *const inst_type_names[]
Definition:
disasm.c:641
INST_CF_SYSEXIT
Definition:
disasm.h:75
INST_INT
Definition:
disasm.h:55
INST_SYSRET
Definition:
disasm.h:52
INST_CF_JMP
Definition:
disasm.h:79
dis_reg_t
_RegisterType dis_reg_t
Definition:
disasm.h:27
INST_CF_JCC
Definition:
disasm.h:80
ADDR
uint32_t ADDR
Definition:
common.h:64
INST_IRET
Definition:
disasm.h:49
disasm_data
Definition:
disasm.h:136
common.h
inst_data::type
dis_inst_t type
Definition:
disasm.h:36
INST_CF_SYSRET
Definition:
disasm.h:73
bsymbol
Definition:
target.h:1012
cf_inst_data::base_reg
dis_reg_t base_reg
Definition:
disasm.h:118
inst_data::dtype
decode_t dtype
Definition:
disasm.h:37
inst_type_t
inst_type_t
Definition:
disasm.h:46
disasm_data::code
unsigned char * code
Definition:
disasm.h:140
cf_inst_data::mem
ADDR mem
Definition:
disasm.h:122
INST_SYSCALL
Definition:
disasm.h:51
INST_CF_INT3
Definition:
disasm.h:77
INST_CMOV
Definition:
disasm.h:60
INST_CF_ANY
Definition:
disasm.h:68
INST_JMP
Definition:
disasm.h:58
cf_inst_data::addr
ADDR addr
Definition:
disasm.h:126
INST_RET
Definition:
disasm.h:48
INST_INTO
Definition:
disasm.h:57
INST_CF_INT
Definition:
disasm.h:76
Generated on Thu Jul 27 2017 20:47:31 for Stackdb by
1.8.8