Function xed_sys::xed_decode

source ·
pub unsafe extern "C" fn xed_decode(
    xedd: *mut xed_decoded_inst_t,
    itext: *const u8,
    bytes: c_uint
) -> xed_error_enum_t
Expand description

This is the main interface to the decoder. @param xedd the decoded instruction of type #xed_decoded_inst_t . Mode/state sent in via xedd; See the #xed_state_t @param itext the pointer to the array of instruction text bytes @param bytes the length of the itext input array. 1 to 15 bytes, anything more is ignored. @return #xed_error_enum_t indicating success (#XED_ERROR_NONE) or failure. Note failure can be due to not enough bytes in the input array.

The maximum instruction is 15B and XED will tell you how long the actual instruction is via an API function call xed_decoded_inst_get_length(). However, it is not always safe or advisable for XED to read 15 bytes if the decode location is at the boundary of some sort of protection limit. For example, if one is decoding near the end of a page and the XED user does not want to cause extra page faults, one might send in the number of bytes that would stop at the page boundary. In this case, XED might not be able to decode the instruction and would return an error. The XED user would then have to decide if it was safe to touch the next page and try again to decode with more bytes. Also sometimes the user process does not have read access to the next page and this allows the user to prevent XED from causing process termination by limiting the memory range that XED will access.

@ingroup DEC