Intel® X86 Encoder Decoder
|
These functions are useful for JITs and other uses where one must modify certain fields of instructions after encoding. To modify an instruction, one must encode it (creating an itext array of bytes) and then decode it (so that the patching routines know where the various fields are located.). Once the itext and the decoded instruction are available, certain fields can be modified. More...
Patching decoded instructions | |
XED_DLL_EXPORT xed_bool_t | xed_patch_disp (xed_decoded_inst_t *xedd, xed_uint8_t *itext, xed_enc_displacement_t disp) |
Replace a memory displacement. More... | |
XED_DLL_EXPORT xed_bool_t | xed_patch_brdisp (xed_decoded_inst_t *xedd, xed_uint8_t *itext, xed_encoder_operand_t disp) |
Replace a relative/absolute branch displacement. More... | |
XED_DLL_EXPORT xed_bool_t | xed_patch_imm0 (xed_decoded_inst_t *xedd, xed_uint8_t *itext, xed_encoder_operand_t imm0) |
Replace an imm0 immediate value. More... | |
These functions are useful for JITs and other uses where one must modify certain fields of instructions after encoding. To modify an instruction, one must encode it (creating an itext array of bytes) and then decode it (so that the patching routines know where the various fields are located.). Once the itext and the decoded instruction are available, certain fields can be modified.
The decode step required to create patchable instructions obviously takes additional time so it is suggested one only create patchable instructions once as templates and re-use them as needed.
See examples/xed-ex9-patch.c for an example.
XED_DLL_EXPORT xed_bool_t xed_patch_brdisp | ( | xed_decoded_inst_t * | xedd, |
xed_uint8_t * | itext, | ||
xed_encoder_operand_t | disp | ||
) |
Replace a relative/absolute branch displacement.
The widths of original displacement and replacement must match.
xedd | A decoded instruction. |
itext | The corresponding encoder output, byte array. |
disp | A xed_encoder_operand_t object describing the new displacement. |
XED_DLL_EXPORT xed_bool_t xed_patch_disp | ( | xed_decoded_inst_t * | xedd, |
xed_uint8_t * | itext, | ||
xed_enc_displacement_t | disp | ||
) |
Replace a memory displacement.
The widths of original displacement and replacement must match.
xedd | A decoded instruction. |
itext | The corresponding encoder output, byte array. |
disp | A xed_enc_displacement_t object describing the new displacement. |
XED_DLL_EXPORT xed_bool_t xed_patch_imm0 | ( | xed_decoded_inst_t * | xedd, |
xed_uint8_t * | itext, | ||
xed_encoder_operand_t | imm0 | ||
) |
Replace an imm0 immediate value.
The widths of original immediate and replacement must match.
xedd | A decoded instruction. |
itext | The corresponding encoder output, byte array. |
imm0 | A xed_encoder_operand_t object describing the new immediate. |