Zydis v4.1.1

Loading...
Searching...
No Matches
Register.h
Go to the documentation of this file.
1/***************************************************************************************************
2
3 Zyan Disassembler Library (Zydis)
4
5 Original Author : Florian Bernd
6
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24
25***************************************************************************************************/
26
31
32#ifndef ZYDIS_REGISTER_H
33#define ZYDIS_REGISTER_H
34
35#include <Zycore/Defines.h>
36#include <Zycore/Types.h>
37#include <Zydis/Defines.h>
38#include <Zydis/SharedTypes.h>
39#include <Zydis/ShortString.h>
40
41#ifdef __cplusplus
42 extern "C" {
43#endif
44
45/* ============================================================================================== */
46/* Enums and types */
47/* ============================================================================================== */
48
49/* ---------------------------------------------------------------------------------------------- */
50/* Registers */
51/* ---------------------------------------------------------------------------------------------- */
52
53#include <Zydis/Generated/EnumRegister.h>
54
55/* ---------------------------------------------------------------------------------------------- */
56/* Register kinds */
57/* ---------------------------------------------------------------------------------------------- */
58
69 typedef enum ZydisRegisterKind_
70{
71 ZYDIS_REGKIND_INVALID,
72 ZYDIS_REGKIND_GPR,
73 ZYDIS_REGKIND_X87,
74 ZYDIS_REGKIND_MMX,
75 ZYDIS_REGKIND_VR,
76 ZYDIS_REGKIND_TMM,
77 ZYDIS_REGKIND_SEGMENT,
78 ZYDIS_REGKIND_TEST,
79 ZYDIS_REGKIND_CONTROL,
80 ZYDIS_REGKIND_DEBUG,
81 ZYDIS_REGKIND_MASK,
82 ZYDIS_REGKIND_BOUND,
83
87 ZYDIS_REGKIND_MAX_VALUE = ZYDIS_REGKIND_BOUND,
91 ZYDIS_REGKIND_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_REGKIND_MAX_VALUE)
92} ZydisRegisterKind;
93
94/* ---------------------------------------------------------------------------------------------- */
95/* Register classes */
96/* ---------------------------------------------------------------------------------------------- */
97
108 typedef enum ZydisRegisterClass_
109{
110 ZYDIS_REGCLASS_INVALID,
114 ZYDIS_REGCLASS_GPR8,
118 ZYDIS_REGCLASS_GPR16,
122 ZYDIS_REGCLASS_GPR32,
126 ZYDIS_REGCLASS_GPR64,
130 ZYDIS_REGCLASS_X87,
134 ZYDIS_REGCLASS_MMX,
138 ZYDIS_REGCLASS_XMM,
142 ZYDIS_REGCLASS_YMM,
146 ZYDIS_REGCLASS_ZMM,
150 ZYDIS_REGCLASS_TMM,
151 /*
152 * Flags registers.
153 */
154 ZYDIS_REGCLASS_FLAGS,
158 ZYDIS_REGCLASS_IP,
162 ZYDIS_REGCLASS_SEGMENT,
166 ZYDIS_REGCLASS_TABLE,
170 ZYDIS_REGCLASS_TEST,
174 ZYDIS_REGCLASS_CONTROL,
178 ZYDIS_REGCLASS_DEBUG,
182 ZYDIS_REGCLASS_MASK,
186 ZYDIS_REGCLASS_BOUND,
187
191 ZYDIS_REGCLASS_MAX_VALUE = ZYDIS_REGCLASS_BOUND,
195 ZYDIS_REGCLASS_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_REGCLASS_MAX_VALUE)
196} ZydisRegisterClass;
197
198/* ---------------------------------------------------------------------------------------------- */
199/* Register width */
200/* ---------------------------------------------------------------------------------------------- */
201
205 typedef ZyanU16 ZydisRegisterWidth;
206
207/* ---------------------------------------------------------------------------------------------- */
208/* Register context */
209/* ---------------------------------------------------------------------------------------------- */
210
214 typedef struct ZydisRegisterContext_
215{
219 ZyanU64 values[ZYDIS_REGISTER_MAX_VALUE + 1];
220} ZydisRegisterContext;
221
222/* ---------------------------------------------------------------------------------------------- */
223
224/* ============================================================================================== */
225/* Exported functions */
226/* ============================================================================================== */
227
233
234/* ---------------------------------------------------------------------------------------------- */
235/* Register */
236/* ---------------------------------------------------------------------------------------------- */
237
247 ZYDIS_EXPORT ZydisRegister ZydisRegisterEncode(ZydisRegisterClass register_class, ZyanU8 id);
248
256 ZYDIS_EXPORT ZyanI8 ZydisRegisterGetId(ZydisRegister reg);
257
265 ZYDIS_EXPORT ZydisRegisterClass ZydisRegisterGetClass(ZydisRegister reg);
266
276 ZYDIS_EXPORT ZydisRegisterWidth ZydisRegisterGetWidth(ZydisMachineMode mode, ZydisRegister reg);
277
287 ZYDIS_EXPORT ZydisRegister ZydisRegisterGetLargestEnclosing(ZydisMachineMode mode,
288 ZydisRegister reg);
289
297 ZYDIS_EXPORT const char* ZydisRegisterGetString(ZydisRegister reg);
298
308 ZYDIS_EXPORT const ZydisShortString* ZydisRegisterGetStringWrapped(ZydisRegister reg);
309
310/* ---------------------------------------------------------------------------------------------- */
311/* Register class */
312/* ---------------------------------------------------------------------------------------------- */
313
322 ZYDIS_EXPORT ZydisRegisterWidth ZydisRegisterClassGetWidth(ZydisMachineMode mode,
323 ZydisRegisterClass register_class);
324
325/* ---------------------------------------------------------------------------------------------- */
326
330
331/* ============================================================================================== */
332
333#ifdef __cplusplus
334}
335#endif
336
337#endif /* ZYDIS_REGISTER_H */
Defines.h
Import/export defines for MSVC builds.
ZYDIS_EXPORT
#define ZYDIS_EXPORT
Symbol is exported in shared library builds.
Definition Defines.h:67
EnumRegister.h
ZYDIS_REGISTER_MAX_VALUE
@ ZYDIS_REGISTER_MAX_VALUE
Maximum value of this enum.
Definition EnumRegister.h:316
ZydisRegister
enum ZydisRegister_ ZydisRegister
Defines the ZydisRegister enum.
ZydisRegisterWidth
ZyanU16 ZydisRegisterWidth
Defines the ZydisRegisterWidth data-type.
Definition Register.h:205
ZydisRegisterClass_
ZydisRegisterClass_
Defines the ZydisRegisterClass enum.
Definition Register.h:109
ZYDIS_REGCLASS_MMX
@ ZYDIS_REGCLASS_MMX
Floating point multimedia registers.
Definition Register.h:134
ZYDIS_REGCLASS_IP
@ ZYDIS_REGCLASS_IP
Instruction-pointer registers.
Definition Register.h:158
ZYDIS_REGCLASS_CONTROL
@ ZYDIS_REGCLASS_CONTROL
Control registers.
Definition Register.h:174
ZYDIS_REGCLASS_GPR8
@ ZYDIS_REGCLASS_GPR8
8-bit general-purpose registers.
Definition Register.h:114
ZYDIS_REGCLASS_SEGMENT
@ ZYDIS_REGCLASS_SEGMENT
Segment registers.
Definition Register.h:162
ZYDIS_REGCLASS_TEST
@ ZYDIS_REGCLASS_TEST
Test registers.
Definition Register.h:170
ZYDIS_REGCLASS_REQUIRED_BITS
@ ZYDIS_REGCLASS_REQUIRED_BITS
The minimum number of bits required to represent all values of this enum.
Definition Register.h:195
ZYDIS_REGCLASS_X87
@ ZYDIS_REGCLASS_X87
Floating point legacy registers.
Definition Register.h:130
ZYDIS_REGCLASS_MAX_VALUE
@ ZYDIS_REGCLASS_MAX_VALUE
Maximum value of this enum.
Definition Register.h:191
ZYDIS_REGCLASS_YMM
@ ZYDIS_REGCLASS_YMM
256-bit vector registers.
Definition Register.h:142
ZYDIS_REGCLASS_TMM
@ ZYDIS_REGCLASS_TMM
Matrix registers.
Definition Register.h:150
ZYDIS_REGCLASS_TABLE
@ ZYDIS_REGCLASS_TABLE
Table registers.
Definition Register.h:166
ZYDIS_REGCLASS_GPR64
@ ZYDIS_REGCLASS_GPR64
64-bit general-purpose registers.
Definition Register.h:126
ZYDIS_REGCLASS_BOUND
@ ZYDIS_REGCLASS_BOUND
Bound registers.
Definition Register.h:186
ZYDIS_REGCLASS_GPR32
@ ZYDIS_REGCLASS_GPR32
32-bit general-purpose registers.
Definition Register.h:122
ZYDIS_REGCLASS_INVALID
@ ZYDIS_REGCLASS_INVALID
Definition Register.h:110
ZYDIS_REGCLASS_DEBUG
@ ZYDIS_REGCLASS_DEBUG
Debug registers.
Definition Register.h:178
ZYDIS_REGCLASS_FLAGS
@ ZYDIS_REGCLASS_FLAGS
Definition Register.h:154
ZYDIS_REGCLASS_ZMM
@ ZYDIS_REGCLASS_ZMM
512-bit vector registers.
Definition Register.h:146
ZYDIS_REGCLASS_MASK
@ ZYDIS_REGCLASS_MASK
Mask registers.
Definition Register.h:182
ZYDIS_REGCLASS_GPR16
@ ZYDIS_REGCLASS_GPR16
16-bit general-purpose registers.
Definition Register.h:118
ZYDIS_REGCLASS_XMM
@ ZYDIS_REGCLASS_XMM
128-bit vector registers.
Definition Register.h:138
ZydisRegisterKind
enum ZydisRegisterKind_ ZydisRegisterKind
Defines the ZydisRegisterKind enum.
ZydisRegisterContext
struct ZydisRegisterContext_ ZydisRegisterContext
Defines the ZydisRegisterContext struct.
ZydisRegisterClass
enum ZydisRegisterClass_ ZydisRegisterClass
Defines the ZydisRegisterClass enum.
ZydisRegisterKind_
ZydisRegisterKind_
Defines the ZydisRegisterKind enum.
Definition Register.h:70
ZYDIS_REGKIND_GPR
@ ZYDIS_REGKIND_GPR
Definition Register.h:72
ZYDIS_REGKIND_SEGMENT
@ ZYDIS_REGKIND_SEGMENT
Definition Register.h:77
ZYDIS_REGKIND_X87
@ ZYDIS_REGKIND_X87
Definition Register.h:73
ZYDIS_REGKIND_CONTROL
@ ZYDIS_REGKIND_CONTROL
Definition Register.h:79
ZYDIS_REGKIND_REQUIRED_BITS
@ ZYDIS_REGKIND_REQUIRED_BITS
The minimum number of bits required to represent all values of this enum.
Definition Register.h:91
ZYDIS_REGKIND_INVALID
@ ZYDIS_REGKIND_INVALID
Definition Register.h:71
ZYDIS_REGKIND_BOUND
@ ZYDIS_REGKIND_BOUND
Definition Register.h:82
ZYDIS_REGKIND_VR
@ ZYDIS_REGKIND_VR
Definition Register.h:75
ZYDIS_REGKIND_TMM
@ ZYDIS_REGKIND_TMM
Definition Register.h:76
ZYDIS_REGKIND_DEBUG
@ ZYDIS_REGKIND_DEBUG
Definition Register.h:80
ZYDIS_REGKIND_MMX
@ ZYDIS_REGKIND_MMX
Definition Register.h:74
ZYDIS_REGKIND_TEST
@ ZYDIS_REGKIND_TEST
Definition Register.h:78
ZYDIS_REGKIND_MAX_VALUE
@ ZYDIS_REGKIND_MAX_VALUE
Maximum value of this enum.
Definition Register.h:87
ZYDIS_REGKIND_MASK
@ ZYDIS_REGKIND_MASK
Definition Register.h:81
SharedTypes.h
Defines decoder/encoder-shared macros and types.
ZydisMachineMode
enum ZydisMachineMode_ ZydisMachineMode
Defines the ZydisMachineMode enum.
ShortString.h
Defines the immutable and storage-efficient ZydisShortString struct, which is used to store strings i...
ZydisShortString
struct ZydisShortString_ ZydisShortString
Defines the ZydisShortString struct.
ZydisRegisterEncode
ZYDIS_EXPORT ZydisRegister ZydisRegisterEncode(ZydisRegisterClass register_class, ZyanU8 id)
Returns the register specified by the register_class and id tuple.
ZydisRegisterGetStringWrapped
ZYDIS_EXPORT const ZydisShortString * ZydisRegisterGetStringWrapped(ZydisRegister reg)
Returns the specified register string as ZydisShortString.
ZydisRegisterGetLargestEnclosing
ZYDIS_EXPORT ZydisRegister ZydisRegisterGetLargestEnclosing(ZydisMachineMode mode, ZydisRegister reg)
Returns the largest enclosing register of the given register.
ZydisRegisterGetId
ZYDIS_EXPORT ZyanI8 ZydisRegisterGetId(ZydisRegister reg)
Returns the id of the specified register.
ZydisRegisterGetString
ZYDIS_EXPORT const char * ZydisRegisterGetString(ZydisRegister reg)
Returns the specified register string.
ZydisRegisterClassGetWidth
ZYDIS_EXPORT ZydisRegisterWidth ZydisRegisterClassGetWidth(ZydisMachineMode mode, ZydisRegisterClass register_class)
Returns the width of the specified register-class.
ZydisRegisterGetClass
ZYDIS_EXPORT ZydisRegisterClass ZydisRegisterGetClass(ZydisRegister reg)
Returns the register-class of the specified register.
ZydisRegisterGetWidth
ZYDIS_EXPORT ZydisRegisterWidth ZydisRegisterGetWidth(ZydisMachineMode mode, ZydisRegister reg)
Returns the width of the specified register.
ZydisRegisterContext_
Defines the ZydisRegisterContext struct.
Definition Register.h:215
ZydisRegisterContext_::values
ZyanU64 values[ZYDIS_REGISTER_MAX_VALUE+1]
The values stored in the register context.
Definition Register.h:219