Skip to content

Debug disassembling and assembling

Zorg edited this page Nov 19, 2022 · 2 revisions

Assembling & Disassembling

  • debug.assemble(string, instructionPointer=0x0, mode=arch.AUTOMATIC)
  • debug.disassemble(buffer, instructionPointer=0x0, mode=arch.AUTOMATIC)

Assembles and disassembles code using yasm and udis86, respectively (the same tools Bit Slicer uses).

debug.assemble takes a string with instructions delimited by newline characters and returns a buffer resulting in the machine code.

debug.disassemble does the reverse: it takes a buffer and returns the instructions in text as a string.

The instructionPointer is used for calculating relative branch addresses; it's optional and defaults to 0x0.

In Bit Slicer 1.7.12 and later, a mode parameter can be provided if you import arch and pass arch.AUTOMATIC, arch.ARM, or arch.INTEL. The default is arch.AUTOMATIC.

debug.assemble raises a ValueError if unable to assemble the passed string.

debug.disassemble raises a BufferError if the passed buffer is zero length or non-contiguous.