- Main Page
- Modules
- Data Structures
- Files

- Search for |

# Printing (disassembling) Instructions

## Data Structures

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

## Legacy printers without context parameter

XED_DLL_EXPORT xed_bool_t | xed_format (xed_syntax_enum_t syntax, const xed_decoded_inst_t *xedd, char *out_buffer, int buffer_len, xed_uint64_t runtime_instruction_address)
| Disassemble the decoded instruction using the specified syntax.
XED_DLL_EXPORT xed_bool_t | xed_format_att (const xed_decoded_inst_t *xedd, char *out_buffer, xed_uint32_t buffer_len, xed_uint64_t runtime_instruction_address)
| Disassemble the decoded instruction using the ATT SYSV syntax.
XED_DLL_EXPORT xed_bool_t | xed_format_intel (const xed_decoded_inst_t *xedd, char *out_buffer, xed_uint32_t buffer_len, xed_uint64_t runtime_instruction_address)
| Disassemble the decoded instruction using the Intel syntax.
XED_DLL_EXPORT xed_bool_t | xed_format_xed (const xed_decoded_inst_t *xedd, char *out_buffer, xed_uint32_t buffer_len, xed_uint64_t runtime_instruction_address)
| Disassemble the decoded instruction using the XED syntax providing all operand resources (implicit, explicit, suppressed).

## Printers with context parameter

XED_DLL_EXPORT xed_bool_t | xed_format_att_context (const xed_decoded_inst_t *xedd, char *out_buffer, xed_uint32_t buffer_len, xed_uint64_t runtime_instruction_address, void *context)
| Disassemble the decoded instruction using the ATT SYSV syntax.
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)
| Disassemble the decoded instruction using the specified syntax.
XED_DLL_EXPORT xed_bool_t | xed_format_intel_context (const xed_decoded_inst_t *xedd, char *out_buffer, xed_uint32_t buffer_len, xed_uint64_t runtime_instruction_address, void *context)
| Disassemble the decoded instruction using the Intel syntax.

## 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.

## 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_register_disassembly_callback (xed_disassembly_callback_fn_t f)
| Register a disassembly call back function of type xed_disassembly_callback_fn_t to get called when the disassembler needs to get a symbol and offset for an address.

## Detailed Description

There are two kinds of printers. The legacy printers to not take a void* context parameter. The other printers take a void* context parameter that is only passed to a callback function registered by calling xed_register_disassembly_callback(). The callback is used for symbolic disassembly.

If using the callback, register a callback once before you program creates its threads.

## Typedef Documentation

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)

Parameters:

  | address | The input address for which we want symbolic name and offset
  | symbol_buffer | A buffer to hold the symbol name. The callback function should fill this in and terminate with a null byte.
  | buffer_length | The maximum length of the symbol_buffer including then null
  | offset | A pointer to a xed_uint64_t to hold the offset from the provided symbol.
  | context | This 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.

Definition at line 58 of file xed-disas.h.

## Function Documentation

XED_DLL_EXPORT xed_bool_t xed_format | ( | xed_syntax_enum_t | syntax,
|  | const xed_decoded_inst_t * | xedd,
|  | char * | out_buffer,
|  | int | buffer_len,
|  | xed_uint64_t | runtime_instruction_address
| ) |

| 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:

  | syntax | a xed_syntax_enum_t the specifies the disassembly format
  | xedd | a xed_decoded_inst_t for a decoded instruction
  | out_buffer | a buffer to write the disassembly in to.
  | buffer_len | maximum length of the disassembly buffer
  | runtime_instruction_address | the 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_DLL_EXPORT xed_bool_t xed_format_att | ( | const xed_decoded_inst_t * | xedd,
|  | char * | out_buffer,
|  | xed_uint32_t | buffer_len,
|  | xed_uint64_t | runtime_instruction_address
| ) |

| Disassemble the decoded instruction using the ATT SYSV syntax. The output buffer must be at least 16 bytes long. Returns true if disassembly proceeded without errors.

