Path: blob/master/dep/zydis/include/Zydis/Internal/FormatterATT.h
4219 views
/***************************************************************************************************12Zyan Disassembler Library (Zydis)34Original Author : Florian Bernd, Joel Hoener56* Permission is hereby granted, free of charge, to any person obtaining a copy7* of this software and associated documentation files (the "Software"), to deal8* in the Software without restriction, including without limitation the rights9* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell10* copies of the Software, and to permit persons to whom the Software is11* furnished to do so, subject to the following conditions:12*13* The above copyright notice and this permission notice shall be included in all14* copies or substantial portions of the Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE19* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,21* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE22* SOFTWARE.2324***************************************************************************************************/2526/**27* @file28* Implements the `AT&T` style instruction-formatter.29*/3031#ifndef ZYDIS_FORMATTER_ATT_H32#define ZYDIS_FORMATTER_ATT_H3334#include <Zydis/Formatter.h>35#include <Zydis/Internal/FormatterBase.h>36#include <Zydis/Internal/String.h>3738#ifdef __cplusplus39extern "C" {40#endif4142/* ============================================================================================== */43/* Formatter functions */44/* ============================================================================================== */4546/* ---------------------------------------------------------------------------------------------- */47/* Instruction */48/* ---------------------------------------------------------------------------------------------- */4950ZyanStatus ZydisFormatterATTFormatInstruction(const ZydisFormatter* formatter,51ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);5253/* ---------------------------------------------------------------------------------------------- */54/* Operands */55/* ---------------------------------------------------------------------------------------------- */5657ZyanStatus ZydisFormatterATTFormatOperandMEM(const ZydisFormatter* formatter,58ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);5960/* ---------------------------------------------------------------------------------------------- */61/* Elemental tokens */62/* ---------------------------------------------------------------------------------------------- */6364ZyanStatus ZydisFormatterATTPrintMnemonic(const ZydisFormatter* formatter,65ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);6667ZyanStatus ZydisFormatterATTPrintRegister(const ZydisFormatter* formatter,68ZydisFormatterBuffer* buffer, ZydisFormatterContext* context, ZydisRegister reg);6970ZyanStatus ZydisFormatterATTPrintAddressABS(const ZydisFormatter* formatter,71ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);7273ZyanStatus ZydisFormatterATTPrintDISP(const ZydisFormatter* formatter,74ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);7576ZyanStatus ZydisFormatterATTPrintIMM(const ZydisFormatter* formatter,77ZydisFormatterBuffer* buffer, ZydisFormatterContext* context);7879/* ---------------------------------------------------------------------------------------------- */8081/* ============================================================================================== */82/* Fomatter presets */83/* ============================================================================================== */8485/* ---------------------------------------------------------------------------------------------- */86/* AT&T */87/* ---------------------------------------------------------------------------------------------- */8889/**90* The default formatter configuration for `AT&T` style disassembly.91*/92static const ZydisFormatter FORMATTER_ATT =93{94/* style */ ZYDIS_FORMATTER_STYLE_ATT,95/* force_memory_size */ ZYAN_FALSE,96/* force_memory_seg */ ZYAN_FALSE,97/* force_memory_scale */ ZYAN_TRUE,98/* force_relative_branches */ ZYAN_FALSE,99/* force_relative_riprel */ ZYAN_FALSE,100/* print_branch_size */ ZYAN_FALSE,101/* detailed_prefixes */ ZYAN_FALSE,102/* addr_base */ ZYDIS_NUMERIC_BASE_HEX,103/* addr_signedness */ ZYDIS_SIGNEDNESS_SIGNED,104/* addr_padding_absolute */ ZYDIS_PADDING_AUTO,105/* addr_padding_relative */ 2,106/* disp_base */ ZYDIS_NUMERIC_BASE_HEX,107/* disp_signedness */ ZYDIS_SIGNEDNESS_SIGNED,108/* disp_padding */ 2,109/* imm_base */ ZYDIS_NUMERIC_BASE_HEX,110/* imm_signedness */ ZYDIS_SIGNEDNESS_AUTO,111/* imm_padding */ 2,112/* case_prefixes */ ZYDIS_LETTER_CASE_DEFAULT,113/* case_mnemonic */ ZYDIS_LETTER_CASE_DEFAULT,114/* case_registers */ ZYDIS_LETTER_CASE_DEFAULT,115/* case_typecasts */ ZYDIS_LETTER_CASE_DEFAULT,116/* case_decorators */ ZYDIS_LETTER_CASE_DEFAULT,117/* hex_uppercase */ ZYAN_TRUE,118/* hex_force_leading_number */ ZYAN_FALSE,119/* number_format */120{121// ZYDIS_NUMERIC_BASE_DEC122{123// Prefix124{125/* string */ ZYAN_NULL,126/* string_data */ ZYAN_DEFINE_STRING_VIEW(""),127/* buffer */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },128},129// Suffix130{131/* string */ ZYAN_NULL,132/* string_data */ ZYAN_DEFINE_STRING_VIEW(""),133/* buffer */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },134}135},136// ZYDIS_NUMERIC_BASE_HEX137{138// Prefix139{140/* string */ &FORMATTER_ATT.number_format[141ZYDIS_NUMERIC_BASE_HEX][0].string_data,142/* string_data */ ZYAN_DEFINE_STRING_VIEW("0x"),143/* buffer */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },144},145// Suffix146{147/* string */ ZYAN_NULL,148/* string_data */ ZYAN_DEFINE_STRING_VIEW(""),149/* buffer */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },150}151}152},153/* func_pre_instruction */ ZYAN_NULL,154/* func_post_instruction */ ZYAN_NULL,155/* func_format_instruction */ &ZydisFormatterATTFormatInstruction,156/* func_pre_operand */ ZYAN_NULL,157/* func_post_operand */ ZYAN_NULL,158/* func_format_operand_reg */ &ZydisFormatterBaseFormatOperandREG,159/* func_format_operand_mem */ &ZydisFormatterATTFormatOperandMEM,160/* func_format_operand_ptr */ &ZydisFormatterBaseFormatOperandPTR,161/* func_format_operand_imm */ &ZydisFormatterBaseFormatOperandIMM,162/* func_print_mnemonic */ &ZydisFormatterATTPrintMnemonic,163/* func_print_register */ &ZydisFormatterATTPrintRegister,164/* func_print_address_abs */ &ZydisFormatterATTPrintAddressABS,165/* func_print_address_rel */ &ZydisFormatterBasePrintAddressREL,166/* func_print_disp */ &ZydisFormatterATTPrintDISP,167/* func_print_imm */ &ZydisFormatterATTPrintIMM,168/* func_print_typecast */ ZYAN_NULL,169/* func_print_segment */ &ZydisFormatterBasePrintSegment,170/* func_print_prefixes */ &ZydisFormatterBasePrintPrefixes,171/* func_print_decorator */ &ZydisFormatterBasePrintDecorator172};173174/* ---------------------------------------------------------------------------------------------- */175176/* ============================================================================================== */177178#ifdef __cplusplus179}180#endif181182#endif // ZYDIS_FORMATTER_ATT_H183184185