本文整理汇总了C++中Database::GetMemoryArea方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::GetMemoryArea方法的具体用法?C++ Database::GetMemoryArea怎么用?C++ Database::GetMemoryArea使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::GetMemoryArea方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetOperandReference
//TODO: Need more work
bool Instruction::GetOperandReference(Database const& rDatabase, u8 Oprd, Address const& rAddrSrc, Address& rAddrDst) const
{
medusa::Operand const* pOprd = Operand(Oprd);
TOffset Offset = 0x0;
rAddrDst = rAddrSrc;
// XXX: Should never happen
if (pOprd == NULL) return false;
if (pOprd->GetType() & O_NO_REF)
return false;
if ((pOprd->GetType() & O_REL) || ((pOprd->GetType() & O_REG_PC_REL) && (pOprd->GetType() & O_MEM)))
{
switch (pOprd->GetType() & DS_MASK)
{
case DS_8BIT: Offset = static_cast<s8> (pOprd->GetValue()) + GetLength(); break;
case DS_16BIT: Offset = static_cast<s16>(pOprd->GetValue()) + GetLength(); break;
case DS_32BIT: Offset = static_cast<s32>(pOprd->GetValue()) + GetLength(); break;
case DS_64BIT: Offset = static_cast<s64>(pOprd->GetValue()) + GetLength(); break;
default: Offset = pOprd->GetValue() + GetLength();
}
rAddrDst = rAddrSrc + Offset;
return true;
}
else if ((pOprd->GetType() & O_ABS) || (pOprd->GetType() & O_IMM) || (pOprd->GetType() & O_DISP))
{
switch (pOprd->GetType() & DS_MASK)
{
case DS_8BIT: rAddrDst.SetOffset(static_cast<s8> (pOprd->GetValue())); break;
case DS_16BIT: rAddrDst.SetOffset(static_cast<s16>(pOprd->GetValue())); break;
case DS_32BIT: rAddrDst.SetOffset(static_cast<s32>(pOprd->GetValue())); break;
case DS_64BIT: rAddrDst.SetOffset(static_cast<s64>(pOprd->GetValue())); break;
default: rAddrDst.SetOffset(pOprd->GetValue());
}
return true;
}
else if ((pOprd->GetType() & O_MEM))
{
if (pOprd->GetType() & O_REG_PC_REL)
Offset += rAddrSrc.GetOffset();
switch (pOprd->GetType() & DS_MASK)
{
case DS_8BIT: Offset += static_cast<s8> (pOprd->GetValue()) + GetLength(); break;
case DS_16BIT: Offset += static_cast<s16>(pOprd->GetValue()) + GetLength(); break;
case DS_32BIT: Offset += static_cast<s32>(pOprd->GetValue()) + GetLength(); break;
case DS_64BIT: Offset += static_cast<s64>(pOprd->GetValue()) + GetLength(); break;
default: Offset += pOprd->GetValue() + GetLength();
}
rAddrDst.SetOffset(Offset);
TOffset RawOffset;
MemoryArea const* pMemArea = rDatabase.GetMemoryArea(rAddrDst);
if (pMemArea == nullptr) return false;
if (!pMemArea->Convert(Offset, RawOffset)) return false;
BinaryStream const& rBinStrm = pMemArea->GetBinaryStream();
u64 ReadOffset = 0x0;
try
{
switch (pOprd->GetType() & MS_MASK)
{
case MS_8BIT: rBinStrm.Read(RawOffset, ReadOffset); ReadOffset &= 0xff; break;
case MS_16BIT: rBinStrm.Read(RawOffset, ReadOffset); ReadOffset &= 0xffff; break;
case MS_32BIT: rBinStrm.Read(RawOffset, ReadOffset); ReadOffset &= 0xffffffff; break;
case MS_64BIT: rBinStrm.Read(RawOffset, ReadOffset); break;
default: return false;
}
}
catch(Exception&) { return false; }
rAddrDst.SetOffset(ReadOffset);
return true;
}
return false;
}