pex.arch.x86
¶
Module Contents¶
- class pex.arch.x86.X86¶
Bases:
object
Subclass of pex.arch module.
This subclass of pex.arch module is intended for providing implementations of some x86 architecture features.
- get_reg_num(reg: str) int ¶
Get register number from a register name.
- Parameters:
reg (str) – register name
- Return int:
register number
- jmp_reg(dest: str) bytes ¶
Pack jmp x86 assembler instruction.
- Parameters:
dest (str) – destination register name
- Return bytes:
packed jmp x86 assembler instruction
- static pack_dword(num: int) bytes ¶
Pack integer as double word.
- Parameters:
num (int) – integer to pack
- Return bytes:
packed dword
- static pack_word(num: int) bytes ¶
Pack integer as word.
- Parameters:
num (int) – integer to pack
- Return bytes:
packed word
- pack_lsb(num: int) bytes ¶
Pack integer as least significant bit.
- Parameters:
num (int) – integer to pack
- Return bytes:
packed lsb
- static unpack_dword(dword: bytes) int ¶
Unpack double word as integer.
- Parameters:
dword (bytes) – double word to unpack
- Return int:
unpacked integer
- static unpack_word(word: bytes) int ¶
Unpack word as integer.
- Parameters:
word (bytes) – word to unpack
- Return int:
unpacked integer
- static push_byte(byte: int) bytes ¶
Pack push byte x86 assembler instruction.
- Parameters:
byte (int) – integer to pack as byte and push
- Return bytes:
packed push byte x86 assembler instruction
- mov_byte(byte: int, dest: str) bytes ¶
Pack mov byte x86 assembler instruction.
- Parameters:
byte (int) – int to pack as byte and mov
dest (str) – destination register name
- Return bytes:
packed mov byte x86 assembler instruction
- mov_word(num: int, dest: str) bytes ¶
Pack mov word x86 assembler instruction.
- Parameters:
num (int) – integer to pack as word and mov
dest (str) – destination register name
- Return bytes:
packed mov word x86 assembler instruction
- mov_dword(num: int, dest: str) bytes ¶
Pack mov dword x86 assembler instruction.
- Parameters:
num (int) – integer to pack as dword and mov
dest (str) – destination register name
- Return bytes:
packed mov dword x86 assembler instruction
- push_dword(num: int) bytes ¶
Pack push dword x86 assembler instruction.
- Parameters:
num (int) – integer to pack as dword and push
- Return bytes:
packed push dword x86 assembler instruction
- push_word(num: int) bytes ¶
Pack push word x86 assembler instruction.
- Parameters:
num (int) – integer to pack as word and push
- Return bytes:
packed push word x86 assembler instruction
- pop_dword(dest: str) bytes ¶
Pack pop dword x86 assembler instruction.
- Parameters:
dest (str) – destination register name
- Return bytes:
packed pop dword x86 assembler instruction
- dword_adjust(dword: bytes, num: int = 0) bytes ¶
Adjust an integer to a double word.
- Parameters:
dword (bytes) – double word to adjust to
num (int) – integer to adjust
- Return bytes:
dword with adjusted integer
- word_adjust(word: bytes, num: int = 0) bytes ¶
Adjust an integer to a word.
- Parameters:
word (bytes) – word to adjust to
num (int) – integer to adjust
- Return bytes:
word with adjusted integer
- loop(offset: int) bytes ¶
Pack loop x86 assembler instruction.
- Parameters:
offset (int) – loop x86 assembler instruction offset
- Return bytes:
packed loop x86 assembly instruction
- jmp(addr: int) bytes ¶
Pack jmp x86 assembler instruction.
- Parameters:
addr (int) – address to jump to
- Return bytes:
packed jmp x86 assembler instruction
- jmp_short(addr: int) bytes ¶
Pack jmp short x86 assembler instruction.
- Parameters:
addr (int) – address to jump to
- Return bytes:
packed jmp short x86 assembler instruction
- call(addr: int) bytes ¶
Pack call x86 assembler instruction.
- Parameters:
addr (int) – address to call
- Return bytes:
packed call x86 assembler instruction
- static rel_number(num: int, delta: int = 0) int ¶
Get a number offset to the supplied string.
- Parameters:
num (int) – number
delta (int) – delta to add to a result
- Return int:
offset
- copy_to_stack(length: int) bytes ¶
Generate a buffer that will copy memory immediately following the stub that is generated to be copied to the stack.
- Parameters:
length (int) – length of a stub
- Return bytes:
buffer that will copy memory immediately following the stub that us generated to be copied to the stack
- searcher(tag: bytes) bytes ¶
Generate a tag-based search routine.
- Parameters:
tag (bytes) – tag to search for
- Return bytes:
tag-based search routine
- encode_effective(shift: int, reg: str) bytes ¶
Generate encoded effective value for a register.
- Parameters:
shift (int) – effective encoding shift
reg (str) – register name
- Return bytes:
encoded effective value
- encode_modrm(src: str, dest: str) bytes ¶
Generate mod r/m characted for a source and destination registers.
- Parameters:
src (str) – source register name
dest (str) – destination register name
- Return bytes:
mod r/m character
- static fpu_instructions() list ¶
Get all floating-point unit x86 assembler instructions.
- Return list:
list of FPU instructions as bytes