Zydis: include/Zydis/Segment.h Source File

Zydis v4.0.0

Loading...
Searching...
No Matches
Segment.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
32#ifndef ZYDIS_SEGMENT_H
33#define ZYDIS_SEGMENT_H
34
35#include <Zycore/Defines.h>
36#include <Zydis/DecoderTypes.h>
37#include <Zydis/Status.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
49/* ============================================================================================== */
50/* Macros */
51/* ============================================================================================== */
52
53/* ---------------------------------------------------------------------------------------------- */
54/* Constants */
55/* ---------------------------------------------------------------------------------------------- */
56
57#define ZYDIS_MAX_INSTRUCTION_SEGMENT_COUNT 9
58
59/* ---------------------------------------------------------------------------------------------- */
60
61/* ============================================================================================== */
62/* Enums and types */
63/* ============================================================================================== */
64
68 typedef enum ZydisInstructionSegment_
69{
70 ZYDIS_INSTR_SEGMENT_NONE,
74 ZYDIS_INSTR_SEGMENT_PREFIXES,
78 ZYDIS_INSTR_SEGMENT_REX,
82 ZYDIS_INSTR_SEGMENT_XOP,
86 ZYDIS_INSTR_SEGMENT_VEX,
90 ZYDIS_INSTR_SEGMENT_EVEX,
94 ZYDIS_INSTR_SEGMENT_MVEX,
98 ZYDIS_INSTR_SEGMENT_OPCODE,
102 ZYDIS_INSTR_SEGMENT_MODRM,
106 ZYDIS_INSTR_SEGMENT_SIB,
110 ZYDIS_INSTR_SEGMENT_DISPLACEMENT,
114 ZYDIS_INSTR_SEGMENT_IMMEDIATE,
115
119 ZYDIS_INSTR_SEGMENT_MAX_VALUE = ZYDIS_INSTR_SEGMENT_IMMEDIATE,
123 ZYDIS_INSTR_SEGMENT_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_INSTR_SEGMENT_MAX_VALUE)
124} ZydisInstructionSegment;
125
129 typedef struct ZydisInstructionSegments_
130{
134 ZyanU8 count;
135 struct
136 {
140 ZydisInstructionSegment type;
144 ZyanU8 offset;
148 ZyanU8 size;
149 } segments[ZYDIS_MAX_INSTRUCTION_SEGMENT_COUNT];
150} ZydisInstructionSegments;
151
152/* ============================================================================================== */
153/* Exported functions */
154/* ============================================================================================== */
155
165 ZYDIS_EXPORT ZyanStatus ZydisGetInstructionSegments(const ZydisDecodedInstruction* instruction,
166 ZydisInstructionSegments* segments);
167
168/* ============================================================================================== */
169
174#ifdef __cplusplus
175}
176#endif
177
178#endif /* ZYDIS_SEGMENT_H */
DecoderTypes.h
Defines the basic ZydisDecodedInstruction and ZydisDecodedOperand structs.
ZYDIS_EXPORT
#define ZYDIS_EXPORT
Symbol is exported in shared library builds.
Definition: Defines.h:67
Status.h
Status code definitions and check macros.
ZydisGetInstructionSegments
ZYDIS_EXPORT ZyanStatus ZydisGetInstructionSegments(const ZydisDecodedInstruction *instruction, ZydisInstructionSegments *segments)
Returns offsets and sizes of all logical instruction segments (e.g.
ZydisInstructionSegment
enum ZydisInstructionSegment_ ZydisInstructionSegment
Defines the ZydisInstructionSegment struct.
ZydisInstructionSegments
struct ZydisInstructionSegments_ ZydisInstructionSegments
Defines the ZydisInstructionSegments struct.
ZydisInstructionSegment_
ZydisInstructionSegment_
Defines the ZydisInstructionSegment struct.
Definition: Segment.h:69
ZYDIS_INSTR_SEGMENT_XOP
@ ZYDIS_INSTR_SEGMENT_XOP
The XOP prefix bytes.
Definition: Segment.h:82
ZYDIS_INSTR_SEGMENT_IMMEDIATE
@ ZYDIS_INSTR_SEGMENT_IMMEDIATE
The immediate bytes.
Definition: Segment.h:114
ZYDIS_INSTR_SEGMENT_OPCODE
@ ZYDIS_INSTR_SEGMENT_OPCODE
The opcode bytes.
Definition: Segment.h:98
ZYDIS_INSTR_SEGMENT_MODRM
@ ZYDIS_INSTR_SEGMENT_MODRM
The ModRM byte.
Definition: Segment.h:102
ZYDIS_INSTR_SEGMENT_MVEX
@ ZYDIS_INSTR_SEGMENT_MVEX
The MVEX prefix bytes.
Definition: Segment.h:94
ZYDIS_INSTR_SEGMENT_REX
@ ZYDIS_INSTR_SEGMENT_REX
The effective REX prefix byte.
Definition: Segment.h:78
ZYDIS_INSTR_SEGMENT_SIB
@ ZYDIS_INSTR_SEGMENT_SIB
The SIB byte.
Definition: Segment.h:106
ZYDIS_INSTR_SEGMENT_REQUIRED_BITS
@ ZYDIS_INSTR_SEGMENT_REQUIRED_BITS
The minimum number of bits required to represent all values of this enum.
Definition: Segment.h:123
ZYDIS_INSTR_SEGMENT_EVEX
@ ZYDIS_INSTR_SEGMENT_EVEX
The EVEX prefix bytes.
Definition: Segment.h:90
ZYDIS_INSTR_SEGMENT_VEX
@ ZYDIS_INSTR_SEGMENT_VEX
The VEX prefix bytes.
Definition: Segment.h:86
ZYDIS_INSTR_SEGMENT_DISPLACEMENT
@ ZYDIS_INSTR_SEGMENT_DISPLACEMENT
The displacement bytes.
Definition: Segment.h:110
ZYDIS_INSTR_SEGMENT_PREFIXES
@ ZYDIS_INSTR_SEGMENT_PREFIXES
The legacy prefixes (including ignored REX prefixes).
Definition: Segment.h:74
ZYDIS_INSTR_SEGMENT_MAX_VALUE
@ ZYDIS_INSTR_SEGMENT_MAX_VALUE
Maximum value of this enum.
Definition: Segment.h:119
ZydisDecodedInstruction_
Information about a decoded instruction.
Definition: DecoderTypes.h:1238
ZydisInstructionSegments_
Defines the ZydisInstructionSegments struct.
Definition: Segment.h:130
ZydisInstructionSegments_::count
ZyanU8 count
The number of logical instruction segments.
Definition: Segment.h:134
ZydisInstructionSegments_::size
ZyanU8 size
The size of the segment, in bytes.
Definition: Segment.h:148
ZydisInstructionSegments_::type
ZydisInstructionSegment type
The type of the segment.
Definition: Segment.h:140
ZydisInstructionSegments_::offset
ZyanU8 offset
The offset of the segment relative to the start of the instruction (in bytes).
Definition: Segment.h:144