C# Class SharpDisasm.Translators.Translator

All translators must inherit from the abstract class Translator. This base class provides a number of common methods, and defines two abstract methods that must be implemented.
显示文件 Open project: spazzarama/SharpDisasm

Protected Properties

Property Type Description
Content StringBuilder
Registers string[]

Public Methods

Method Description
Translate ( IEnumerable insns ) : string

Abstract method to translate multiple instructions. Classes implementing this method must reset the protected Content member instance and cleanup.

Translate ( Instruction insn ) : string

Abstract method to translate a single instruction. Classes implementing this method must reset the protected Content member instance and cleanup.

Protected Methods

Method Description
RegisterForType ( SharpDisasm type ) : string

Converts a SharpDisasm.Udis86.ud_type into an index into Registers and returns the result.

WriteAddress ( Instruction insn ) : void

Writes the address of the instruction to Content. The width of the address is determined by the ArchitectureMode used during disassembly.

WriteBinary ( Instruction insn ) : void

Writes the instruction binary data to Content. The result is padded to 20 characters (supporting instructions up to 10-bytes long). If the instruction was disassembled without Disassembler.CopyBinaryToInstruction a blank 20 character string will be appended.

ud_syn_print_addr ( Instruction insn, long addr ) : void

TODO: document and rename ported translator methods

ud_syn_print_imm ( Instruction insn, Operand op ) : void

TODO: document and rename ported translator methods

ud_syn_print_mem_disp ( Instruction insn, Operand op, int sign ) : void

TODO: document and rename ported translator methods

ud_syn_rel_target ( Instruction insn, Operand opr ) : ulong

TODO: document and rename ported translator methods

Method Details

RegisterForType() protected method

Converts a SharpDisasm.Udis86.ud_type into an index into Registers and returns the result.
protected RegisterForType ( SharpDisasm type ) : string
type SharpDisasm The register to retrieve the corresponding string for. Note: only the UD_R_* types will result in a valid index.
return string

Translate() public abstract method

Abstract method to translate multiple instructions. Classes implementing this method must reset the protected Content member instance and cleanup.
public abstract Translate ( IEnumerable insns ) : string
insns IEnumerable Collection of instructions to be translated
return string

Translate() public abstract method

Abstract method to translate a single instruction. Classes implementing this method must reset the protected Content member instance and cleanup.
public abstract Translate ( Instruction insn ) : string
insn Instruction The instruction to translate
return string

WriteAddress() protected method

Writes the address of the instruction to Content. The width of the address is determined by the ArchitectureMode used during disassembly.
protected WriteAddress ( Instruction insn ) : void
insn Instruction The instruction to append the address of.
return void

WriteBinary() protected method

Writes the instruction binary data to Content. The result is padded to 20 characters (supporting instructions up to 10-bytes long). If the instruction was disassembled without Disassembler.CopyBinaryToInstruction a blank 20 character string will be appended.
protected WriteBinary ( Instruction insn ) : void
insn Instruction The instruction of which to append the binary data for
return void

ud_syn_print_addr() protected method

TODO: document and rename ported translator methods
protected ud_syn_print_addr ( Instruction insn, long addr ) : void
insn Instruction
addr long
return void

ud_syn_print_imm() protected method

TODO: document and rename ported translator methods
protected ud_syn_print_imm ( Instruction insn, Operand op ) : void
insn Instruction
op Operand
return void

ud_syn_print_mem_disp() protected method

TODO: document and rename ported translator methods
protected ud_syn_print_mem_disp ( Instruction insn, Operand op, int sign ) : void
insn Instruction
op Operand
sign int
return void

ud_syn_rel_target() protected method

TODO: document and rename ported translator methods
protected ud_syn_rel_target ( Instruction insn, Operand opr ) : ulong
insn Instruction
opr Operand
return ulong

Property Details

Content protected_oe property

The content being generated by the current call to the translator
protected StringBuilder Content
return StringBuilder

Registers protected_oe static_oe property

A list of all registers names
protected static string[] Registers
return string[]