コード例 #1
0
ファイル: BinaryImage.cpp プロジェクト: nemerle/boomerang
Byte BinaryImage::readNative1(Address addr) const
{
    const BinarySection *section = getSectionByAddr(addr);

    if (section == nullptr || section->getHostAddr() == HostAddress::INVALID) {
        LOG_WARN("Invalid read at address %1: Address is not mapped to a section", addr);
        return 0xFF;
    }

    HostAddress host = section->getHostAddr() - section->getSourceAddr() + addr;
    return *reinterpret_cast<Byte *>(host.value());
}
コード例 #2
0
ファイル: BinaryImage.cpp プロジェクト: nemerle/boomerang
QWord BinaryImage::readNative8(Address addr) const
{
    const BinarySection *si = getSectionByAddr(addr);

    if (si == nullptr || si->getHostAddr() == HostAddress::INVALID) {
        LOG_WARN("Invalid read at address %1: Address is not mapped to a section", addr.toString());
        return 0x0000000000000000;
    }
    else if (addr + 8 > si->getSourceAddr() + si->getSize()) {
        LOG_WARN("Invalid read at address %1: Read extends past section boundary", addr);
        return 0x0000000000000000;
    }
    else if (si->isAddressBss(addr)) {
        return 0x0000000000000000;
    }

    HostAddress host = si->getHostAddr() - si->getSourceAddr() + addr;
    return Util::readQWord(reinterpret_cast<const Byte *>(host.value()), si->getEndian());
}
コード例 #3
0
ファイル: BinaryImage.cpp プロジェクト: nemerle/boomerang
bool BinaryImage::writeNative4(Address addr, uint32_t value)
{
    BinarySection *si = getSectionByAddr(addr);

    if (si == nullptr || si->getHostAddr() == HostAddress::INVALID) {
        LOG_WARN("Ignoring write at address %1: Address is outside any writable section");
        return false;
    }
    else if (addr + 4 > si->getSourceAddr() + si->getSize()) {
        LOG_WARN("Invalid write at address %1: Write extends past section boundary", addr);
        return false;
    }

    si->addDefinedArea(addr, addr + 4);

    HostAddress host = si->getHostAddr() - si->getSourceAddr() + addr;
    Util::writeDWord(reinterpret_cast<void *>(host.value()), value, si->getEndian());
    return true;
}