示例#1
0
  bool operator()(BinaryStream const& rBinStrm, TOffset Offset, Instruction& rInsn, Operand* pOprd)
  {
    ConstType ct;

    rBinStrm.Read(Offset, ct);
    pOprd->SetValue(SignExtend<ConstType, Pos>(ct));
    pOprd->SetType(OpType);
    pOprd->SetOffset(static_cast<u8>(rInsn.GetLength()));
    rInsn.Length() += sizeof(ct);
    return true;
  }
示例#2
0
文件: VM.cpp 项目: DarrenStahl/Libra
unsigned int VM::CalcInstructionLen() {
	if(mLoaded) {
		Memory::MemoryOffset curMem = mMem.getOffset(mProc.GetRegister(REG_IP));
		Instruction* inst = Instruction::ReadInstruction(curMem, &mProc);
		if(inst != NULL) {
			unsigned int len = inst->GetLength();
			delete inst;
			return len;
		}
		return 0;
	}
	return 0;
}
示例#3
0
文件: VM.cpp 项目: DarrenStahl/Libra
void VM::Disassemble() {
	if(mLoaded) {
		if(!mVirgo) {
			unsigned int tmpIP = 0;
			Instruction* tmpInst = 0;
			Memory::MemoryOffset curMem = mMem.getOffset(tmpIP);
			while((tmpInst = Instruction::ReadInstruction(curMem, &mProc )) != 0) {
				mInstructions.push_back(tmpInst);
				tmpIP += tmpInst->GetLength() % MEM_SIZE;
				curMem = curMem.getNewOffset(tmpIP);
			}
		}
	}
}
示例#4
0
  bool operator()(BinaryStream const& rBinStrm, X86_Bit Bit, TOffset Offset, Instruction& rInsn, Operand* pOprd)
  {
    ConstType ct;

    rBinStrm.Read(Offset, ct);
    pOprd->SetValue(SignExtend<ConstType, Pos>(ct));
    switch (Bit)
    {
    case X86_Bit_16: pOprd->SetType(O_REL16); break;
    case X86_Bit_32: pOprd->SetType(O_REL32); break;
    case X86_Bit_64: pOprd->SetType(O_REL64); break;
    default:         pOprd->SetType(O_NONE);  break;
    }
    pOprd->SetOffset(static_cast<u8>(rInsn.GetLength()));
    rInsn.Length() += sizeof(ct);
    return true;
  }