Parameters:

  | xedd | a xed_decoded_inst_t for a decoded instruction
  | out_buffer | a buffer to write the disassembly in to.
  | buffer_len | maximum length of the disassembly buffer
  | runtime_instruction_address | the 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_DLL_EXPORT xed_bool_t xed_format_att_context | ( | const xed_decoded_inst_t * | xedd,
|  | char * | out_buffer,
|  | xed_uint32_t | buffer_len,
|  | xed_uint64_t | runtime_instruction_address,
|  | void * | context
| ) |

| Disassemble the decoded instruction using the ATT SYSV syntax. The output buffer must be at least 16 bytes long. Returns true if disassembly proceeded without errors.

Parameters:

  | xedd | a xed_decoded_inst_t for a decoded instruction
  | out_buffer | a buffer to write the disassembly in to.
  | buffer_len | maximum length of the disassembly buffer
  | runtime_instruction_address | the 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.
  | context | A void* used only for the call back routine for symbolic disassembly if one is registered.

Returns:
  Returns 0 if the disassembly fails, 1 otherwise.

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
| ) |

| 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:

  | syntax | a xed_syntax_enum_t the specifies the disassembly format
  | xedd | a xed_decoded_inst_t for a decoded instruction
  | out_buffer | a buffer to write the disassembly in to.
  | buffer_len | maximum length of the disassembly buffer
  | runtime_instruction_address | the 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.
  | context | A void* used only for the call back routine for symbolic disassembly if one is registered.

Returns:
  Returns 0 if the disassembly fails, 1 otherwise.

XED_DLL_EXPORT xed_bool_t xed_format_intel | ( | const xed_decoded_inst_t * | xedd,
|  | char * | out_buffer,
|  | xed_uint32_t | buffer_len,
|  | xed_uint64_t | runtime_instruction_address
| ) |

| Disassemble the decoded instruction using the Intel syntax. The output buffer must be at least 16 bytes long. Returns true if disassembly proceeded without errors.

Parameters:

  | xedd | a xed_decoded_inst_t for a decoded instruction
  | out_buffer | a buffer to write the disassembly in to.
  | buffer_len | maximum length of the disassembly buffer
  | runtime_instruction_address | the 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_DLL_EXPORT xed_bool_t xed_format_intel_context | ( | const xed_decoded_inst_t * | xedd,
|  | char * | out_buffer,
|  | xed_uint32_t | buffer_len,
|  | xed_uint64_t | runtime_instruction_address,
|  | void * | context
| ) |

| Disassemble the decoded instruction using the Intel syntax. The output buffer must be at least 16 bytes long. Returns true if disassembly proceeded without errors.

Parameters:

  | xedd | a xed_decoded_inst_t for a decoded instruction
  | out_buffer | a buffer to write the disassembly in to.
  | buffer_len | maximum length of the disassembly buffer
  | runtime_instruction_address | the 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.
  | context | A void* used only for the call back routine for symbolic disassembly if one is registered.

Returns:
  Returns 0 if the disassembly fails, 1 otherwise.

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_DLL_EXPORT xed_bool_t xed_format_xed | ( | const xed_decoded_inst_t * | xedd,
|  | char * | out_buffer,
|  | xed_uint32_t | buffer_len,
|  | xed_uint64_t | runtime_instruction_address
| ) |

| Disassemble the decoded instruction using the XED syntax providing all operand resources (implicit, explicit, suppressed). The output buffer must be at least 25 bytes long. Returns true if disassembly proceeded without errors.

Parameters:

  | xedd | a xed_decoded_inst_t for a decoded instruction
  | out_buffer | a buffer to write the disassembly in to.
  | buffer_len | maximum length of the disassembly buffer
  | runtime_instruction_address | the 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_DLL_EXPORT void xed_register_disassembly_callback | ( | xed_disassembly_callback_fn_t | f | ) |

| Register a disassembly call back function of type xed_disassembly_callback_fn_t to get called when the disassembler needs to get a symbol and offset for an address.