本文整理汇总了C++中Address::SetOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ Address::SetOffset方法的具体用法?C++ Address::SetOffset怎么用?C++ Address::SetOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::SetOffset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: linked_section_sp
bool
Section::ResolveContainedAddress (addr_t offset, Address &so_addr) const
{
const uint32_t num_children = m_children.GetSize();
if (num_children > 0)
{
for (uint32_t i=0; i<num_children; i++)
{
Section* child_section = m_children.GetSectionAtIndex (i).get();
addr_t child_offset = child_section->GetOffset();
if (child_offset <= offset && offset - child_offset < child_section->GetByteSize())
return child_section->ResolveContainedAddress (offset - child_offset, so_addr);
}
}
SectionSP linked_section_sp (m_linked_section_wp.lock());
if (linked_section_sp)
{
so_addr.SetOffset(m_linked_offset + offset);
so_addr.SetSection(linked_section_sp);
}
else
{
so_addr.SetOffset(offset);
so_addr.SetSection(const_cast<Section *>(this)->shared_from_this());
#ifdef LLDB_CONFIGURATION_DEBUG
// For debug builds, ensure that there are no orphaned (i.e., moduleless) sections.
assert(GetModule().get());
#endif
}
return true;
}
示例2:
bool
Section::ResolveContainedAddress (addr_t offset, Address &so_addr) const
{
const uint32_t num_children = m_children.GetSize();
if (num_children > 0)
{
for (uint32_t i=0; i<num_children; i++)
{
Section* child_section = m_children.GetSectionAtIndex (i).get();
addr_t child_offset = child_section->GetOffset();
if (child_offset <= offset && offset - child_offset < child_section->GetByteSize())
return child_section->ResolveContainedAddress (offset - child_offset, so_addr);
}
}
if (m_linked_section)
{
so_addr.SetOffset(m_linked_offset + offset);
so_addr.SetSection(m_linked_section);
}
else
{
so_addr.SetOffset(offset);
so_addr.SetSection(this);
}
return true;
}
示例3: 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;
}
示例4: MakeAddress
Address VirtualMemoryArea::MakeAddress(TOffset Offset) const
{
Address Addr = m_VirtualBase;
Addr.SetOffset(Offset);
return Addr;
}
示例5: data
//.........这里部分代码省略.........
SymbolContext sc;
Address address_point_address;
if (target && !target->GetSectionLoadList().IsEmpty())
{
if (target->GetSectionLoadList().ResolveLoadAddress (vtable_address_point, address_point_address))
{
target->GetImages().ResolveSymbolContextForAddress (address_point_address, eSymbolContextSymbol, sc);
Symbol *symbol = sc.symbol;
if (symbol != NULL)
{
const char *name = symbol->GetMangled().GetDemangledName().AsCString();
if (strstr(name, vtable_demangled_prefix) == name)
{
// We are a C++ class, that's good. Get the class name and look it up:
const char *class_name = name + strlen(vtable_demangled_prefix);
class_type_or_name.SetName (class_name);
TypeList class_types;
uint32_t num_matches = target->GetImages().FindTypes (sc,
ConstString(class_name),
true,
UINT32_MAX,
class_types);
if (num_matches == 1)
{
class_type_or_name.SetTypeSP(class_types.GetTypeAtIndex(0));
}
else if (num_matches > 1)
{
for (size_t i = 0; i < num_matches; i++)
{
lldb::TypeSP this_type(class_types.GetTypeAtIndex(i));
if (this_type)
{
if (ClangASTContext::IsCXXClassType(this_type->GetClangFullType()))
{
// There can only be one type with a given name,
// so we've just found duplicate definitions, and this
// one will do as well as any other.
// We don't consider something to have a dynamic type if
// it is the same as the static type. So compare against
// the value we were handed:
clang::ASTContext *in_ast_ctx = in_value.GetClangAST ();
clang::ASTContext *this_ast_ctx = this_type->GetClangAST ();
if (in_ast_ctx != this_ast_ctx
|| !ClangASTContext::AreTypesSame (in_ast_ctx,
in_value.GetClangType(),
this_type->GetClangFullType()))
{
class_type_or_name.SetTypeSP (this_type);
return true;
}
return false;
}
}
}
}
else
return false;
// The offset_to_top is two pointers above the address.
Address offset_to_top_address = address_point_address;
int64_t slide = -2 * ((int64_t) target->GetArchitecture().GetAddressByteSize());
offset_to_top_address.Slide (slide);
Error error;
lldb::addr_t offset_to_top_location = offset_to_top_address.GetLoadAddress(target);
size_t bytes_read = process->ReadMemory (offset_to_top_location,
memory_buffer,
address_byte_size,
error);
if (!error.Success() || (bytes_read != address_byte_size))
{
return false;
}
offset_ptr = 0;
int64_t offset_to_top = data.GetMaxS64(&offset_ptr, process->GetAddressByteSize());
// So the dynamic type is a value that starts at offset_to_top
// above the original address.
lldb::addr_t dynamic_addr = original_ptr + offset_to_top;
if (!target->GetSectionLoadList().ResolveLoadAddress (dynamic_addr, dynamic_address))
{
dynamic_address.SetOffset(dynamic_addr);
dynamic_address.SetSection(NULL);
}
return true;
}
}
}
}
}
return false;
}