triton::uint128 x86Cpu::getLastMemoryValue(triton::arch::MemoryOperand& mem) { triton::uint128 ret = 0; triton::__uint addr = mem.getAddress(); triton::uint32 size = mem.getSize(); if (size == 0 || size > DQWORD_SIZE) throw std::invalid_argument("x86Cpu::getLastMemoryValue(): Invalid size memory"); for (triton::sint32 i = size-1; i >= 0; i--) ret = ((ret << BYTE_SIZE_BIT) | this->memory[addr+i]); return ret; }
void x86Cpu::setLastMemoryValue(triton::arch::MemoryOperand& mem) { triton::__uint addr = mem.getAddress(); triton::uint32 size = mem.getSize(); triton::uint128 cv = mem.getConcreteValue(); if (size == 0 || size > DQWORD_SIZE) throw std::invalid_argument("x86Cpu::setLastMemoryValue(): Invalid size memory"); for (triton::uint32 i = 0; i < size; i++) { this->memory[addr+i] = static_cast<triton::uint8>(cv & 0xff); cv >>= 8; } }
bool API::taintAssignmentMemoryRegister(const triton::arch::MemoryOperand& memDst, const triton::arch::RegisterOperand& regSrc) { this->checkTaint(); bool flag = triton::engines::taint::UNTAINTED; triton::__uint memAddrDst = memDst.getAddress(); triton::uint32 writeSize = memDst.getSize(); flag = this->taint->assignmentMemoryRegister(memDst, regSrc); /* Taint each byte of reference expression */ for (triton::uint32 i = 0; i != writeSize; i++) { triton::__uint byteId = this->getSymbolicMemoryId(memAddrDst + i); if (byteId == triton::engines::symbolic::UNSET) continue; triton::engines::symbolic::SymbolicExpression* byte = this->getSymbolicExpressionFromId(byteId); byte->isTainted = flag; } return flag; }