ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DisassemblerX86 Class Reference

Disassembler for the x86 architecture. More...

#include <DisassemblerX86.h>

Inheritance diagram for DisassemblerX86:
Collaboration diagram for DisassemblerX86:

Classes

class  ExceptionX86
 Same as Disassembler::Exception except with a different constructor for ease of use in DisassemblerX86. More...
 

Public Member Functions

 DisassemblerX86 (size_t wordsize)
 
 DisassemblerX86 (const DisassemblerX86 &other)
 
virtual ~DisassemblerX86 ()
 
virtual DisassemblerX86clone () const
 Creates a new copy of a disassembler. More...
 
virtual bool can_disassemble (SgAsmGenericHeader *) const
 See Disassembler::can_disassemble. More...
 
virtual SgAsmInstructiondisassembleOne (const MemoryMap *map, rose_addr_t start_va, AddressSet *successors=NULL)
 See Disassembler::disassembleOne. More...
 
virtual SgAsmInstructionmake_unknown_instruction (const Exception &)
 Make an unknown instruction from an exception. More...
 
- Public Member Functions inherited from Disassembler
 Disassembler ()
 
 Disassembler (const Disassembler &other)
 
virtual ~Disassembler ()
 
void disassemble (SgAsmInterpretation *, AddressSet *successors=NULL, BadMap *bad=NULL)
 This high-level method disassembles instructions belonging to part of a file described by an executable file header as indicated by the specified interpretation. More...
 
void set_registers (const RegisterDictionary *rdict)
 Specifies the registers available on this architecture. More...
 
const RegisterDictionaryget_registers () const
 Returns the dictionary used for looking up register names. More...
 
void set_partitioner (class Partitioner *p)
 Specifies the instruction partitioner to use when partitioning instructions into functions. More...
 
class Partitionerget_partitioner () const
 Returns the partitioner object set by set_partitioner(). More...
 
void set_search (unsigned bits)
 Specifies the heuristics used when searching for instructions. More...
 
unsigned get_search () const
 Returns a bit mask of SearchHeuristic bits representing which heuristics would be used when searching for instructions. More...
 
void set_wordsize (size_t)
 Specifies the word size for the SEARCH_WORDS heuristic. More...
 
size_t get_wordsize () const
 Returns the word size used by the SEARCH_WORDS heuristic. More...
 
void set_alignment (size_t)
 Specifies the alignment for the SEARCH_WORDS heuristic. More...
 
size_t get_alignment () const
 Returns the alignment used by the SEARCH_WORDS heuristic. More...
 
void set_sex (ByteOrder::Endianness sex)
 Specifies the byte order for the SEARCH_WORDS heuristic. More...
 
ByteOrder::Endianness get_sex () const
 Returns the byte order used by the SEARCH_WORDS heuristic. More...
 
void set_debug (FILE *f)
 Sends disassembler diagnostics to the specified output stream. More...
 
FILE * get_debug () const
 Returns the file currently used for debugging; null implies no debugging. More...
 
size_t get_ndisassembled () const
 Returns the number of instructions successfully disassembled. More...
 
void set_protection (unsigned bitvec)
 Normally the disassembler will only read memory when the execute permission is turned on for the memory. More...
 
unsigned get_protection () const
 Returns a bit vector describing which bits must be enabled in the MemoryMap in order for the disassembler to read from that memory. More...
 
void set_progress_reporting (FILE *, unsigned min_interval)
 Set progress reporting properties. More...
 
SgAsmInstructiondisassembleOne (const unsigned char *buf, rose_addr_t buf_va, size_t buf_size, rose_addr_t start_va, AddressSet *successors=NULL)
 Similar in functionality to the disassembleOne method that takes a MemoryMap argument, except the content buffer is mapped 1:1 to virtual memory beginning at the specified address. More...
 
InstructionMap disassembleBlock (const MemoryMap *map, rose_addr_t start_va, AddressSet *successors=NULL, InstructionMap *cache=NULL)
 Like the disassembleOne method except it disassembles a basic block's worth of instructions beginning at the specified virtual address. More...
 
InstructionMap disassembleBlock (const unsigned char *buf, rose_addr_t buf_va, size_t buf_size, rose_addr_t start_va, AddressSet *successors=NULL, InstructionMap *cache=NULL)
 Similar in functionality to the disassembleBlock method that takes a MemoryMap argument, except the supplied buffer is mapped 1:1 to virtual memory beginning at the specified address. More...
 
InstructionMap disassembleBuffer (const MemoryMap *map, size_t start_va, AddressSet *successors=NULL, BadMap *bad=NULL)
 Disassembles instructions from the content buffer beginning at the specified virtual address and including all instructions that are direct or indirect successors of the first instruction. More...
 
InstructionMap disassembleBuffer (const unsigned char *buf, rose_addr_t buf_va, size_t buf_size, rose_addr_t start_va, AddressSet *successors=NULL, BadMap *bad=NULL)
 Similar in functionality to the disassembleBuffer methods that take a MemoryMap argument, except the supplied buffer is mapped 1:1 to virtual memory beginning at the specified address. More...
 
InstructionMap disassembleBuffer (const MemoryMap *map, AddressSet workset, AddressSet *successors=NULL, BadMap *bad=NULL)
 Similar in functionality to the disassembleBuffer methods that take a single starting virtual address, except this one tries to disassemble from all the addresses specified in the workset. More...
 
InstructionMap disassembleSection (SgAsmGenericSection *section, rose_addr_t section_va, rose_addr_t start_offset, AddressSet *successors=NULL, BadMap *bad=NULL)
 Disassembles instructions in the specified section by assuming that it's mapped to a particular starting address. More...
 
InstructionMap disassembleInterp (SgAsmInterpretation *interp, AddressSet *successors=NULL, BadMap *bad=NULL)
 Disassembles instructions in a particular binary interpretation. More...
 
void search_following (AddressSet *worklist, const InstructionMap &bb, rose_addr_t bb_va, const MemoryMap *map, const InstructionMap &tried)
 Adds the address following a basic block to the list of addresses that should be disassembled. More...
 
void search_immediate (AddressSet *worklist, const InstructionMap &bb, const MemoryMap *map, const InstructionMap &tried)
 Adds values of immediate operands to the list of addresses that should be disassembled. More...
 
void search_words (AddressSet *worklist, const MemoryMap *map, const InstructionMap &tried)
 Adds all word-aligned values to work list, provided they specify a virtual address in the map. More...
 
void search_next_address (AddressSet *worklist, rose_addr_t start_va, const MemoryMap *map, const InstructionMap &insns, const InstructionMap &tried, bool avoid_overlaps)
 Finds the lowest virtual address, greater than or equal to start_va, which does not correspond to a previous disassembly attempt as evidenced by its presence in the supplied instructions or bad map. More...
 
void search_function_symbols (AddressSet *worklist, const MemoryMap *, SgAsmGenericHeader *)
 Adds addresses that correspond to function symbols. More...
 
void update_progress (SgAsmInstruction *)
 Updates progress information. More...
 
