Zydis: include/Zydis/Internal/FormatterATT.h Source File

Zydis v4.1.1

Loading...
Searching...
No Matches
FormatterATT.h
Go to the documentation of this file.
1/***************************************************************************************************
2
3 Zyan Disassembler Library (Zydis)
4
5 Original Author : Florian Bernd, Joel Hoener
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_FORMATTER_ATT_H
33#define ZYDIS_FORMATTER_ATT_H
34
35#include <Zydis/Formatter.h>
36#include <Zydis/Internal/FormatterBase.h>
37#include <Zydis/Internal/String.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/* ============================================================================================== */
44/* Formatter functions */
45/* ============================================================================================== */
46
47/* ---------------------------------------------------------------------------------------------- */
48/* Instruction */
49/* ---------------------------------------------------------------------------------------------- */
50
51ZyanStatus ZydisFormatterATTFormatInstruction(const ZydisFormatter* formatter,
52 ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);
53
54/* ---------------------------------------------------------------------------------------------- */
55/* Operands */
56/* ---------------------------------------------------------------------------------------------- */
57
58ZyanStatus ZydisFormatterATTFormatOperandMEM(const ZydisFormatter* formatter,
59 ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);
60
61/* ---------------------------------------------------------------------------------------------- */
62/* Elemental tokens */
63/* ---------------------------------------------------------------------------------------------- */
64
65ZyanStatus ZydisFormatterATTPrintMnemonic(const ZydisFormatter* formatter,
66 ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);
67
68ZyanStatus ZydisFormatterATTPrintRegister(const ZydisFormatter* formatter,
69 ZydisFormatterBuffer* buffer, ZydisFormatterContext* context, ZydisRegister reg);
70
71ZyanStatus ZydisFormatterATTPrintAddressABS(const ZydisFormatter* formatter,
72 ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);
73
74ZyanStatus ZydisFormatterATTPrintDISP(const ZydisFormatter* formatter,
75 ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);
76
77ZyanStatus ZydisFormatterATTPrintIMM(const ZydisFormatter* formatter,
78 ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);
79
80/* ---------------------------------------------------------------------------------------------- */
81
82/* ============================================================================================== */
83/* Fomatter presets */
84/* ============================================================================================== */
85
86/* ---------------------------------------------------------------------------------------------- */
87/* AT&T */
88/* ---------------------------------------------------------------------------------------------- */
89
93static const ZydisFormatter FORMATTER_ATT =
94{
95 /* style */ ZYDIS_FORMATTER_STYLE_ATT,
96 /* force_memory_size */ ZYAN_FALSE,
97 /* force_memory_seg */ ZYAN_FALSE,
98 /* force_memory_scale */ ZYAN_TRUE,
99 /* force_relative_branches */ ZYAN_FALSE,
100 /* force_relative_riprel */ ZYAN_FALSE,
101 /* print_branch_size */ ZYAN_FALSE,
102 /* detailed_prefixes */ ZYAN_FALSE,
103 /* addr_base */ ZYDIS_NUMERIC_BASE_HEX,
104 /* addr_signedness */ ZYDIS_SIGNEDNESS_SIGNED,
105 /* addr_padding_absolute */ ZYDIS_PADDING_AUTO,
106 /* addr_padding_relative */ 2,
107 /* disp_base */ ZYDIS_NUMERIC_BASE_HEX,
108 /* disp_signedness */ ZYDIS_SIGNEDNESS_SIGNED,
109 /* disp_padding */ 2,
110 /* imm_base */ ZYDIS_NUMERIC_BASE_HEX,
111 /* imm_signedness */ ZYDIS_SIGNEDNESS_AUTO,
112 /* imm_padding */ 2,
113 /* case_prefixes */ ZYDIS_LETTER_CASE_DEFAULT,
114 /* case_mnemonic */ ZYDIS_LETTER_CASE_DEFAULT,
115 /* case_registers */ ZYDIS_LETTER_CASE_DEFAULT,
116 /* case_typecasts */ ZYDIS_LETTER_CASE_DEFAULT,
117 /* case_decorators */ ZYDIS_LETTER_CASE_DEFAULT,
118 /* hex_uppercase */ ZYAN_TRUE,
119 /* hex_force_leading_number */ ZYAN_FALSE,
120 /* number_format */
121 {
122 // ZYDIS_NUMERIC_BASE_DEC
123 {
124 // Prefix
125 {
126 /* string */ ZYAN_NULL,
127 /* string_data */ ZYAN_DEFINE_STRING_VIEW(""),
128 /* buffer */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
129 },
130 // Suffix
131 {
132 /* string */ ZYAN_NULL,
133 /* string_data */ ZYAN_DEFINE_STRING_VIEW(""),
134 /* buffer */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
135 }
136 },
137 // ZYDIS_NUMERIC_BASE_HEX
138 {
139 // Prefix
140 {
141 /* string */ &FORMATTER_ATT.number_format[
142 ZYDIS_NUMERIC_BASE_HEX][0].string_data,
143 /* string_data */ ZYAN_DEFINE_STRING_VIEW("0x"),
144 /* buffer */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
145 },
146 // Suffix
147 {
148 /* string */ ZYAN_NULL,
149 /* string_data */ ZYAN_DEFINE_STRING_VIEW(""),
150 /* buffer */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
151 }
152 }
153 },
154 /* func_pre_instruction */ ZYAN_NULL,
155 /* func_post_instruction */ ZYAN_NULL,
156 /* func_format_instruction */ &ZydisFormatterATTFormatInstruction,
157 /* func_pre_operand */ ZYAN_NULL,
158 /* func_post_operand */ ZYAN_NULL,
159 /* func_format_operand_reg */ &ZydisFormatterBaseFormatOperandREG,
160 /* func_format_operand_mem */ &ZydisFormatterATTFormatOperandMEM,
161 /* func_format_operand_ptr */ &ZydisFormatterBaseFormatOperandPTR,
162 /* func_format_operand_imm */ &ZydisFormatterBaseFormatOperandIMM,
163 /* func_print_mnemonic */ &ZydisFormatterATTPrintMnemonic,
164 /* func_print_register */ &ZydisFormatterATTPrintRegister,
165 /* func_print_address_abs */ &ZydisFormatterATTPrintAddressABS,
166 /* func_print_address_rel */ &ZydisFormatterBasePrintAddressREL,
167 /* func_print_disp */ &ZydisFormatterATTPrintDISP,
168 /* func_print_imm */ &ZydisFormatterATTPrintIMM,
169 /* func_print_typecast */ ZYAN_NULL,
170 /* func_print_segment */ &ZydisFormatterBasePrintSegment,
171 /* func_print_prefixes */ &ZydisFormatterBasePrintPrefixes,
172 /* func_print_decorator */ &ZydisFormatterBasePrintDecorator
173};
174
175/* ---------------------------------------------------------------------------------------------- */
176
177/* ============================================================================================== */
178
179#ifdef __cplusplus
180}
181#endif
182
183#endif // ZYDIS_FORMATTER_ATT_H
ZydisRegister
enum ZydisRegister_ ZydisRegister
Defines the ZydisRegister enum.
ZydisFormatterATTPrintDISP
ZyanStatus ZydisFormatterATTPrintDISP(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterATTPrintIMM
ZyanStatus ZydisFormatterATTPrintIMM(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterATTFormatOperandMEM
ZyanStatus ZydisFormatterATTFormatOperandMEM(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterATTPrintMnemonic
ZyanStatus ZydisFormatterATTPrintMnemonic(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterATTFormatInstruction
ZyanStatus ZydisFormatterATTFormatInstruction(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterATTPrintRegister
ZyanStatus ZydisFormatterATTPrintRegister(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context, ZydisRegister reg)
ZydisFormatterATTPrintAddressABS
ZyanStatus ZydisFormatterATTPrintAddressABS(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
FormatterBase.h
Provides formatter functions that are shared between the different formatters.
ZydisFormatterBasePrintPrefixes
ZyanStatus ZydisFormatterBasePrintPrefixes(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterBasePrintSegment
ZyanStatus ZydisFormatterBasePrintSegment(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterBasePrintAddressREL
ZyanStatus ZydisFormatterBasePrintAddressREL(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterBaseFormatOperandREG
ZyanStatus ZydisFormatterBaseFormatOperandREG(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterBaseFormatOperandPTR
ZyanStatus ZydisFormatterBaseFormatOperandPTR(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterBasePrintDecorator
ZyanStatus ZydisFormatterBasePrintDecorator(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context, ZydisDecorator decorator)
ZydisFormatterBaseFormatOperandIMM
ZyanStatus ZydisFormatterBaseFormatOperandIMM(const ZydisFormatter *formatter, ZydisFormatterBuffer *buffer, ZydisFormatterContext *context)
ZydisFormatterBuffer
struct ZydisFormatterBuffer_ ZydisFormatterBuffer
Defines the ZydisFormatterBuffer struct.
Formatter.h
Functions for formatting instructions to human-readable text.
ZYDIS_FORMATTER_STYLE_ATT
@ ZYDIS_FORMATTER_STYLE_ATT
Generates AT&T-style disassembly.
Definition Formatter.h:71
ZYDIS_SIGNEDNESS_AUTO
@ ZYDIS_SIGNEDNESS_AUTO
Automatically choose the most suitable mode based on the operands ZydisDecodedOperand....
Definition Formatter.h:381
ZYDIS_SIGNEDNESS_SIGNED
@ ZYDIS_SIGNEDNESS_SIGNED
Force signed values.
Definition Formatter.h:385
ZydisFormatter
struct ZydisFormatter_ ZydisFormatter
Definition Formatter.h:646
ZYDIS_PADDING_AUTO
@ ZYDIS_PADDING_AUTO
Padds the value to the current stack-width for addresses, or to the operand-width for immediate value...
Definition Formatter.h:417
ZydisFormatterContext
struct ZydisFormatterContext_ ZydisFormatterContext
Context structure that that is passed to all formatter.
ZYDIS_NUMERIC_BASE_HEX
@ ZYDIS_NUMERIC_BASE_HEX
Hexadecimal system.
Definition Formatter.h:358
String.h
Provides some internal, more performant, but unsafe helper functions for the ZyanString data-type.
ZYDIS_LETTER_CASE_DEFAULT
@ ZYDIS_LETTER_CASE_DEFAULT
Uses the given text "as is".
Definition String.h:72