Intel® X86 Encoder Decoder
Printing (disassembling) Instructions

There are two primary instruction printing functions: xed_format_generic() and xed_format_context() . Both emit disassembly to a user specified buffer. xed_format_generic() takes all the required information in a pointer to a structure of type xed_print_info_t. In contrast, xed_format_context(), takes its arguments individually. Both versions can take a void* context argument that is passed to an optional symbolic disassembly callback function.
More...

Data Structures

struct  xed_format_options_t
 Options for the disasembly formatting functions. More...
 
struct  xed_print_info_t
 

Typedefs

typedef int(* xed_disassembly_callback_fn_t) (xed_uint64_t address, char *symbol_buffer, xed_uint32_t buffer_length, xed_uint64_t *offset, void *context)
 

Functions

XED_DLL_EXPORT void xed_init_print_info (xed_print_info_t *pi)
 

xed_decoded_inst_t Printers

XED_DLL_EXPORT void xed_decoded_inst_dump (const xed_decoded_inst_t *p, char *buf, int buflen)
 
XED_DLL_EXPORT xed_bool_t xed_decoded_inst_dump_xed_format (const xed_decoded_inst_t *p, char *buf, int buflen, xed_uint64_t runtime_address)
 
XED_DLL_EXPORT xed_bool_t xed_format_context (xed_syntax_enum_t syntax, const xed_decoded_inst_t *xedd, char *out_buffer, int buffer_len, xed_uint64_t runtime_instruction_address, void *context, xed_disassembly_callback_fn_t symbolic_callback)
 Disassemble the decoded instruction using the specified syntax. More...
 
XED_DLL_EXPORT xed_bool_t xed_format_generic (xed_print_info_t *pi)
 

Formatting options

XED_DLL_EXPORT void xed_format_set_options (xed_format_options_t format_options)
 Optionally, customize the disassembly formatting options by passing in a xed_format_options_t structure. More...
 

Detailed Description

There are two primary instruction printing functions: xed_format_generic() and xed_format_context() . Both emit disassembly to a user specified buffer. xed_format_generic() takes all the required information in a pointer to a structure of type xed_print_info_t. In contrast, xed_format_context(), takes its arguments individually. Both versions can take a void* context argument that is passed to an optional symbolic disassembly callback function.

The disassembly dialect (order of operands and formatting) is specified by the xed_syntax_enum_t parameter. For finer control on certain aspects of disassembly, the parameter to xed_format_generic() has a field specifying lower level formatting options (xed_format_options_t).

Typedef Documentation

◆ xed_disassembly_callback_fn_t

typedef int(* xed_disassembly_callback_fn_t) (xed_uint64_t address, char *symbol_buffer, xed_uint32_t buffer_length, xed_uint64_t *offset, void *context)

A xed_disassembly_callback_fn_t takes an address, a pointer to a symbol buffer of buffer_length bytes, and a pointer to an offset. The function fills in the symbol_buffer and sets the offset to the desired offset for that symbol. If the function succeeds, it returns 1.

Parameters
addressThe input address for which we want symbolic name and offset
symbol_bufferA buffer to hold the symbol name. The callback function should fill this in and terminate with a null byte.
buffer_lengthThe maximum length of the symbol_buffer including then null
offsetA pointer to a xed_uint64_t to hold the offset from the provided symbol.
contextThis void* pointer passed to the disassembler's new interface so that the caller can identify the proper context against which to resolve the symbols. The disassembler passes this value to the callback. The legacy formatters that do not have context will pass zero for this parameter.
Returns
0 on failure, 1 on success.

Function Documentation

◆ xed_decoded_inst_dump()

XED_DLL_EXPORT void xed_decoded_inst_dump ( const xed_decoded_inst_t p,
char *  buf,
int  buflen 
)

Print out all the information about the decoded instruction to the buffer buf whose length is maximally buflen. This is for debugging.

◆ xed_decoded_inst_dump_xed_format()

XED_DLL_EXPORT xed_bool_t xed_decoded_inst_dump_xed_format ( const xed_decoded_inst_t p,
char *  buf,
int  buflen,
xed_uint64_t  runtime_address 
)

Print the instruction information in a verbose format. This is for debugging.

Parameters
pa xed_decoded_inst_t for a decoded instruction
bufa buffer to write the disassembly in to.
buflenmaximum length of the disassembly buffer
runtime_addressthe address of the instruction being disassembled. If zero, the offset is printed for relative branches. If nonzero, XED attempts to print the target address for relative branches.
Returns
Returns 0 if the disassembly fails, 1 otherwise.

◆ xed_format_context()

XED_DLL_EXPORT xed_bool_t xed_format_context ( xed_syntax_enum_t  syntax,
const xed_decoded_inst_t xedd,
char *  out_buffer,
int  buffer_len,
xed_uint64_t  runtime_instruction_address,
void *  context,
xed_disassembly_callback_fn_t  symbolic_callback 
)

Disassemble the decoded instruction using the specified syntax.

The output buffer must be at least 25 bytes long. Returns true if disassembly proceeded without errors.

Parameters
syntaxa xed_syntax_enum_t the specifies the disassembly format
xedda xed_decoded_inst_t for a decoded instruction
out_buffera buffer to write the disassembly in to.
buffer_lenmaximum length of the disassembly buffer
runtime_instruction_addressthe address of the instruction being disassembled. If zero, the offset is printed for relative branches. If nonzero, XED attempts to print the target address for relative branches.
contextA void* used only for the call back routine for symbolic disassembly if one is provided. Can be zero.
symbolic_callbackA function pointer for obtaining symbolic disassembly. Can be zero.
Returns
Returns 0 if the disassembly fails, 1 otherwise.

◆ xed_format_generic()

XED_DLL_EXPORT xed_bool_t xed_format_generic ( xed_print_info_t pi)

Disassemble the instruction information to a buffer. See the xed_print_info_t for the required public fields of the argument. This is the preferred method of doing disassembly. The output buffer must be at least 25 bytes long.

Parameters
pia xed_print_info_t
Returns
Returns 0 if the disassembly fails, 1 otherwise.

◆ xed_format_set_options()

XED_DLL_EXPORT void xed_format_set_options ( xed_format_options_t  format_options)

Optionally, customize the disassembly formatting options by passing in a xed_format_options_t structure.

◆ xed_init_print_info()

XED_DLL_EXPORT void xed_init_print_info ( xed_print_info_t pi)