void progress (FILE *, const char *fmt,...) const __attribute__((format(printf
 Conditionally prints a progress report. More...
 
void mark_referenced_instructions (SgAsmInterpretation *, const MemoryMap *, const InstructionMap &)
 Marks parts of the file that correspond to instructions as having been referenced. More...
 
AddressSet get_block_successors (const InstructionMap &, bool *complete)
 Calculates the successor addresses of a basic block and adds them to a successors set. More...
 

Private Types

enum  RegisterMode {
  rmLegacyByte,
  rmRexByte,
  rmWord,
  rmDWord,
  rmQWord,
  rmSegment,
  rmST,
  rmMM,
  rmXMM,
  rmControl,
  rmDebug,
  rmReturnNull
}
 ModR/M settings that create register expressions (or rmReturnNull for no register) More...
 
enum  MMPrefix {
  mmNone,
  mmF3,
  mm66,
  mmF2
}
 

Private Member Functions

uint8_t getByte ()
 Returns the next byte of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction(). More...
 
uint16_t getWord ()
 Returns the next two-byte, little endian word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction(). More...
 
uint32_t getDWord ()
 Returns the next four-byte, little endian double word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction(). More...
 
uint64_t getQWord ()
 Returns the next eight-byte, little endian quad word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction(). More...
 
SgAsmExpressioncurrentDataSegment () const
 Constructs a register reference expression for the current data segment based on whether a segment override prefix has been encountered. More...
 
X86InstructionSize effectiveAddressSize () const
 Returns the size of instruction addresses. More...
 
RegisterMode effectiveOperandMode () const
 Returns the register mode for the instruction's effective operand size. More...
 
X86InstructionSize effectiveOperandSize () const
 Returns the size of the operands. More...
 
SgAsmTypeeffectiveOperandType () const
 Returns the data type for the instruction's effective operand size. More...
 
bool longMode () const
 Returns true if we're disassembling 64-bit code. More...
 
MMPrefix mmPrefix () const
 
void not64 () const
 Throws an exception if the instruction being disassembled is not valid for 64-bit mode. More...
 
void setRex (uint8_t prefix)
 Sets the rexPresent flag along with rexW, rexR, rexX, and/or rexB based on the instruction prefix, which should be a value between 0x40 and 0x4f, inclusive. More...
 
SgAsmExpressionmakeAddrSizeValue (int64_t val, size_t bit_offset, size_t bit_size)
 Constructs an expression for the specified address size. More...
 
SgAsmx86InstructionmakeInstruction (X86InstructionKind kind, const std::string &mnemonic, SgAsmExpression *op1=NULL, SgAsmExpression *op2=NULL, SgAsmExpression *op3=NULL, SgAsmExpression *op4=NULL)
 Creates an instruction with optional operands. More...
 
SgAsmx86RegisterReferenceExpressionmakeIP ()
 Constructs a register reference expression for the instruction pointer register. More...
 
SgAsmx86RegisterReferenceExpressionmakeOperandRegisterByte (bool rexExtension, uint8_t registerNumber)
 
SgAsmx86RegisterReferenceExpressionmakeOperandRegisterFull (bool rexExtension, uint8_t registerNumber)
 
SgAsmx86RegisterReferenceExpressionmakeRegister (uint8_t fullRegisterNumber, RegisterMode, SgAsmType *registerType=NULL) const
 Constructs a register reference expression. More...
 
SgAsmx86RegisterReferenceExpressionmakeRegisterEffective (uint8_t fullRegisterNumber)
 
SgAsmx86RegisterReferenceExpressionmakeRegisterEffective (bool rexExtension, uint8_t registerNumber)
 
SgAsmExpressionmakeSegmentRegister (X86SegmentRegister so, bool insn64) const
 Constructs a register reference expression for a segment register. More...
 
void getModRegRM (RegisterMode regMode, RegisterMode rmMode, SgAsmType *t, SgAsmType *tForReg=NULL)
 Decodes the ModR/M byte of an instruction. More...
 
SgAsmMemoryReferenceExpressiondecodeModrmMemory ()
 Decodes the ModR/M byte to a memory reference expression. More...
 
void fillInModRM (RegisterMode rmMode, SgAsmType *t)
 If ModR/M is a memory reference, fill in its type; otherwise, make a register with the appropriate mode and put it into the modrm data member. More...
 
SgAsmExpressionmakeModrmNormal (RegisterMode, SgAsmType *mrType)
 Builds the register or memory reference expression for the ModR/M byte. More...
 
SgAsmx86RegisterReferenceExpressionmakeModrmRegister (RegisterMode, SgAsmType *mrType=NULL)
 Builds the register reference expression for the ModR/M byte. More...
 
void requireMemory () const
 Throw an exceptions if the instruction requires the "Mod" part of the ModR/M byte to have the value 3. More...
 
SgAsmExpressiongetImmByte ()
 
SgAsmExpressiongetImmWord ()
 
SgAsmExpressiongetImmDWord ()
 
SgAsmExpressiongetImmQWord ()
 
SgAsmExpressiongetImmForAddr ()
 
SgAsmExpressiongetImmIv ()
 
SgAsmExpressiongetImmJz ()
 
SgAsmExpressiongetImmByteAsIv ()
 
SgAsmExpressiongetImmIzAsIv ()
 
SgAsmExpressiongetImmJb ()
 
SgAsmx86Instructiondisassemble ()
 Disassembles an instruction. More...
 
SgAsmx86InstructiondecodeOpcode0F ()
 Disassemble an instruction following the 0x0f prefix. More...
 
SgAsmx86InstructiondecodeOpcode0F38 ()
 Disassemble SSE3 instructions. More...
 
SgAsmx86InstructiondecodeX87InstructionD8 ()
 Disassembles an instruction with primary opcode 0xd8. More...
 
SgAsmx86InstructiondecodeX87InstructionD9 ()
 Disassembles an instruction with primary opcode 0xd9. More...
 
SgAsmx86InstructiondecodeX87InstructionDA ()
 Disassembles an instruction with primary opcode 0xda. More...
 
SgAsmx86InstructiondecodeX87InstructionDB ()
 Disassembles an instruction with primary opcode 0xdb. More...
 
SgAsmx86InstructiondecodeX87InstructionDC ()
 Disassembles an instruction with primary opcode 0xdc. More...
 
SgAsmx86InstructiondecodeX87InstructionDD ()
 Disassembles an instruction with primary opcode 0xdd. More...
 
SgAsmx86InstructiondecodeX87InstructionDE ()
 Disassembles an instruction with primary opcode 0xde. More...
 
SgAsmx86InstructiondecodeX87InstructionDF ()
 Disassembles an instruction with primary opcode 0xdf. More...
 
SgAsmx86InstructiondecodeGroup1 (SgAsmExpression *imm)
 Disassembles ADD, OR, ADC, SBB, AND, SUB, XOR, CMP. More...
 
SgAsmx86InstructiondecodeGroup1a ()
 Disassembles POP. More...
 
SgAsmx86InstructiondecodeGroup2 (SgAsmExpression *count)
 Disassembles ROL, ROR, RCL, RCR, SHL, SHR, SHL, SAR. More...
 
SgAsmx86InstructiondecodeGroup3 (SgAsmExpression *immMaybe)
 Disassembles TEST, NOT, NEG, MUL, IMUL, DIV, IDIV. More...
 
SgAsmx86InstructiondecodeGroup4 ()
 Disassembles INC, DEC. More...
 
SgAsmx86InstructiondecodeGroup5 ()
 Disassembles INC, DEC, CALL, FARCALL, JMP, FARJMP, PUSH. More...
 
SgAsmx86InstructiondecodeGroup6 ()
 Disassembles SLDT, STR, LLDT, LTR, VERR, VERW. More...
 
SgAsmx86InstructiondecodeGroup7 ()
 Disassembles VMCALL, VMLAUNCH, VMRESUME, VMXOFF, SGDT, MONITOR, MWAIT, SIDT, SGDT, XGETBV, XSETBV, LGDT, VMRUN, VMMCALL, VMLOAD, VMSAVE, STGI, CLGI, SKINIT, INVLPGA, LIDT, SMSW, LMSW, SWAPGS, RDTSCP, INVLPG. More...
 
SgAsmx86InstructiondecodeGroup8 (SgAsmExpression *imm)
 Disassembles BT, BTS, BTR, BTC. More...
 
SgAsmx86InstructiondecodeGroup11 (SgAsmExpression *imm)
 Disassembles MOV. More...
 
SgAsmx86InstructiondecodeGroup15 ()
 Disassembles FXSAVE, FXRSTOR, LDMXCSR, STMXCSR, XSAVE, LFENCE, XRSTOR, MFENCE, SFENCE, CLFLUSH. More...
 
SgAsmx86InstructiondecodeGroup16 ()
 Disassembles PREFETCHNTA, PREFETCH0, PREFETCH1, PREFETCH2, PREFETCH. More...
 
SgAsmx86InstructiondecodeGroupP ()
 Disassembles PREFETCH, PREFETCHW. More...
 
void init (size_t wordsize)
 Initialize instances of this class. More...
 
void startInstruction (SgAsmx86Instruction *insn)
 Resets disassembler state to beginning of an instruction for assembly. More...
 
void startInstruction (rose_addr_t start_va, const uint8_t *buf, size_t bufsz)
 Resets disassembler state to beginning of an instruction for disassembly. More...
 

Static Private Member Functions

static RegisterMode sizeToMode (X86InstructionSize)
 Returns the register mode for the specified instruction size. More...
 
static SgAsmTypesizeToType (X86InstructionSize s)
 Returns a data type associated with an instruction size. More...
 

Private Attributes

X86InstructionSize insnSize
 Default size of instructions, based on architecture; see init() More...
 
uint64_t ip
 Virtual address for start of instruction. More...
 
SgUnsignedCharList insnbuf
 Buffer containing bytes of instruction. More...
 
size_t insnbufat
 Index of next byte to be read from or write to insnbuf. More...
 
X86SegmentRegister segOverride
 Set by 0x26,0x2e,0x36,0x3e,0x64,0x65 prefixes. More...
 
X86BranchPrediction branchPrediction
 
bool branchPredictionEnabled
 
bool rexPresent
 
bool rexW
 
bool rexR
 
bool rexX
 
bool rexB
 Set by 0x40-0x4f prefixes; extended registers present; see setRex() More...
 
bool sizeMustBe64Bit
 Set if effective operand size must be 64 bits. More...
 
bool operandSizeOverride
 Set by the 0x66 prefix; used by effectiveOperandSize() and mmPrefix() More...
 
bool addressSizeOverride
 Set by the 0x67 prefix; used by effectiveAddressSize() More...
 
bool lock
 Set by the 0xf0 prefix. More...
 
X86RepeatPrefix repeatPrefix
 Set by 0xf2 (repne) and 0xf3 (repe) prefixes. More...
 
bool modregrmByteSet
 True if modregrmByte is initialized. More...
 
uint8_t modregrmByte
 Set by instructions that use ModR/M when the ModR/M byte is read. More...
 
uint8_t modeField
 Value (0-3) of high-order two bits of modregrmByte; see getModRegRM() More...
 
uint8_t regField
 Value (0-7) of bits 3-5 inclusive of modregrmByte; see getModRegRM() More...
 
uint8_t rmField
 Value (0-7) of bits 0-3 inclusive of modregrmByte; see getModRegRM() More...
 
SgAsmExpressionmodrm
 Register or memory ref expr built from modregrmByte; see getModRegRM() More...
 
SgAsmExpressionreg
 Register reference expression built from modregrmByte; see getModRegRM() More...
 
bool isUnconditionalJump
 True for jmp, farjmp, ret, retf, iret, and hlt. More...
 

Additional Inherited Members

- Public Types inherited from Disassembler
enum  SearchHeuristic {
  SEARCH_FOLLOWING = 0x0001,
  SEARCH_IMMEDIATE = 0x0002,
  SEARCH_WORDS = 0x0004,
  SEARCH_ALLBYTES = 0x0008,
  SEARCH_UNUSED = 0x0010,
  SEARCH_NONEXE = 0x0020,
  SEARCH_DEADEND = 0x0040,
  SEARCH_UNKNOWN = 0x0080,
  SEARCH_FUNCSYMS = 0x0100,
  SEARCH_DEFAULT = 0x0101
}
 Heuristics used to find instructions to disassemble. More...
 
typedef std::set< rose_addr_tAddressSet
 An AddressSet contains virtual addresses (alternatively, relative virtual addresses) for such things as specifying which virtual addresses should be disassembled. More...
 
typedef Map< rose_addr_t,
SgAsmInstruction * > 
InstructionMap
 The InstructionMap is a mapping from (absolute) virtual address to disassembled instruction. More...
 
typedef Map< rose_addr_t,
Exception
BadMap
 The BadMap is a mapping from (absolute) virtual address to information about a failed disassembly attempt at that address. More...
 
- Static Public Member Functions inherited from Disassembler
static unsigned parse_switches (const std::string &s, unsigned initial=SEARCH_DEFAULT)
 Given a string (presumably from the ROSE command-line), parse it and return the bit vector describing which search heuristics should be employed by the disassembler. More...
 
static void register_subclass (Disassembler *)
 Register a disassembler instance. More...
 
static Disassemblerlookup (SgAsmGenericHeader *)
 Finds a suitable disassembler. More...
 
static Disassemblerlookup (SgAsmInterpretation *)
 Finds a suitable disassembler. More...
 
static void disassembleInterpretation (SgAsmInterpretation *)
 This class method is for backward compatibility with the disassembleInterpretation() function in the old Disassembler namespace. More...
 
- Protected Attributes inherited from Disassembler
const RegisterDictionaryp_registers
 Description of registers available for this platform. More...
 
class Partitionerp_partitioner
 Used for placing instructions into blocks and functions. More...
 
unsigned p_search
 Mask of SearchHeuristic bits specifying instruction searching. More...
 
FILE * p_debug
 Set to non-null to get debugging info. More...
 
size_t p_wordsize
 Word size used by SEARCH_WORDS. More...
 
ByteOrder::Endianness p_sex
 Byte order for SEARCH_WORDS. More...
 
size_t p_alignment
 Word alignment constraint for SEARCH_WORDS (0 and 1 imply byte). More...
 
size_t p_ndisassembled
 Total number of instructions disassembled by disassembleBlock() More...
 
unsigned p_protection
 Memory protection bits that must be set to disassemble. More...
 
- Static Protected Attributes inherited from Disassembler
static std::vector
< Disassembler * > 
disassemblers
 List of disassembler subclasses. More...
 
static time_t progress_interval = 10
 Minimum interval between progress reports. More...
 
static time_t progress_time = 0
 Time of last report, or zero if no report has been generated. More...
 
static FILE * progress_file = stderr
 File to which reports are made. More...
 
static RTS_mutex_t class_mutex = RTS_MUTEX_INITIALIZER(RTS_LAYER_DISASSEMBLER_CLASS)
 Mutex for class-wide thread safety. More...
 

Detailed Description

Disassembler for the x86 architecture.

Most of the useful disassembly methods can be found in the superclass. There's really not much reason to use this class directly or to call any of these methods directly.

Definition at line 11 of file DisassemblerX86.h.

Member Enumeration Documentation

ModR/M settings that create register expressions (or rmReturnNull for no register)

Enumerator
rmLegacyByte 
rmRexByte 
rmWord 
rmDWord 
rmQWord 
rmSegment 
rmST 
rmMM 
rmXMM 
rmControl 
rmDebug 
rmReturnNull 

Definition at line 72 of file DisassemblerX86.h.

Enumerator
mmNone 
mmF3 
mm66 
mmF2 

Definition at line 78 of file DisassemblerX86.h.

Constructor & Destructor Documentation

DisassemblerX86::DisassemblerX86 ( size_t  wordsize)
inline

Definition at line 18 of file DisassemblerX86.h.

References init().

Referenced by clone().

DisassemblerX86::DisassemblerX86 ( const DisassemblerX86 other)
inline

Definition at line 27 of file DisassemblerX86.h.

virtual DisassemblerX86::~DisassemblerX86 ( )
inlinevirtual

Definition at line 38 of file DisassemblerX86.h.

Member Function Documentation

virtual DisassemblerX86* DisassemblerX86::clone ( ) const
inlinevirtual

Creates a new copy of a disassembler.

The new copy has all the same settings as the original.

Thread safety: The thread safety of this virtual method depends on the implementation in the subclass.

Implements Disassembler.

Definition at line 40 of file DisassemblerX86.h.

References DisassemblerX86().

SgAsmInstruction * DisassemblerX86::disassembleOne ( const MemoryMap map,
rose_addr_t  start_va,
AddressSet successors = NULL 
)
virtual
SgAsmInstruction * DisassemblerX86::make_unknown_instruction ( const Exception e)
virtual

Make an unknown instruction from an exception.

Implements Disassembler.

Definition at line 111 of file DisassemblerX86.C.

References Disassembler::Exception::bytes, makeInstruction(), SgAsmInstruction::set_raw_bytes(), and x86_unknown_instruction.

uint8_t DisassemblerX86::getByte ( )
private

Returns the next byte of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction().

Throws an exception for short reads or if we've read more than 15 bytes. The longest possible x86 instruction is 15 bytes.

Definition at line 124 of file DisassemblerX86.C.

References insnbuf, and insnbufat.

Referenced by decodeModrmMemory(), decodeOpcode0F(), decodeOpcode0F38(), disassemble(), getImmByte(), getImmByteAsIv(), getImmJb(), getModRegRM(), and getWord().

uint16_t DisassemblerX86::getWord ( )
private

Returns the next two-byte, little endian word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction().

Throws an exception for short reads or if we've read more than 15 bytes. The longest possible x86 instruction is 15 bytes.

Definition at line 134 of file DisassemblerX86.C.

References getByte().

Referenced by decodeModrmMemory(), getDWord(), getImmJz(), and getImmWord().

uint32_t DisassemblerX86::getDWord ( )
private

Returns the next four-byte, little endian double word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction().

Throws an exception for short reads or if we've read more than 15 bytes. The longest possible x86 instruction is 15 bytes.

Definition at line 142 of file DisassemblerX86.C.

References getWord().

Referenced by decodeModrmMemory(), getImmDWord(), getImmJz(), and getQWord().

uint64_t DisassemblerX86::getQWord ( )
private

Returns the next eight-byte, little endian quad word of the instruction by looking at the insnbuf, insnbufsz, and insnbufat data members that were set by startInstruction().

Throws an exception for short reads or if we've read more than 15 bytes. The longest possible x86 instruction is 15 bytes.

Definition at line 150 of file DisassemblerX86.C.

References getDWord().

Referenced by getImmQWord().

SgAsmExpression * DisassemblerX86::currentDataSegment ( ) const
private

Constructs a register reference expression for the current data segment based on whether a segment override prefix has been encountered.

Definition at line 165 of file DisassemblerX86.C.

References insnSize, makeSegmentRegister(), segOverride, x86_insnsize_64, x86_segreg_ds, and x86_segreg_none.

Referenced by disassemble().

X86InstructionSize DisassemblerX86::effectiveAddressSize ( ) const
private

Returns the size of instruction addresses.

The effective address size is normally based on the default instruction size. However, if the disassembler encounters the 0x67 instruction prefix ("Address-size Override Prefix") as indicated by the addressSizeOverride data member being set, then other sizes are used. See pattent 6571330.

Definition at line 172 of file DisassemblerX86.C.

References addressSizeOverride, insnSize, x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.

Referenced by decodeModrmMemory(), getImmForAddr(), makeAddrSizeValue(), and makeInstruction().

RegisterMode DisassemblerX86::effectiveOperandMode ( ) const
inlineprivate

Returns the register mode for the instruction's effective operand size.

Definition at line 125 of file DisassemblerX86.h.

References effectiveOperandSize(), and sizeToMode().

Referenced by decodeGroup7(), decodeOpcode0F(), disassemble(), and makeRegisterEffective().

X86InstructionSize DisassemblerX86::effectiveOperandSize ( ) const
private

Returns the size of the operands.

The operand size is normally based on the default instruction size; however, if the disassembler encounters the 0x66 instruction prefix ("Precision-size Override Prefix") as indicated by the operandSizeOverride data member being set, then other sizes are used. See pattent 6571330.

Definition at line 187 of file DisassemblerX86.C.

References insnSize, operandSizeOverride, rexPresent, rexW, sizeMustBe64Bit, x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.

Referenced by decodeOpcode0F(), disassemble(), effectiveOperandMode(), effectiveOperandType(), getImmIv(), getImmIzAsIv(), getImmJz(), and makeInstruction().

SgAsmType* DisassemblerX86::effectiveOperandType ( ) const
inlineprivate

Returns the data type for the instruction's effective operand size.

Definition at line 135 of file DisassemblerX86.h.

References effectiveOperandSize(), and sizeToType().

Referenced by decodeOpcode0F(), and disassemble().

bool DisassemblerX86::longMode ( ) const
inlineprivate

Returns true if we're disassembling 64-bit code.

Definition at line 140 of file DisassemblerX86.h.

References insnSize, and x86_insnsize_64.

Referenced by disassemble(), and not64().

DisassemblerX86::MMPrefix DisassemblerX86::mmPrefix ( ) const
private
void DisassemblerX86::not64 ( ) const
inlineprivate

Throws an exception if the instruction being disassembled is not valid for 64-bit mode.

Definition at line 148 of file DisassemblerX86.h.

References longMode().

Referenced by decodeOpcode0F(), and disassemble().

void DisassemblerX86::setRex ( uint8_t  prefix)
private

Sets the rexPresent flag along with rexW, rexR, rexX, and/or rexB based on the instruction prefix, which should be a value between 0x40 and 0x4f, inclusive.

Definition at line 245 of file DisassemblerX86.C.

References rexB, rexPresent, rexR, rexW, and rexX.

Referenced by disassemble().

DisassemblerX86::RegisterMode DisassemblerX86::sizeToMode ( X86InstructionSize  s)
staticprivate

Returns the register mode for the specified instruction size.

Definition at line 255 of file DisassemblerX86.C.

References rmDWord, rmQWord, rmWord, x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.

Referenced by decodeModrmMemory(), effectiveOperandMode(), and makeOperandRegisterFull().

SgAsmType * DisassemblerX86::sizeToType ( X86InstructionSize  s)
staticprivate

Returns a data type associated with an instruction size.

For instance, a 32-bit instruction returns the type for a double word.

Definition at line 266 of file DisassemblerX86.C.

References SgAsmTypeWord::createType(), SgAsmTypeDoubleWord::createType(), SgAsmTypeQuadWord::createType(), x86_insnsize_16, x86_insnsize_32, x86_insnsize_64, and x86_insnsize_none.

Referenced by effectiveOperandType(), and makeIP().

SgAsmExpression * DisassemblerX86::makeAddrSizeValue ( int64_t  val,
size_t  bit_offset,
size_t  bit_size 
)
private

Constructs an expression for the specified address size.

The bit_offset and bit_size are the offset and size where val was found in the instruction raw bytes.

Definition at line 286 of file DisassemblerX86.C.

References effectiveAddressSize(), SageBuilderAsm::makeDWordValue(), SageBuilderAsm::makeQWordValue(), SageBuilderAsm::makeWordValue(), SgAsmValueExpression::set_bit_offset(), SgAsmValueExpression::set_bit_size(), x86_insnsize_16, x86_insnsize_32, and x86_insnsize_64.

Referenced by decodeModrmMemory().

SgAsmx86Instruction * DisassemblerX86::makeInstruction ( X86InstructionKind  kind,
const std::string &  mnemonic,
SgAsmExpression op1 = NULL,
SgAsmExpression op2 = NULL,
SgAsmExpression op3 = NULL,
SgAsmExpression op4 = NULL 
)
private
SgAsmx86RegisterReferenceExpression * DisassemblerX86::makeIP ( )
private

Constructs a register reference expression for the instruction pointer register.

Definition at line 347 of file DisassemblerX86.C.

References Disassembler::get_registers(), insnSize, RegisterDictionary::lookup(), name, SgAsmExpression::set_type(), sizeToType(), x86_insnsize_16, x86_insnsize_32, x86_insnsize_64, and x86_insnsize_none.

Referenced by decodeModrmMemory().

SgAsmx86RegisterReferenceExpression * DisassemblerX86::makeOperandRegisterByte ( bool  rexExtension,
uint8_t  registerNumber 
)
private

Definition at line 365 of file DisassemblerX86.C.

References makeRegister(), rexPresent, rmLegacyByte, and rmRexByte.

Referenced by disassemble().

SgAsmx86RegisterReferenceExpression * DisassemblerX86::makeOperandRegisterFull ( bool  rexExtension,
uint8_t  registerNumber 
)
private

Definition at line 372 of file DisassemblerX86.C.

References insnSize, makeRegister(), and sizeToMode().

Referenced by decodeModrmMemory().

SgAsmx86RegisterReferenceExpression* DisassemblerX86::makeRegisterEffective ( uint8_t  fullRegisterNumber)
inlineprivate

Definition at line 197 of file DisassemblerX86.h.

References effectiveOperandMode(), and makeRegister().

Referenced by decodeOpcode0F(), and disassemble().

SgAsmx86RegisterReferenceExpression* DisassemblerX86::makeRegisterEffective ( bool  rexExtension,
uint8_t  registerNumber 
)
inlineprivate

Definition at line 202 of file DisassemblerX86.h.

References effectiveOperandMode(), and makeRegister().

SgAsmExpression * DisassemblerX86::makeSegmentRegister ( X86SegmentRegister  so,
bool  insn64 
) const
private

Constructs a register reference expression for a segment register.

Definition at line 495 of file DisassemblerX86.C.

References makeRegister(), rmSegment, x86_segreg_cs, x86_segreg_ds, x86_segreg_es, x86_segreg_fs, x86_segreg_gs, x86_segreg_none, and x86_segreg_ss.

Referenced by currentDataSegment(), and decodeModrmMemory().

void DisassemblerX86::getModRegRM ( RegisterMode  regMode,
RegisterMode  rmMode,
SgAsmType t,
SgAsmType tForReg = NULL 
)
private

Decodes the ModR/M byte of an instruction.

The ModR/M byte is used to carry operand information when the first byte (after prefixes) cannot do so. It consists of three parts:

  • Bits 6-7: the "Mod" (i.e., mode) bits. They are saved in the DisassemblerX86::modeField data member. A mode of 3 indicates that the "M" bits designate a register; otherwise the M bits are used for memory coding.
  • Bits 3-5: the "R" (i.e., register) bits, saved in the DisassemblerX86::regField data member.
  • Bits 0-2: the "M" (i.e., memory) bits, saved in the DisassemblerX86::rmField data member. These are used to specify or help specify a memory location except when the mode bits have the value 3.

The regMode is the register kind for the "R" bits and is used when constructing the DisassemblerX86::reg data member. The rmMode is the register kind for the "RM" field when the mode refers to a register.

Definition at line 521 of file DisassemblerX86.C.

References getByte(), makeModrmNormal(), makeModrmRegister(), modeField, modregrmByte, modregrmByteSet, modrm, reg, regField, and rmField.

Referenced by decodeGroup15(), decodeGroup7(), decodeGroupP(), decodeOpcode0F(), decodeOpcode0F38(), decodeX87InstructionD8(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDC(), decodeX87InstructionDD(), decodeX87InstructionDE(), decodeX87InstructionDF(), and disassemble().

void DisassemblerX86::fillInModRM ( RegisterMode  rmMode,
SgAsmType t 
)
private

If ModR/M is a memory reference, fill in its type; otherwise, make a register with the appropriate mode and put it into the modrm data member.

Definition at line 706 of file DisassemblerX86.C.

References isSgAsmMemoryReferenceExpression(), makeRegister(), modeField, modrm, rexB, rmField, and SgAsmExpression::set_type().

Referenced by decodeGroup15(), decodeGroup7(), decodeOpcode0F(), and disassemble().

SgAsmExpression * DisassemblerX86::makeModrmNormal ( RegisterMode  m,
SgAsmType mrType 
)
private

Builds the register or memory reference expression for the ModR/M byte.

See getModRegRM().

Definition at line 716 of file DisassemblerX86.C.

References decodeModrmMemory(), makeRegister(), modeField, modregrmByteSet, modrm, rexB, rexPresent, rmField, rmLegacyByte, rmRexByte, and SgAsmExpression::set_type().

Referenced by decodeX87InstructionD9(), decodeX87InstructionDB(), decodeX87InstructionDF(), and getModRegRM().

SgAsmx86RegisterReferenceExpression * DisassemblerX86::makeModrmRegister ( RegisterMode  m,
SgAsmType mrType = NULL 
)
private

Builds the register reference expression for the ModR/M byte.

See getModRegRM(). The mrType is only used for vector registers.

Definition at line 732 of file DisassemblerX86.C.

References makeRegister(), modregrmByteSet, regField, rexPresent, rexR, rmLegacyByte, and rmRexByte.

Referenced by decodeOpcode0F(), decodeX87InstructionDA(), and getModRegRM().

void DisassemblerX86::requireMemory ( ) const
inlineprivate

Throw an exceptions if the instruction requires the "Mod" part of the ModR/M byte to have the value 3.

Definition at line 246 of file DisassemblerX86.h.

References modeField, and modregrmByteSet.

Referenced by decodeGroup15(), decodeGroup16(), decodeGroupP(), decodeOpcode0F(), and disassemble().

SgAsmExpression * DisassemblerX86::getImmForAddr ( )
private
SgAsmExpression * DisassemblerX86::getImmIv ( )
private
SgAsmExpression * DisassemblerX86::getImmByteAsIv ( )
private
SgAsmExpression * DisassemblerX86::getImmIzAsIv ( )
private
SgAsmx86Instruction * DisassemblerX86::disassemble ( )
private

Disassembles an instruction.

This is the workhorse: it reads and decodes bytes of the instruction in a huge switch statement.

Definition at line 903 of file DisassemblerX86.C.

References addressSizeOverride, branchPrediction, branchPredictionEnabled, BYTET, currentDataSegment(), decodeGroup1(), decodeGroup11(), decodeGroup1a(), decodeGroup2(), decodeGroup3(), decodeGroup4(), decodeGroup5(), decodeOpcode0F(), decodeX87InstructionD8(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDC(), decodeX87InstructionDD(), decodeX87InstructionDE(), decodeX87InstructionDF(), DWORDT, effectiveOperandMode(), effectiveOperandSize(), effectiveOperandType(), fillInModRM(), getByte(), getImmByte(), getImmByteAsIv(), getImmForAddr(), getImmIv(), getImmIzAsIv(), getImmJb(), getImmJz(), getImmWord(), getModRegRM(), isUnconditionalJump, lock, longMode(), SageBuilderAsm::makeByteValue(), makeInstruction(), SageBuilderAsm::makeMemoryReference(), makeOperandRegisterByte(), makeRegister(), makeRegisterEffective(), modrm, not64(), operandSizeOverride, reg, regField, repeatPrefix, requireMemory(), rexB, rmDWord, rmLegacyByte, rmReturnNull, rmSegment, rmWord, segOverride, setRex(), sizeMustBe64Bit, WORDT, x86_aaa, x86_aad, x86_aam, x86_aas, x86_adc, x86_add, x86_and, x86_arpl, x86_bound, x86_branch_prediction_not_taken, x86_branch_prediction_taken, x86_call, x86_cbw, x86_cdq, x86_cdqe, x86_clc, x86_cld, x86_cli, x86_cmc, x86_cmp, x86_cmpsb, x86_cmpsd, x86_cmpsq, x86_cmpsw, x86_cqo, x86_cwd, x86_cwde, x86_daa, x86_das, x86_dec, x86_enter, x86_farcall, x86_farjmp, x86_hlt, x86_imul, x86_in, x86_inc, x86_insb, x86_insd, x86_insnsize_16, x86_insnsize_32, x86_insnsize_64, x86_insw, x86_int, x86_int1, x86_int3, x86_into, x86_iret, x86_ja, x86_jae, x86_jb, x86_jbe, x86_jcxz, x86_je, x86_jecxz, x86_jg, x86_jge, x86_jl, x86_jle, x86_jmp, x86_jne, x86_jno, x86_jns, x86_jo, x86_jpe, x86_jpo, x86_jrcxz, x86_js, x86_lahf, x86_lds, x86_lea, x86_leave, x86_les, x86_lodsb, x86_lodsd, x86_lodsq, x86_lodsw, x86_loop, x86_loopnz, x86_loopz, x86_mov, x86_movsb, x86_movsd, x86_movsq, x86_movsw, x86_movsxd, x86_nop, x86_or, x86_out, x86_outsb, x86_outsd, x86_outsw, x86_pause, x86_pop, x86_popa, x86_popad, x86_popf, x86_popfd, x86_popfq, x86_push, x86_pusha, x86_pushad, x86_pushf, x86_pushfd, x86_pushfq, x86_rep_insb, x86_rep_insd, x86_rep_insw, x86_rep_lodsb, x86_rep_lodsd, x86_rep_lodsq, x86_rep_lodsw, x86_rep_movsb, x86_rep_movsd, x86_rep_movsq, x86_rep_movsw, x86_rep_outsb, x86_rep_outsd, x86_rep_outsw, x86_rep_stosb, x86_rep_stosd, x86_rep_stosq, x86_rep_stosw, x86_repe_cmpsb, x86_repe_cmpsd, x86_repe_cmpsq, x86_repe_cmpsw, x86_repe_scasb, x86_repe_scasd, x86_repe_scasq, x86_repe_scasw, x86_repeat_none, x86_repeat_repe, x86_repeat_repne, x86_repne_cmpsb, x86_repne_cmpsd, x86_repne_cmpsq, x86_repne_cmpsw, x86_repne_scasb, x86_repne_scasd, x86_repne_scasq, x86_repne_scasw, x86_ret, x86_retf, x86_sahf, x86_salc, x86_sbb, x86_scasb, x86_scasd, x86_scasq, x86_scasw, x86_segreg_cs, x86_segreg_ds, x86_segreg_es, x86_segreg_fs, x86_segreg_gs, x86_segreg_ss, x86_stc, x86_std, x86_sti, x86_stosb, x86_stosd, x86_stosq, x86_stosw, x86_sub, x86_test, x86_wait, x86_xchg, x86_xlatb, and x86_xor.

Referenced by disassembleOne().

SgAsmx86Instruction * DisassemblerX86::decodeOpcode0F ( )
private

Disassemble an instruction following the 0x0f prefix.

Definition at line 2675 of file DisassemblerX86.C.

References branchPredictionEnabled, BYTET, decodeGroup15(), decodeGroup16(), decodeGroup6(), decodeGroup7(), decodeGroup8(), decodeGroupP(), decodeOpcode0F38(), DOUBLET, DQWORDT, DWORDT, effectiveOperandMode(), effectiveOperandSize(), effectiveOperandType(), fillInModRM(), FLOATT, getByte(), getImmByte(), getImmJz(), getModRegRM(), isSgAsmx86RegisterReferenceExpression(), isUnconditionalJump, makeInstruction(), makeModrmRegister(), makeRegister(), makeRegisterEffective(), mm66, mmF2, mmF3, mmNone, mmPrefix(), modeField, modrm, not64(), operandSizeOverride, QWORDT, reg, regField, repeatPrefix, requireMemory(), rexB, rmControl, rmDebug, rmDWord, rmLegacyByte, rmMM, rmReturnNull, rmSegment, rmWord, rmXMM, SgAsmExpression::set_type(), V16BYTET, V2DOUBLET, V2DWORDT, V2FLOATT, V2QWORDT, V4DWORDT, V4FLOATT, V4WORDT, V8BYTET, V8WORDT, WORDT, x86_addpd, x86_addps, x86_addsd, x86_addss, x86_addsubpd, x86_addsubps, x86_andnpd, x86_andnps, x86_andpd, x86_andps, x86_bsf, x86_bsr, x86_bswap, x86_bt, x86_btc, x86_btr, x86_bts, x86_clts, x86_cmova, x86_cmovae, x86_cmovb, x86_cmovbe, x86_cmove, x86_cmovg, x86_cmovge, x86_cmovl, x86_cmovle, x86_cmovne, x86_cmovno, x86_cmovns, x86_cmovo, x86_cmovpe, x86_cmovpo, x86_cmovs, x86_cmppd, x86_cmpps, x86_cmpsd, x86_cmpss, x86_cmpxchg, x86_cmpxchg16b, x86_cmpxchg8b, x86_comisd, x86_comiss, x86_cpuid, x86_cvtdq2pd, x86_cvtdq2ps, x86_cvtpd2dq, x86_cvtpd2pi, x86_cvtpd2ps, x86_cvtpi2pd, x86_cvtpi2ps, x86_cvtps2dq, x86_cvtps2pd, x86_cvtps2pi, x86_cvtsd2si, x86_cvtsd2ss, x86_cvtsi2sd, x86_cvtsi2ss, x86_cvtss2sd, x86_cvtss2si, x86_cvttpd2dq, x86_cvttpd2pi, x86_cvttps2dq, x86_cvttps2pi, x86_cvttsd2si, x86_cvttss2si, x86_divpd, x86_divps, x86_divsd, x86_divss, x86_emms, x86_extrq, x86_femms, x86_getsec, x86_haddpd, x86_haddps, x86_hsubpd, x86_hsubps, x86_imul, x86_insertq, x86_insnsize_64, x86_invd, x86_ja, x86_jae, x86_jb, x86_jbe, x86_je, x86_jg, x86_jge, x86_jl, x86_jle, x86_jmpe, x86_jne, x86_jno, x86_jns, x86_jo, x86_jpe, x86_jpo, x86_js, x86_lar, x86_lddqu, x86_lfs, x86_lgs, x86_lsl, x86_lss, x86_lzcnt, x86_maxpd, x86_maxps, x86_maxsd, x86_maxss, x86_minpd, x86_minps, x86_minsd, x86_minss, x86_mov, x86_movapd, x86_movaps, x86_movd, x86_movddup, x86_movdq2q, x86_movdqa, x86_movdqu, x86_movhlps, x86_movhpd, x86_movhps, x86_movlhps, x86_movlpd, x86_movlps, x86_movmskpd, x86_movmskps, x86_movntdq, x86_movnti, x86_movntpd, x86_movntps, x86_movntq, x86_movntsd, x86_movntss, x86_movq, x86_movq2dq, x86_movsd_sse, x86_movshdup, x86_movsldup, x86_movss, x86_movsx, x86_movupd, x86_movups, x86_movzx, x86_mulpd, x86_mulps, x86_mulsd, x86_mulss, x86_nop, x86_orpd, x86_orps, x86_packssdw, x86_packsswb, x86_packuswb, x86_paddb, x86_paddd, x86_paddq, x86_paddsb, x86_paddsw, x86_paddusb, x86_paddusw, x86_paddw, x86_palignr, x86_pand, x86_pandn, x86_pavgb, x86_pavgusb, x86_pavgw, x86_pcmpeqb, x86_pcmpeqd, x86_pcmpeqw, x86_pcmpgtb, x86_pcmpgtd, x86_pcmpgtw, x86_pextrw, x86_pf2id, x86_pf2iw, x86_pfacc, x86_pfadd, x86_pfcmpeq, x86_pfcmpge, x86_pfcmpgt, x86_pfmax, x86_pfmin, x86_pfmul, x86_pfnacc, x86_pfpnacc, x86_pfrcp, x86_pfrcpit1, x86_pfrcpit2, x86_pfrsqit1, x86_pfrsqrt, x86_pfsub, x86_pfsubr, x86_pi2fd, x86_pi2fw, x86_pinsrw, x86_pmaddwd, x86_pmaxsw, x86_pmaxub, x86_pminsw, x86_pminub, x86_pmovmskb, x86_pmulhrw, x86_pmulhuw, x86_pmulhw, x86_pmullw, x86_pmuludq, x86_pop, x86_popcnt, x86_por, x86_psadbw, x86_pshufd, x86_pshufhw, x86_pshuflw, x86_pshufw, x86_pslld, x86_pslldq, x86_psllq, x86_psllw, x86_psrad, x86_psraq, x86_psraw, x86_psrld, x86_psrldq, x86_psrlq, x86_psrlw, x86_psubb, x86_psubd, x86_psubq, x86_psubsb, x86_psubsw, x86_psubusb, x86_psubusw, x86_psubw, x86_pswapd, x86_punpckhbw, x86_punpckhdq, x86_punpckhqdq, x86_punpckhwd, x86_punpcklbw, x86_punpckldq, x86_punpcklqdq, x86_punpcklwd, x86_push, x86_pxor, x86_rcpps, x86_rcpss, x86_rdmsr, x86_rdpmc, x86_rdtsc, x86_repeat_repe, x86_rsm, x86_rsqrtps, x86_rsqrtss, x86_seta, x86_setae, x86_setb, x86_setbe, x86_sete, x86_setg, x86_setge, x86_setl, x86_setle, x86_setne, x86_setno, x86_setns, x86_seto, x86_setpe, x86_setpo, x86_sets, x86_shld, x86_shrd, x86_shufpd, x86_shufps, x86_sqrtpd, x86_sqrtps, x86_sqrtsd, x86_sqrtss, x86_subpd, x86_subps, x86_subsd, x86_subss, x86_syscall, x86_sysenter, x86_sysexit, x86_sysret, x86_ucomisd, x86_ucomiss, x86_ud2, x86_unpckhpd, x86_unpckhps, x86_unpcklpd, x86_unpcklps, x86_vmclear, x86_vmptrld, x86_vmptrst, x86_vmxon, x86_wbinvd, x86_wrmsr, x86_xadd, x86_xorpd, and x86_xorps.

Referenced by disassemble().

SgAsmx86Instruction * DisassemblerX86::decodeOpcode0F38 ( )
private

Disassemble SSE3 instructions.

Definition at line 5120 of file DisassemblerX86.C.

References getByte(), getModRegRM(), makeInstruction(), mm66, mmF2, mmF3, mmNone, mmPrefix(), modrm, reg, rmMM, rmXMM, V2DWORDT, V4DWORDT, and x86_pshufb.

Referenced by decodeOpcode0F().

SgAsmx86Instruction * DisassemblerX86::decodeX87InstructionD8 ( )
private
SgAsmx86Instruction * DisassemblerX86::decodeX87InstructionDA ( )
private
SgAsmx86Instruction * DisassemblerX86::decodeX87InstructionDC ( )
private

Disassembles an instruction with primary opcode 0xdc.

Definition at line 5339 of file DisassemblerX86.C.

References DOUBLET, getModRegRM(), makeInstruction(), makeRegister(), modeField, modrm, regField, rmReturnNull, rmST, x86_fadd, x86_fcom, x86_fcomp, x86_fdiv, x86_fdivr, x86_fmul, x86_fsub, and x86_fsubr.

Referenced by disassemble().

SgAsmx86Instruction * DisassemblerX86::decodeX87InstructionDD ( )
private
SgAsmx86Instruction * DisassemblerX86::decodeX87InstructionDE ( )
private
SgAsmx86Instruction * DisassemblerX86::decodeX87InstructionDF ( )
private
SgAsmx86Instruction * DisassemblerX86::decodeGroup1 ( SgAsmExpression imm)
private

Disassembles ADD, OR, ADC, SBB, AND, SUB, XOR, CMP.

Definition at line 5503 of file DisassemblerX86.C.

References makeInstruction(), modrm, regField, x86_adc, x86_add, x86_and, x86_cmp, x86_or, x86_sbb, x86_sub, and x86_xor.

Referenced by disassemble().

SgAsmx86Instruction * DisassemblerX86::decodeGroup1a ( )
private

Disassembles POP.

Definition at line 5521 of file DisassemblerX86.C.

References makeInstruction(), modrm, regField, and x86_pop.

Referenced by disassemble().

SgAsmx86Instruction * DisassemblerX86::decodeGroup2 ( SgAsmExpression count)
private

Disassembles ROL, ROR, RCL, RCR, SHL, SHR, SHL, SAR.

Definition at line 5529 of file DisassemblerX86.C.

References makeInstruction(), modrm, regField, x86_rcl, x86_rcr, x86_rol, x86_ror, x86_sar, x86_shl, and x86_shr.

Referenced by disassemble().

SgAsmx86Instruction * DisassemblerX86::decodeGroup3 ( SgAsmExpression immMaybe)
private

Disassembles TEST, NOT, NEG, MUL, IMUL, DIV, IDIV.

Definition at line 5547 of file DisassemblerX86.C.

References makeInstruction(), modrm, regField, x86_div, x86_idiv, x86_imul, x86_mul, x86_neg, x86_not, and x86_test.

Referenced by disassemble().

SgAsmx86Instruction * DisassemblerX86::decodeGroup4 ( )
private

Disassembles INC, DEC.

Definition at line 5574 of file DisassemblerX86.C.

References makeInstruction(), modrm, regField, x86_dec, and x86_inc.

Referenced by disassemble().

SgAsmx86Instruction * DisassemblerX86::decodeGroup5 ( )
private

Disassembles INC, DEC, CALL, FARCALL, JMP, FARJMP, PUSH.

Definition at line 5586 of file DisassemblerX86.C.

References isUnconditionalJump, makeInstruction(), modrm, regField, x86_call, x86_dec, x86_farcall, x86_farjmp, x86_inc, x86_jmp, and x86_push.

Referenced by disassemble().

SgAsmx86Instruction * DisassemblerX86::decodeGroup6 ( )
private

Disassembles SLDT, STR, LLDT, LTR, VERR, VERW.

Definition at line 5615 of file DisassemblerX86.C.

References makeInstruction(), modrm, regField, x86_lldt, x86_ltr, x86_sldt, x86_str, x86_verr, and x86_verw.

Referenced by decodeOpcode0F().

SgAsmx86Instruction * DisassemblerX86::decodeGroup7 ( )
private

Disassembles VMCALL, VMLAUNCH, VMRESUME, VMXOFF, SGDT, MONITOR, MWAIT, SIDT, SGDT, XGETBV, XSETBV, LGDT, VMRUN, VMMCALL, VMLOAD, VMSAVE, STGI, CLGI, SKINIT, INVLPGA, LIDT, SMSW, LMSW, SWAPGS, RDTSCP, INVLPG.

Definition at line 5633 of file DisassemblerX86.C.

References BYTET, effectiveOperandMode(), fillInModRM(), getModRegRM(), makeInstruction(), modeField, modrm, regField, rmField, rmReturnNull, rmWord, WORDT, x86_clgi, x86_invlpg, x86_invlpga, x86_lgdt, x86_lidt, x86_lmsw, x86_monitor, x86_mwait, x86_rdtscp, x86_sgdt, x86_sidt, x86_skinit, x86_smsw, x86_stgi, x86_swapgs, x86_vmcall, x86_vmlaunch, x86_vmload, x86_vmmcall, x86_vmresume, x86_vmrun, x86_vmsave, x86_vmxoff, x86_xgetbv, and x86_xsetbv.

Referenced by decodeOpcode0F().

SgAsmx86Instruction * DisassemblerX86::decodeGroup8 ( SgAsmExpression imm)
private

Disassembles BT, BTS, BTR, BTC.

Definition at line 5723 of file DisassemblerX86.C.

References makeInstruction(), modrm, regField, x86_bt, x86_btc, x86_btr, and x86_bts.

Referenced by decodeOpcode0F().

SgAsmx86Instruction * DisassemblerX86::decodeGroup11 ( SgAsmExpression imm)
private

Disassembles MOV.

Definition at line 5741 of file DisassemblerX86.C.

References makeInstruction(), modrm, regField, and x86_mov.

Referenced by disassemble().

SgAsmx86Instruction * DisassemblerX86::decodeGroup15 ( )
private

Disassembles FXSAVE, FXRSTOR, LDMXCSR, STMXCSR, XSAVE, LFENCE, XRSTOR, MFENCE, SFENCE, CLFLUSH.

Definition at line 5752 of file DisassemblerX86.C.

References BYTET, DWORDT, fillInModRM(), getModRegRM(), makeInstruction(), modeField, modrm, regField, requireMemory(), rmReturnNull, x86_clflush, x86_fxrstor, x86_fxsave, x86_ldmxcsr, x86_lfence, x86_mfence, x86_sfence, x86_stmxcsr, x86_xrstor, and x86_xsave.

Referenced by decodeOpcode0F().

SgAsmx86Instruction * DisassemblerX86::decodeGroup16 ( )
private

Disassembles PREFETCHNTA, PREFETCH0, PREFETCH1, PREFETCH2, PREFETCH.

Definition at line 5802 of file DisassemblerX86.C.

References makeInstruction(), modrm, regField, requireMemory(), x86_prefetch, x86_prefetchnta, x86_prefetcht0, x86_prefetcht1, and x86_prefetcht2.

Referenced by decodeOpcode0F().

SgAsmx86Instruction * DisassemblerX86::decodeGroupP ( )
private

Disassembles PREFETCH, PREFETCHW.

Definition at line 5815 of file DisassemblerX86.C.

References BYTET, getModRegRM(), makeInstruction(), modrm, regField, requireMemory(), rmLegacyByte, rmReturnNull, x86_prefetch, and x86_prefetchw.

Referenced by decodeOpcode0F().

void DisassemblerX86::startInstruction ( SgAsmx86Instruction insn)
inlineprivate
void DisassemblerX86::startInstruction ( rose_addr_t  start_va,
const uint8_t *  buf,
size_t  bufsz 
)
inlineprivate

Member Data Documentation

X86InstructionSize DisassemblerX86::insnSize
private
uint64_t DisassemblerX86::ip
private

Virtual address for start of instruction.

Definition at line 399 of file DisassemblerX86.h.

Referenced by getImmJb(), getImmJz(), makeInstruction(), and startInstruction().

SgUnsignedCharList DisassemblerX86::insnbuf
private

Buffer containing bytes of instruction.

Definition at line 400 of file DisassemblerX86.h.

Referenced by getByte(), makeInstruction(), and startInstruction().

size_t DisassemblerX86::insnbufat
private

Index of next byte to be read from or write to insnbuf.

Definition at line 401 of file DisassemblerX86.h.

Referenced by decodeModrmMemory(), getByte(), getImmByte(), getImmByteAsIv(), getImmDWord(), getImmJb(), getImmJz(), getImmQWord(), getImmWord(), makeInstruction(), and startInstruction().

X86SegmentRegister DisassemblerX86::segOverride
private

Set by 0x26,0x2e,0x36,0x3e,0x64,0x65 prefixes.

Definition at line 404 of file DisassemblerX86.h.

Referenced by currentDataSegment(), decodeModrmMemory(), disassemble(), makeInstruction(), and startInstruction().

X86BranchPrediction DisassemblerX86::branchPrediction
private

Definition at line 405 of file DisassemblerX86.h.

Referenced by disassemble(), makeInstruction(), and startInstruction().

bool DisassemblerX86::branchPredictionEnabled
private

Definition at line 406 of file DisassemblerX86.h.

Referenced by decodeOpcode0F(), disassemble(), makeInstruction(), and startInstruction().

bool DisassemblerX86::rexPresent
private
bool DisassemblerX86::rexW
private

Definition at line 407 of file DisassemblerX86.h.

Referenced by effectiveOperandSize(), setRex(), and startInstruction().

bool DisassemblerX86::rexR
private

Definition at line 407 of file DisassemblerX86.h.

Referenced by makeModrmRegister(), setRex(), and startInstruction().

bool DisassemblerX86::rexX
private

Definition at line 407 of file DisassemblerX86.h.

Referenced by decodeModrmMemory(), setRex(), and startInstruction().

bool DisassemblerX86::rexB
private

Set by 0x40-0x4f prefixes; extended registers present; see setRex()

Definition at line 407 of file DisassemblerX86.h.

Referenced by decodeModrmMemory(), decodeOpcode0F(), disassemble(), fillInModRM(), makeModrmNormal(), setRex(), and startInstruction().

bool DisassemblerX86::sizeMustBe64Bit
private

Set if effective operand size must be 64 bits.

Definition at line 408 of file DisassemblerX86.h.

Referenced by disassemble(), effectiveOperandSize(), and startInstruction().

bool DisassemblerX86::operandSizeOverride
private

Set by the 0x66 prefix; used by effectiveOperandSize() and mmPrefix()

Definition at line 409 of file DisassemblerX86.h.

Referenced by decodeOpcode0F(), disassemble(), effectiveOperandSize(), mmPrefix(), and startInstruction().

bool DisassemblerX86::addressSizeOverride
private

Set by the 0x67 prefix; used by effectiveAddressSize()

Definition at line 410 of file DisassemblerX86.h.

Referenced by disassemble(), effectiveAddressSize(), and startInstruction().

bool DisassemblerX86::lock
private

Set by the 0xf0 prefix.

Definition at line 411 of file DisassemblerX86.h.

Referenced by disassemble(), makeInstruction(), and startInstruction().

X86RepeatPrefix DisassemblerX86::repeatPrefix
private

Set by 0xf2 (repne) and 0xf3 (repe) prefixes.

Definition at line 412 of file DisassemblerX86.h.

Referenced by decodeOpcode0F(), disassemble(), makeInstruction(), mmPrefix(), and startInstruction().

bool DisassemblerX86::modregrmByteSet
private

True if modregrmByte is initialized.

Definition at line 413 of file DisassemblerX86.h.

Referenced by decodeModrmMemory(), getModRegRM(), makeModrmNormal(), makeModrmRegister(), requireMemory(), and startInstruction().

uint8_t DisassemblerX86::modregrmByte
private

Set by instructions that use ModR/M when the ModR/M byte is read.

Definition at line 414 of file DisassemblerX86.h.

Referenced by decodeX87InstructionD8(), decodeX87InstructionD9(), decodeX87InstructionDA(), decodeX87InstructionDB(), decodeX87InstructionDE(), decodeX87InstructionDF(), getModRegRM(), and startInstruction().

uint8_t DisassemblerX86::rmField
private

Value (0-7) of bits 0-3 inclusive of modregrmByte; see getModRegRM()

Definition at line 417 of file DisassemblerX86.h.

Referenced by decodeGroup7(), decodeModrmMemory(), fillInModRM(), getModRegRM(), makeModrmNormal(), and startInstruction().

SgAsmExpression* DisassemblerX86::reg
private

Register reference expression built from modregrmByte; see getModRegRM()

Definition at line 419 of file DisassemblerX86.h.

Referenced by decodeOpcode0F(), decodeOpcode0F38(), decodeX87InstructionDE(), disassemble(), getModRegRM(), and startInstruction().

bool DisassemblerX86::isUnconditionalJump
private

True for jmp, farjmp, ret, retf, iret, and hlt.

Definition at line 420 of file DisassemblerX86.h.

Referenced by decodeGroup5(), decodeOpcode0F(), disassemble(), and startInstruction().


The documentation for this class was generated from the following files: