C# Class SharpDisasm.Disassembler

Provides a simple wrapper around the C# ported udis86 library.
Inheritance: IDisposable
Show file Open project: spazzarama/SharpDisasm Class Usage Examples

Public Properties

Property Type Description
Address ulong
Architecture ArchitectureMode
CopyBinaryToInstruction bool
Translator SharpDisasm.Translators.Translator
Vendor Vendor

Public Methods

Method Description
Disassemble ( ) : IEnumerable

Disassemble instructions and yield the result. Breaking out of the enumerator will prevent further instructions being disassembled.

Disassembler ( IAssemblyCode code, ArchitectureMode architecture, ulong address = 0x0, bool copyBinaryToInstruction = false, Vendor vendor = Vendor.Any ) : System

Initializes a new instance of the Disassembler class.

Disassembler ( IntPtr codePtr, int codeLength, ArchitectureMode architecture, ulong address = 0x0, bool copyBinaryToInstruction = false, Vendor vendor = Vendor.Any ) : System

Prepares a new disassembler instance for the code located at the memory address provided. The instructions can then be disassembled with a call to Disassemble. The base address used to resolve relative addresses should be provided in address.

Disassembler ( byte code, ArchitectureMode architecture, ulong address = 0x0, bool copyBinaryToInstruction = false, Vendor vendor = Vendor.Any ) : System

Prepares a new disassembler instance for the code provided. The instructions can then be disassembled with a call to Disassemble. The base address used to resolve relative addresses should be provided in address.

Dispose ( ) : void

Dispose

NextInstruction ( ) : Instruction

Decodes a single instruction and increments buffer position.

Reset ( ) : void

Reset to beginning of the buffer

Private Methods

Method Description
InitUdis86 ( ) : void

(Re)Initialise the udis86 disassembler

Method Details

Disassemble() public method

Disassemble instructions and yield the result. Breaking out of the enumerator will prevent further instructions being disassembled.
public Disassemble ( ) : IEnumerable
return IEnumerable

Disassembler() public method

Initializes a new instance of the Disassembler class.
public Disassembler ( IAssemblyCode code, ArchitectureMode architecture, ulong address = 0x0, bool copyBinaryToInstruction = false, Vendor vendor = Vendor.Any ) : System
code IAssemblyCode The code.
architecture ArchitectureMode The architecture.
address ulong The address.
copyBinaryToInstruction bool if set to true [copy binary to instruction].
vendor Vendor The vendor.
return System

Disassembler() public method

Prepares a new disassembler instance for the code located at the memory address provided. The instructions can then be disassembled with a call to Disassemble. The base address used to resolve relative addresses should be provided in address.
public Disassembler ( IntPtr codePtr, int codeLength, ArchitectureMode architecture, ulong address = 0x0, bool copyBinaryToInstruction = false, Vendor vendor = Vendor.Any ) : System
codePtr System.IntPtr A pointer to memory to be disassembled.
codeLength int The maximum length to be disassembled.
architecture ArchitectureMode The architecture of the code (e.g. 64-bit, 32-bit or 16-bit).
address ulong The address of the first byte of code. This value is used to resolve relative addresses into absolute addresses while disassembling.
copyBinaryToInstruction bool Keeps a copy of the binary code for the instruction. This will increase the memory usage for each instruction. This is necessary if planning on using the option.
vendor Vendor What vendors to support for disassembly, default is Any. Other options are AMD or Intel.
return System

Disassembler() public method

Prepares a new disassembler instance for the code provided. The instructions can then be disassembled with a call to Disassemble. The base address used to resolve relative addresses should be provided in address.
public Disassembler ( byte code, ArchitectureMode architecture, ulong address = 0x0, bool copyBinaryToInstruction = false, Vendor vendor = Vendor.Any ) : System
code byte The code to be disassembled
architecture ArchitectureMode The target x86 instruction set architecture of the code (e.g. 64-bit, 32-bit or 16-bit).
address ulong The address of the first byte of code. This value is used to resolve relative addresses into absolute addresses while disassembling.
copyBinaryToInstruction bool Keeps a copy of the binary code for the instruction. This will increase the memory usage for each instruction. This is necessary if planning on using the option.
vendor Vendor What vendor instructions to support during disassembly, default is Any. Other options are AMD or Intel.
return System

Dispose() public method

Dispose
public Dispose ( ) : void
return void

NextInstruction() public method

Decodes a single instruction and increments buffer position.
public NextInstruction ( ) : Instruction
return Instruction

Reset() public method

Reset to beginning of the buffer
public Reset ( ) : void
return void

Property Details

Address public property

The address
public ulong Address
return ulong

Architecture public property

The x86 CPU architecture to use: 16-bit, 32-bit or 64-bit.
public ArchitectureMode Architecture
return ArchitectureMode

CopyBinaryToInstruction public property

Copies the source binary to the decoded instructions. When true this option increases the memory required for each decoded instruction.
public bool CopyBinaryToInstruction
return bool

Translator public static property

The translator that will be used when calling Instruction.ToString.
public static SharpDisasm.Translators.Translator Translator
return SharpDisasm.Translators.Translator

Vendor public property

Which vendor instructions to support for disassembly. Options are AMD, Intel or Any.
public Vendor Vendor
return Vendor