10#include <triton/config.hpp>
177 arch(&this->callbacks) {
178 this->
modes = std::make_shared<triton::modes::Modes>();
179 this->
astCtxt = std::make_shared<triton::ast::AstContext>(this->
modes);
194 inline void Context::checkArchitecture(
void)
const {
200 inline void Context::checkIrBuilder(
void)
const {
206 inline void Context::checkSymbolic(
void)
const {
208 throw triton::exceptions::Context(
"Context::checkSymbolic(): Symbolic engine is undefined, you should define an architecture first.");
212 inline void Context::checkSolver(
void)
const {
218 inline void Context::checkTaint(
void)
const {
224 inline void Context::checkLifting(
void)
const {
226 throw triton::exceptions::Context(
"Context::checkLifting(): Lifting engine is undefined, you should define an architecture first.");
257 this->arch.setArchitecture(
arch);
266 this->checkArchitecture();
352 this->checkArchitecture();
357 this->checkArchitecture();
363 this->checkArchitecture();
369 this->checkArchitecture();
375 this->checkArchitecture();
381 this->checkArchitecture();
387 this->checkArchitecture();
393 this->checkArchitecture();
404 this->checkArchitecture();
415 this->checkArchitecture();
421 for (
triton::usize index = 0 ; index < values.size() ; index++) {
428 this->checkArchitecture();
441 this->checkArchitecture();
470 case triton::arch::ARCH_RV64:
473 case triton::arch::ARCH_RV32:
487 this->checkArchitecture();
493 this->checkArchitecture();
499 this->checkArchitecture();
505 this->checkArchitecture();
511 this->checkArchitecture();
517 this->checkArchitecture();
523 this->checkArchitecture();
529 this->checkArchitecture();
535 this->checkArchitecture();
544 this->checkArchitecture();
551 if (this->
solver ==
nullptr)
555 if (this->
taint ==
nullptr)
584 this->
taint =
nullptr;
588 this->
astCtxt = std::make_shared<triton::ast::AstContext>(this->
modes);
607 this->checkArchitecture();
614 this->checkArchitecture();
624 this->checkIrBuilder();
630 this->checkIrBuilder();
644 return this->
astCtxt->getRepresentationMode();
649 this->
astCtxt->setRepresentationMode(mode);
700 this->
modes->setMode(mode, flag);
705 return this->
modes->isModeEnabled(mode);
710 this->
modes->clearModes();
718 this->checkSymbolic();
724 this->checkSymbolic();
730 this->checkSymbolic();
736 this->checkSymbolic();
742 this->checkSymbolic();
748 this->checkSymbolic();
754 this->checkSymbolic();
760 this->checkSymbolic();
766 this->checkSymbolic();
772 this->checkSymbolic();
778 this->checkSymbolic();
784 this->checkSymbolic();
790 this->checkSymbolic();
796 this->checkSymbolic();
802 this->checkSymbolic();
808 this->checkSymbolic();
814 this->checkSymbolic();
820 this->checkSymbolic();
826 this->checkSymbolic();
832 this->checkSymbolic();
838 this->checkSymbolic();
844 this->checkSymbolic();
850 this->checkSymbolic();
856 this->checkSymbolic();
862 this->checkSymbolic();
868 this->checkSymbolic();
874 this->checkSymbolic();
880 this->checkSymbolic();
886 this->checkSymbolic();
892 this->checkSymbolic();
901 else if (usingLLVM) {
905 this->checkSymbolic();
912 this->checkSymbolic();
918 this->checkSymbolic();
924 this->checkSymbolic();
930 this->checkSymbolic();
936 this->checkSymbolic();
942 this->checkSymbolic();
948 this->checkSymbolic();
954 this->checkSymbolic();
960 this->checkSymbolic();
966 this->checkSymbolic();
972 this->checkSymbolic();
978 this->checkSymbolic();
984 this->checkSymbolic();
990 this->checkSymbolic();
996 this->checkSymbolic();
1002 this->checkSymbolic();
1008 this->checkSymbolic();
1014 this->checkSymbolic();
1020 this->checkSymbolic();
1026 this->checkSymbolic();
1032 this->checkSymbolic();
1038 this->checkSymbolic();
1044 this->checkSymbolic();
1050 this->checkSymbolic();
1056 this->checkSymbolic();
1062 this->checkSymbolic();
1068 this->checkSymbolic();
1074 this->checkSymbolic();
1080 this->checkSymbolic();
1089 this->checkSolver();
1095 this->checkSolver();
1101 this->checkSolver();
1107 this->checkSolver();
1113 this->checkSolver();
1119 this->checkSolver();
1120 return this->
solver->
getModel(node, status, timeout, solvingTime);
1125 this->checkSolver();
1126 return this->
solver->
getModels(node, limit, status, timeout, solvingTime);
1131 this->checkSolver();
1132 return this->
solver->
isSat(node, status, timeout, solvingTime);
1137 this->checkSolver();
1138 #ifdef TRITON_Z3_INTERFACE
1143 #ifdef TRITON_BITWUZLA_INTERFACE
1153 this->checkSolver();
1154 #ifdef TRITON_Z3_INTERFACE
1164 this->checkSolver();
1170 this->checkSolver();
1364 this->checkSymbolic();
1366 return synth.
synthesize(node, constant, subexpr, opaque);
1374 this->checkLifting();
1375 #ifdef TRITON_LLVM_INTERFACE
1383 return this->
liftToLLVM(stream, expr->getAst(), fname, optimize);
1388 this->checkLifting();
1394 this->checkLifting();
1400 this->checkLifting();
1406 this->checkLifting();
1412 this->checkLifting();
1413 #ifdef TRITON_LLVM_INTERFACE
This is the main Triton Context class.
TRITON_EXPORT bool setTaintRegister(const triton::arch::Register ®, bool flag)
[taint api] - Sets the flag (taint or untaint) to a register.
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable newSymbolicVariable(triton::uint32 varSize, const std::string &alias="")
[symbolic api] - Returns a new symbolic variable.
TRITON_EXPORT const triton::arch::Register & getParentRegister(const triton::arch::Register ®) const
[architecture api] - Returns parent Register from a register.
TRITON_EXPORT std::ostream & liftToDot(std::ostream &stream, const triton::ast::SharedAbstractNode &node)
[lifting api] - Lifts an AST and all its references to Dot format.
TRITON_EXPORT bool setTaintMemory(const triton::arch::MemoryAccess &mem, bool flag)
[taint api] - Sets the flag (taint or untaint) to a memory.
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable symbolizeExpression(triton::usize exprId, triton::uint32 symVarSize, const std::string &symVarAlias="")
[symbolic api] - Converts a symbolic expression to a symbolic variable. symVarSize must be in bits.
TRITON_EXPORT void setArchitecture(triton::arch::architecture_e arch)
[architecture api] - Initializes an architecture.
TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression & getSymbolicRegister(const triton::arch::Register ®) const
[symbolic api] - Returns the symbolic expression assigned to the parent register.
TRITON_EXPORT const std::vector< triton::engines::symbolic::PathConstraint > & getPathConstraints(void) const
[symbolic api] - Returns the logical conjunction vector of path constraints.
TRITON_EXPORT triton::uint512 getConcreteRegisterValue(const triton::arch::Register ®, bool execCallbacks=true) const
[architecture api] - Returns the concrete value of a register.
TRITON_EXPORT void concretizeMemory(const triton::arch::MemoryAccess &mem)
[symbolic api] - Concretizes symbolic memory cells.
TRITON_EXPORT void setCustomSolver(triton::engines::solver::SolverInterface *customSolver)
Initializes a custom solver.
TRITON_EXPORT const std::unordered_map< triton::uint64, triton::uint8, IdentityHash< triton::uint64 > > & getConcreteMemory(void) const
[architecture api] - Returns all memory.
TRITON_EXPORT bool isArchitectureValid(void) const
[Architecture api] - Returns true if the architecture is valid.
triton::ast::SharedAstContext astCtxt
The AST Context interface.
TRITON_EXPORT const std::unordered_map< triton::arch::register_e, const triton::arch::Register > & getAllRegisters(void) const
[architecture api] - Returns all registers.
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable symbolizeMemory(const triton::arch::MemoryAccess &mem, const std::string &symVarAlias="")
[symbolic api] - Converts a symbolic memory expression to a symbolic variable.
TRITON_EXPORT bool isThumb(void) const
[architecture api] - Returns true if the execution mode is Thumb. Only useful for Arm32.
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable symbolizeRegister(const triton::arch::Register ®, const std::string &symVarAlias="")
[symbolic api] - Converts a symbolic register expression to a symbolic variable.
triton::engines::symbolic::SymbolicEngine * symbolic
The symbolic engine.
TRITON_EXPORT triton::engines::symbolic::SymbolicEngine * getSymbolicEngine(void)
[symbolic api] - Returns the instance of the symbolic engine.
triton::arch::ShortcutRegister registers
A shortcut to access to a Register class from a register name.
TRITON_EXPORT bool isRegisterTainted(const triton::arch::Register ®) const
[taint api] - Returns true if the register is tainted.
TRITON_EXPORT void initEngines(void)
[proccesing api] - Initializes everything.
TRITON_EXPORT void setSolver(triton::engines::solver::solver_e kind)
Initializes a predefined solver.
TRITON_EXPORT void setMode(triton::modes::mode_e mode, bool flag)
[modes api] - Enables or disables a specific mode.
TRITON_EXPORT void popPathConstraint(void)
[symbolic api] - Pops the last constraints added to the path predicate.
TRITON_EXPORT triton::uint512 evaluateAstViaSolver(const triton::ast::SharedAbstractNode &node) const
[solver api] - Evaluates a Triton's AST via the solver and returns a concrete value.
TRITON_EXPORT triton::arch::endianness_e getEndianness(void) const
[architecture api] - Returns the endianness as triton::arch::endianness_e.
TRITON_EXPORT triton::ast::SharedAbstractNode simplifyAstViaLLVM(const triton::ast::SharedAbstractNode &node) const
[lifting api] - Lifts and simplify an AST using LLVM
TRITON_EXPORT triton::uint512 getConcreteVariableValue(const triton::engines::symbolic::SharedSymbolicVariable &symVar) const
[symbolic api] - Gets the concrete value of a symbolic variable.
TRITON_EXPORT std::unordered_set< const triton::arch::Register * > getTaintedRegisters(void) const
[taint api] - Returns the tainted registers.
TRITON_EXPORT std::unordered_map< triton::usize, triton::engines::symbolic::SharedSymbolicExpression > sliceExpressions(const triton::engines::symbolic::SharedSymbolicExpression &expr)
[symbolic api] - Slices all expressions from a given one.
TRITON_EXPORT triton::arch::exception_e processing(triton::arch::Instruction &inst)
[proccesing api] - Processes an instruction and updates engines according to the instruction semantic...
TRITON_EXPORT bool isMemoryTainted(triton::uint64 addr, triton::uint32 size=1) const
[taint api] - Returns true if the address:size is tainted.
TRITON_EXPORT bool untaintRegister(const triton::arch::Register ®)
[taint api] - Untaints a register. Returns !TAINTED if the register has been untainted correctly....
TRITON_EXPORT void setAstRepresentationMode(triton::ast::representations::mode_e mode)
[AST representation api] - Sets the AST representation.
TRITON_EXPORT void reset(void)
[proccesing api] - Resets everything.
TRITON_EXPORT std::vector< triton::uint8 > getSymbolicMemoryAreaValue(triton::uint64 baseAddr, triton::usize size)
[symbolic api] - Returns the symbolic values of a memory area.
TRITON_EXPORT bool isRegisterSymbolized(const triton::arch::Register ®) const
[symbolic api] - Returns true if the register expression contains a symbolic variable.
TRITON_EXPORT bool isMemorySymbolized(const triton::arch::MemoryAccess &mem) const
[symbolic api] - Returns true if memory cell expressions contain symbolic variables.
TRITON_EXPORT bool isModeEnabled(triton::modes::mode_e mode) const
[modes api] - Returns true if the mode is enabled.
TRITON_EXPORT void assignSymbolicExpressionToRegister(const triton::engines::symbolic::SharedSymbolicExpression &se, const triton::arch::Register ®)
[symbolic api] - Assigns a symbolic expression to a register.
TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression & createSymbolicMemoryExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::MemoryAccess &mem, const std::string &comment="")
[symbolic api] - Returns the new symbolic memory expression and links this expression to the instruct...
triton::arch::Architecture arch
The architecture entry.
TRITON_EXPORT const triton::arch::Instruction getNopInstruction(void) const
Returns a NOP instruction according to the architecture.
TRITON_EXPORT Context()
Constructor of the Context.
TRITON_EXPORT void setConcreteState(triton::arch::Architecture &other)
[architecture api] - Defines a concrete state.
TRITON_EXPORT bool taintRegister(const triton::arch::Register ®)
[taint api] - Taints a register. Returns TAINTED if the register has been tainted correctly....
TRITON_EXPORT bool isSymbolicExpressionExists(triton::usize symExprId) const
[symbolic api] - Returns true if the symbolic expression ID exists.
void removeCallback(triton::callbacks::callback_e kind, T cb)
[callbacks api] - Removes a callback.
TRITON_EXPORT bool isFlag(triton::arch::register_e regId) const
[architecture api] - Returns true if the register id is a flag.
TRITON_EXPORT std::ostream & liftToLLVM(std::ostream &stream, const triton::ast::SharedAbstractNode &node, const char *fname="__triton", bool optimize=false)
[lifting api] - Lifts an AST and all its references to LLVM format. fname represents the name of the ...
TRITON_EXPORT triton::engines::taint::TaintEngine * getTaintEngine(void)
[taint api] - Returns the instance of the taint engine.
TRITON_EXPORT triton::usize getSizeOfPathConstraints(void) const
[symbolic api] - Returns the size of the path constraints
TRITON_EXPORT void disassembly(triton::arch::Instruction &inst) const
[architecture api] - Disassembles the instruction and setup operands.
TRITON_EXPORT triton::ast::SharedAbstractNode processCallbacks(triton::callbacks::callback_e kind, triton::ast::SharedAbstractNode node)
[callbacks api] - Processes callbacks according to the kind and the C++ polymorphism.
TRITON_EXPORT void assignSymbolicExpressionToMemory(const triton::engines::symbolic::SharedSymbolicExpression &se, const triton::arch::MemoryAccess &mem)
[symbolic api] - Assigns a symbolic expression to a memory.
void addCallback(triton::callbacks::callback_e kind, T cb)
[callbacks api] - Adds a callback.
TRITON_EXPORT std::vector< triton::uint8 > getConcreteMemoryAreaValue(triton::uint64 baseAddr, triton::usize size, bool execCallbacks=true) const
[architecture api] - Returns the concrete value of a memory area.
TRITON_EXPORT void setSolverMemoryLimit(triton::uint32 limit)
[solver api] - Defines a solver memory consumption limit (in megabytes).
TRITON_EXPORT triton::ast::SharedAstContext getAstContext(void)
[IR builder api] - Returns the AST context. Used as AST builder.
TRITON_EXPORT void removeSymbolicExpression(const triton::engines::symbolic::SharedSymbolicExpression &expr)
[symbolic api] - Removes the symbolic expression corresponding to the id.
TRITON_EXPORT void setThumb(bool state)
[architecture api] - Sets CPU state to Thumb mode.
TRITON_EXPORT std::unordered_map< triton::usize, triton::engines::solver::SolverModel > getModel(const triton::ast::SharedAbstractNode &node, triton::engines::solver::status_e *status=nullptr, triton::uint32 timeout=0, triton::uint32 *solvingTime=nullptr) const
[solver api] - Computes and returns a model from a symbolic constraint. State is returned in the stat...
TRITON_EXPORT triton::uint32 getGprBitSize(void) const
[architecture api] - Returns the bit in byte of the General Purpose Registers.
TRITON_EXPORT void concretizeAllMemory(void)
[symbolic api] - Concretizes all symbolic memory cells.
triton::engines::taint::TaintEngine * taint
The taint engine.
TRITON_EXPORT const triton::arch::Register & getRegister(triton::arch::register_e id) const
[architecture api] - Returns Register from regId.
TRITON_EXPORT bool taintUnion(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
[taint api] - Abstract union tainting.
TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression & createSymbolicExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::OperandWrapper &dst, const std::string &comment="")
[symbolic api] - Returns the new symbolic abstract expression and links this expression to the instru...
TRITON_EXPORT void setConcreteVariableValue(const triton::engines::symbolic::SharedSymbolicVariable &symVar, const triton::uint512 &value)
[symbolic api] - Sets the concrete value of a symbolic variable.
triton::modes::SharedModes modes
The modes.
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicExpression newSymbolicExpression(const triton::ast::SharedAbstractNode &node, const std::string &comment="")
[symbolic api] - Returns a new symbolic expression. Note that if there are simplification passes reco...
TRITON_EXPORT std::vector< triton::engines::symbolic::SharedSymbolicExpression > getTaintedSymbolicExpressions(void) const
[symbolic api] - Returns the list of the tainted symbolic expressions.
TRITON_EXPORT triton::ast::SharedAbstractNode getRegisterAst(const triton::arch::Register ®)
[symbolic api] - Returns the AST corresponding to the register.
TRITON_EXPORT ~Context()
Destructor of the Context.
TRITON_EXPORT triton::uint8 getSymbolicMemoryValue(triton::uint64 address)
[symbolic api] - Returns the symbolic memory value.
TRITON_EXPORT bool isTainted(const triton::arch::OperandWrapper &op) const
[taint api] - Abstract taint verification. Returns true if the operand is tainted.
triton::engines::solver::SolverEngine * solver
The solver engine.
TRITON_EXPORT bool isRegister(triton::arch::register_e regId) const
[architecture api] - Returns true if the regId is a register.
triton::arch::IrBuilder * irBuilder
The IR builder.
TRITON_EXPORT triton::ast::SharedAbstractNode simplify(const triton::ast::SharedAbstractNode &node, bool usingSolver=false, bool usingLLVM=false) const
[symbolic api] - Processes all recorded AST simplifications, uses solver's simplifications if usingSo...
TRITON_EXPORT std::vector< triton::ast::SharedAbstractNode > getPredicatesToReachAddress(triton::uint64 addr)
[symbolic api] - Returns path predicates which may reach the targeted address.
TRITON_EXPORT bool untaintMemory(triton::uint64 addr)
[taint api] - Untaints an address. Returns !TAINTED if the address has been untainted correctly....
TRITON_EXPORT triton::arch::CpuInterface * getCpuInstance(void)
[architecture api] - Returns the instance of the current CPU used.
TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression & createSymbolicVolatileExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const std::string &comment="")
[symbolic api] - Returns the new symbolic volatile expression and links this expression to the instru...
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable getSymbolicVariable(triton::usize symVarId) const
[symbolic api] - Returns the symbolic variable corresponding to the symbolic variable id.
triton::engines::lifters::LiftingEngine * lifting
The lifting engine.
TRITON_EXPORT void concretizeAllRegister(void)
[symbolic api] - Concretizes all symbolic register.
TRITON_EXPORT triton::engines::solver::solver_e getSolver(void) const
Returns the kind of solver as triton::engines::solver::solver_e.
TRITON_EXPORT triton::arch::architecture_e getArchitecture(void) const
[architecture api] - Returns the architecture as triton::arch::architecture_e.
TRITON_EXPORT triton::ast::SharedAbstractNode getImmediateAst(const triton::arch::Immediate &imm)
[symbolic api] - Returns the AST corresponding to the immediate.
TRITON_EXPORT triton::uint32 getGprSize(void) const
[architecture api] - Returns the size in byte of the General Purpose Registers.
TRITON_EXPORT std::ostream & liftToSMT(std::ostream &stream, const triton::engines::symbolic::SharedSymbolicExpression &expr, bool assert_=false, bool icomment=false)
[lifting api] - Lifts a symbolic expression and all its references to SMT format. If assert_ is true,...
TRITON_EXPORT void setSolverTimeout(triton::uint32 ms)
[solver api] - Defines a solver timeout (in milliseconds).
TRITON_EXPORT triton::ast::representations::mode_e getAstRepresentationMode(void) const
[AST representation api] - Returns the AST representation as triton::ast::representation_e.
TRITON_EXPORT bool isSolverValid(void) const
Returns true if the solver is valid.
TRITON_EXPORT std::unordered_map< triton::uint64, triton::engines::symbolic::SharedSymbolicExpression > getSymbolicMemory(void) const
[symbolic api] - Returns the map (<Addr : SymExpr>) of symbolic memory defined.
TRITON_EXPORT triton::uint8 getConcreteMemoryValue(triton::uint64 addr, bool execCallbacks=true) const
[architecture api] - Returns the concrete value of a memory cell.
TRITON_EXPORT void concretizeRegister(const triton::arch::Register ®)
[symbolic api] - Concretizes a symbolic register.
TRITON_EXPORT void setConcreteMemoryValue(triton::uint64 addr, triton::uint8 value, bool execCallbacks=true)
[architecture api] - Sets the concrete value of a memory cell.
TRITON_EXPORT std::unordered_map< triton::arch::register_e, triton::engines::symbolic::SharedSymbolicExpression > getSymbolicRegisters(void) const
[symbolic api] - Returns the map of symbolic registers defined.
TRITON_EXPORT triton::engines::synthesis::SynthesisResult synthesize(const triton::ast::SharedAbstractNode &node, bool constant=true, bool subexpr=true, bool opaque=false)
[synthesizer api] - Synthesizes a given node. If constant is true, performa a constant synthesis....
TRITON_EXPORT triton::ast::SharedAbstractNode simplifyAstViaSolver(const triton::ast::SharedAbstractNode &node) const
[solver api] - Converts a Triton's AST to a solver's AST, perform a simplification and returns a Trit...
TRITON_EXPORT triton::arch::exception_e buildSemantics(triton::arch::Instruction &inst)
[IR builder api] - Builds the instruction semantics. Returns triton::arch::NO_FAULT if succeed.
TRITON_EXPORT std::map< triton::usize, triton::engines::symbolic::SharedSymbolicVariable > getSymbolicVariables(void) const
[symbolic api] - Returns all symbolic variables as a map of <SymVarId : SymVar>
TRITON_EXPORT bool taintMemory(triton::uint64 addr)
[taint api] - Taints an address. Returns TAINTED if the address has been tainted correctly....
TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression & createSymbolicRegisterExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::Register ®, const std::string &comment="")
[symbolic api] - Returns the new symbolic register expression and links this expression to the instru...
TRITON_EXPORT void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const std::vector< triton::uint8 > &values, bool execCallbacks=true)
[architecture api] - Sets the concrete value of a memory area.
TRITON_EXPORT void pushPathConstraint(const triton::ast::SharedAbstractNode &node, const std::string &comment="")
[symbolic api] - Pushes constraint created from node to the current path predicate.
TRITON_EXPORT triton::ast::SharedAbstractNode getOperandAst(const triton::arch::OperandWrapper &op)
[symbolic api] - Returns the AST corresponding to the operand.
TRITON_EXPORT void clearConcreteMemoryValue(const triton::arch::MemoryAccess &mem)
Clears concrete values assigned to the memory cells.
TRITON_EXPORT void clearArchitecture(void)
[architecture api] - Clears the architecture states (registers and memory).
TRITON_EXPORT const std::unordered_set< triton::uint64 > & getTaintedMemory(void) const
[taint api] - Returns the tainted addresses.
TRITON_EXPORT std::set< const triton::arch::Register * > getParentRegisters(void) const
[architecture api] - Returns all parent registers.
TRITON_EXPORT triton::uint32 getNumberOfRegisters(void) const
[architecture api] - Returns the number of registers according to the CPU architecture.
TRITON_EXPORT void setConcreteRegisterValue(const triton::arch::Register ®, const triton::uint512 &value, bool execCallbacks=true)
[architecture api] - Sets the concrete value of a register.
TRITON_EXPORT triton::uint512 getSymbolicRegisterValue(const triton::arch::Register ®)
[symbolic api] - Returns the symbolic register value.
TRITON_EXPORT bool taintAssignment(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
[taint api] - Abstract assignment tainting.
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicExpression getSymbolicExpression(triton::usize symExprId) const
[symbolic api] - Returns the symbolic expression corresponding to an id.
TRITON_EXPORT void clearPathConstraints(void)
[symbolic api] - Clears the current path predicate.
TRITON_EXPORT triton::ast::SharedAbstractNode getPathPredicate(void)
[symbolic api] - Returns the current path predicate as an AST of logical conjunction of each taken br...
TRITON_EXPORT void clearCallbacks(void)
[callbacks api] - Clears recorded callbacks.
TRITON_EXPORT std::vector< triton::engines::symbolic::PathConstraint > getPathConstraintsOfThread(triton::uint32 threadId) const
[symbolic api] - Returns the logical conjunction vector of path constraint of a given thread.
TRITON_EXPORT void removeEngines(void)
[proccesing api] - Removes everything.
TRITON_EXPORT std::vector< std::unordered_map< triton::usize, triton::engines::solver::SolverModel > > getModels(const triton::ast::SharedAbstractNode &node, triton::uint32 limit, triton::engines::solver::status_e *status=nullptr, triton::uint32 timeout=0, triton::uint32 *solvingTime=nullptr) const
[solver api] - Computes and returns several models from a symbolic constraint. The limit is the numbe...
TRITON_EXPORT void clearModes(void)
[modes api] - Clears recorded modes.
TRITON_EXPORT std::unordered_map< triton::usize, triton::engines::symbolic::SharedSymbolicExpression > getSymbolicExpressions(void) const
[symbolic api] - Returns all symbolic expressions as a map of <SymExprId : SymExpr>
TRITON_EXPORT bool isRegisterValid(triton::arch::register_e regId) const
[architecture api] - Returns true if the regId is a register or a flag.
triton::callbacks::Callbacks callbacks
The Callbacks interface.
TRITON_EXPORT std::ostream & liftToPython(std::ostream &stream, const triton::engines::symbolic::SharedSymbolicExpression &expr, bool icomment=false)
[lifting api] - Lifts a symbolic expression and all its references to Python format....
TRITON_EXPORT bool setTaint(const triton::arch::OperandWrapper &op, bool flag)
[taint api] - Sets the flag (taint or untaint) to an abstract operand (Register or Memory).
TRITON_EXPORT const triton::engines::solver::SolverInterface * getSolverInstance(void) const
Returns the instance of the initialized solver.
TRITON_EXPORT triton::ast::SharedAbstractNode getMemoryAst(const triton::arch::MemoryAccess &mem)
[symbolic api] - Returns the AST corresponding to the memory.
TRITON_EXPORT bool isConcreteMemoryValueDefined(const triton::arch::MemoryAccess &mem) const
Returns true if memory cells have a defined concrete value.
TRITON_EXPORT bool isSat(const triton::ast::SharedAbstractNode &node, triton::engines::solver::status_e *status=nullptr, triton::uint32 timeout=0, triton::uint32 *solvingTime=nullptr) const
Returns true if an expression is satisfiable.
The abstract architecture class.
TRITON_EXPORT const triton::arch::Register & getRegister(triton::arch::register_e id) const
Returns register from id.
TRITON_EXPORT void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const std::vector< triton::uint8 > &values, bool execCallbacks=true)
[architecture api] - Sets the concrete value of a memory area.
TRITON_EXPORT std::set< const triton::arch::Register * > getParentRegisters(void) const
Returns all parent registers.
TRITON_EXPORT void setThumb(bool state)
Sets CPU state to Thumb mode. Only valid for Arm32.
TRITON_EXPORT triton::uint32 numberOfRegisters(void) const
Returns the number of registers according to the CPU architecture.
TRITON_EXPORT triton::uint32 gprBitSize(void) const
Returns the bit in bit of the General Purpose Registers.
TRITON_EXPORT void setConcreteRegisterValue(const triton::arch::Register ®, const triton::uint512 &value, bool execCallbacks=true)
[architecture api] - Sets the concrete value of a register.
TRITON_EXPORT void setConcreteMemoryValue(triton::uint64 addr, triton::uint8 value, bool execCallbacks=true)
[architecture api] - Sets the concrete value of a memory cell.
TRITON_EXPORT const std::unordered_map< triton::uint64, triton::uint8, IdentityHash< triton::uint64 > > & getConcreteMemory(void) const
Return all memory.
TRITON_EXPORT void disassembly(triton::arch::Instruction &inst) const
Disassembles the instruction according to the architecture.
TRITON_EXPORT void clearArchitecture(void)
Clears the architecture states (registers and memory).
TRITON_EXPORT std::vector< triton::uint8 > getConcreteMemoryAreaValue(triton::uint64 baseAddr, triton::usize size, bool execCallbacks=true) const
Returns the concrete value of a memory area.
TRITON_EXPORT const triton::arch::Instruction getNopInstruction(void) const
Returns a NOP instruction according to the architecture.
TRITON_EXPORT bool isConcreteMemoryValueDefined(const triton::arch::MemoryAccess &mem) const
Returns true if memory cells have a defined concrete value.
TRITON_EXPORT const std::unordered_map< triton::arch::register_e, const triton::arch::Register > & getAllRegisters(void) const
Returns all registers.
TRITON_EXPORT bool isFlag(triton::arch::register_e regId) const
Returns true if the register ID is a flag.
TRITON_EXPORT triton::uint8 getConcreteMemoryValue(triton::uint64 addr, bool execCallbacks=true) const
Returns the concrete value of a memory cell.
TRITON_EXPORT triton::uint512 getConcreteRegisterValue(const triton::arch::Register ®, bool execCallbacks=true) const
Returns the concrete value of a register.
TRITON_EXPORT void clearConcreteMemoryValue(const triton::arch::MemoryAccess &mem)
Clears concrete values assigned to the memory cells.
TRITON_EXPORT bool isRegisterValid(triton::arch::register_e regId) const
Returns true if the register ID is a register or a flag.
TRITON_EXPORT bool isRegister(triton::arch::register_e regId) const
Returns true if the register ID is a register.
TRITON_EXPORT bool isThumb(void) const
Returns true if the execution mode is Thumb. Only valid for Arm32.
TRITON_EXPORT triton::arch::architecture_e getArchitecture(void) const
Returns the kind of architecture as triton::arch::architecture_e.
TRITON_EXPORT bool isValid(void) const
Returns true if the architecture is valid.
TRITON_EXPORT triton::arch::endianness_e getEndianness(void) const
Returns the kind of endianness as triton::arch::endianness_e.
TRITON_EXPORT triton::uint32 gprSize(void) const
Returns the bit in byte of the General Purpose Registers.
TRITON_EXPORT const triton::arch::Register & getParentRegister(triton::arch::register_e id) const
Returns parent register from id.
TRITON_EXPORT triton::arch::CpuInterface * getCpuInstance(void)
Returns the instance of the current CPU used.
This class is used to represent a basic block.
This interface is used as abstract CPU interface. All CPU must use this interface.
This class is used to represent an instruction.
TRITON_EXPORT triton::arch::exception_e buildSemantics(triton::arch::Instruction &inst)
Builds the semantics of the instruction. Returns triton::arch::NO_FAULT if succeed.
This class is used to represent a memory access.
This class is used as operand wrapper.
This class is used when an instruction has a register operand.
void init(triton::arch::architecture_e arch)
This class is used to describe the ARM (64-bits) spec.
This class is used to describe the ARM (32-bits) spec.
This class is used to describe the RV32 spec.
This class is used to describe the RV64 spec.
This class is used to describe the x86 (64-bits) spec.
This class is used to describe the x86 (32-bits) spec.
TRITON_EXPORT void clearCallbacks(void)
Clears recorded callbacks.
TRITON_EXPORT bool isDefined(triton::callbacks::callback_e kind) const
Returns true if the callback is defined.
TRITON_EXPORT triton::ast::SharedAbstractNode processCallbacks(triton::callbacks::callback_e kind, triton::ast::SharedAbstractNode node)
Processes callbacks according to the kind and the C++ polymorphism.
The lifting engine class.
TRITON_EXPORT std::ostream & liftToDot(std::ostream &stream, const triton::ast::SharedAbstractNode &node)
Lifts an AST and all its references to Dot format.
TRITON_EXPORT triton::ast::SharedAbstractNode simplifyAstViaLLVM(const triton::ast::SharedAbstractNode &node) const
Lifts and simplify an AST using LLVM.
TRITON_EXPORT std::ostream & liftToLLVM(std::ostream &stream, const triton::engines::symbolic::SharedSymbolicExpression &expr, const char *fname="__triton", bool optimize=false)
Lifts a symbolic expression and all its references to LLVM format. fname represents the name of the L...
TRITON_EXPORT std::ostream & liftToPython(std::ostream &stream, const triton::engines::symbolic::SharedSymbolicExpression &expr, bool icomment=false)
Lifts a symbolic expression and all its references to Python format. If icomment is true,...
TRITON_EXPORT std::ostream & liftToSMT(std::ostream &stream, const triton::engines::symbolic::SharedSymbolicExpression &expr, bool assert_=false, bool icomment=false)
Lifts a symbolic expression and all its references to SMT format. If assert_ is true,...
Solver engine using Bitwuzla.
This class is used to interface with solvers.
TRITON_EXPORT void setSolver(triton::engines::solver::solver_e kind)
Initializes a predefined solver.
TRITON_EXPORT void setCustomSolver(triton::engines::solver::SolverInterface *customSolver)
Initializes a custom solver.
TRITON_EXPORT triton::engines::solver::solver_e getSolver(void) const
Returns the kind of solver as triton::engines::solver::solver_e.
TRITON_EXPORT void setTimeout(triton::uint32 ms)
Defines a solver timeout (in milliseconds).
TRITON_EXPORT std::unordered_map< triton::usize, SolverModel > getModel(const triton::ast::SharedAbstractNode &node, triton::engines::solver::status_e *status=nullptr, triton::uint32 timeout=0, triton::uint32 *solvingTime=nullptr) const
Computes and returns a model from a symbolic constraint. State is returned in the status pointer as w...
TRITON_EXPORT const triton::engines::solver::SolverInterface * getSolverInstance(void) const
Returns the instance of the initialized solver.
TRITON_EXPORT std::vector< std::unordered_map< triton::usize, SolverModel > > getModels(const triton::ast::SharedAbstractNode &node, triton::uint32 limit, triton::engines::solver::status_e *status=nullptr, triton::uint32 timeout=0, triton::uint32 *solvingTime=nullptr) const
Computes and returns several models from a symbolic constraint. The limit is the max number of models...
TRITON_EXPORT bool isValid(void) const
Returns true if the solver is valid.
TRITON_EXPORT void setMemoryLimit(triton::uint32 mem)
Defines a solver memory consumption limit (in megabytes).
TRITON_EXPORT bool isSat(const triton::ast::SharedAbstractNode &node, triton::engines::solver::status_e *status=nullptr, triton::uint32 timeout=0, triton::uint32 *solvingTime=nullptr) const
Returns true if an expression is satisfiable.
This interface is used to interface with solvers.
The path constraint class.
TRITON_EXPORT triton::ast::SharedAbstractNode getPathPredicate(void) const
Returns the current path predicate as an AST of logical conjunction of each taken branch.
TRITON_EXPORT std::vector< triton::ast::SharedAbstractNode > getPredicatesToReachAddress(triton::uint64 addr) const
Returns path predicates which may reach the targeted address.
TRITON_EXPORT const std::vector< triton::engines::symbolic::PathConstraint > & getPathConstraints(void) const
Returns the logical conjunction vector of path constraints.
TRITON_EXPORT triton::usize getSizeOfPathConstraints(void) const
Returns the size of the path constraints.
TRITON_EXPORT std::vector< triton::engines::symbolic::PathConstraint > getPathConstraintsOfThread(triton::uint32 threadId) const
Returns the logical conjunction vector of path constraint of a given thread.
TRITON_EXPORT void pushPathConstraint(const triton::arch::Instruction &inst, const triton::engines::symbolic::SharedSymbolicExpression &expr)
Pushs constraints of a branch instruction to the path predicate.
TRITON_EXPORT void clearPathConstraints(void)
Clears the current path predicate.
TRITON_EXPORT void popPathConstraint(void)
Pops the last constraints added to the path predicate.
The symbolic engine class.
TRITON_EXPORT const SharedSymbolicExpression & createSymbolicMemoryExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::MemoryAccess &mem, const std::string &comment="")
Returns the new symbolic memory expression expression and links this expression to the instruction.
TRITON_EXPORT void concretizeMemory(const triton::arch::MemoryAccess &mem, bool array=true)
Concretizes specific symbolic memory cells.
TRITON_EXPORT const SharedSymbolicExpression & createSymbolicRegisterExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::Register ®, const std::string &comment="")
Returns the new symbolic register expression expression and links this expression to the instruction.
TRITON_EXPORT SharedSymbolicVariable symbolizeExpression(triton::usize exprId, triton::uint32 symVarSize, const std::string &symVarAlias="")
Converts a symbolic expression to a symbolic variable. symVarSize must be in bits.
TRITON_EXPORT bool isMemorySymbolized(const triton::arch::MemoryAccess &mem) const
Returns true if memory cell expressions contain symbolic variables.
TRITON_EXPORT std::unordered_map< triton::usize, SharedSymbolicExpression > getSymbolicExpressions(void) const
Returns all symbolic expressions.
TRITON_EXPORT bool isSymbolicExpressionExists(triton::usize symExprId) const
Returns true if the symbolic expression ID exists.
TRITON_EXPORT SharedSymbolicVariable symbolizeRegister(const triton::arch::Register ®, const std::string &symVarAlias="")
Converts a symbolic register expression to a symbolic variable.
TRITON_EXPORT SharedSymbolicExpression getSymbolicExpression(triton::usize symExprId) const
Returns the symbolic expression corresponding to an id.
TRITON_EXPORT SharedSymbolicVariable getSymbolicVariable(triton::usize symVarId) const
Returns the symbolic variable corresponding to the symbolic variable id.
TRITON_EXPORT const SharedSymbolicExpression & createSymbolicVolatileExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const std::string &comment="")
Returns the new symbolic volatile expression expression and links this expression to the instruction.
TRITON_EXPORT void assignSymbolicExpressionToMemory(const SharedSymbolicExpression &se, const triton::arch::MemoryAccess &mem)
Assigns a symbolic expression to a memory.
TRITON_EXPORT void setConcreteVariableValue(const SharedSymbolicVariable &symVar, const triton::uint512 &value)
Sets the concrete value of a symbolic variable.
TRITON_EXPORT SharedSymbolicExpression getSymbolicMemory(triton::uint64 addr) const
Returns the symbolic expression assigned to the memory address.
TRITON_EXPORT void assignSymbolicExpressionToRegister(const SharedSymbolicExpression &se, const triton::arch::Register ®)
Assigns a symbolic expression to a register.
TRITON_EXPORT std::vector< triton::uint8 > getSymbolicMemoryAreaValue(triton::uint64 baseAddr, triton::usize size)
Returns the symbolic values of a memory area.
TRITON_EXPORT std::unordered_map< triton::arch::register_e, SharedSymbolicExpression > getSymbolicRegisters(void) const
Returns the map of symbolic registers defined.
TRITON_EXPORT triton::ast::SharedAbstractNode getMemoryAst(const triton::arch::MemoryAccess &mem)
Returns the AST corresponding to the memory.
TRITON_EXPORT SharedSymbolicVariable symbolizeMemory(const triton::arch::MemoryAccess &mem, const std::string &symVarAlias="")
Converts a symbolic memory expression to a symbolic variable.
TRITON_EXPORT triton::uint512 getSymbolicRegisterValue(const triton::arch::Register ®)
Returns the symbolic register value.
TRITON_EXPORT std::vector< SharedSymbolicExpression > getTaintedSymbolicExpressions(void) const
Returns the vector of the tainted symbolic expressions.
TRITON_EXPORT triton::ast::SharedAbstractNode getRegisterAst(const triton::arch::Register ®)
Returns the AST corresponding to the register.
TRITON_EXPORT triton::uint512 getConcreteVariableValue(const SharedSymbolicVariable &symVar) const
Gets the concrete value of a symbolic variable.
TRITON_EXPORT SharedSymbolicVariable newSymbolicVariable(triton::engines::symbolic::variable_e type, triton::uint64 source, triton::uint32 size, const std::string &alias="")
Adds a symbolic variable.
TRITON_EXPORT const SharedSymbolicExpression & createSymbolicExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::OperandWrapper &dst, const std::string &comment="")
Returns the new symbolic expression and links this expression to the instruction.
TRITON_EXPORT SharedSymbolicExpression newSymbolicExpression(const triton::ast::SharedAbstractNode &node, triton::engines::symbolic::expression_e type, const std::string &comment="")
Creates a new symbolic expression.
TRITON_EXPORT const SharedSymbolicExpression & getSymbolicRegister(const triton::arch::Register ®) const
Returns the symbolic expression assigned to the register.
TRITON_EXPORT void removeSymbolicExpression(const SharedSymbolicExpression &expr)
Removes the symbolic expression corresponding to the id.
TRITON_EXPORT std::unordered_map< triton::usize, SharedSymbolicExpression > sliceExpressions(const SharedSymbolicExpression &expr)
Slices all expressions from a given one.
TRITON_EXPORT triton::uint8 getSymbolicMemoryValue(triton::uint64 address)
Returns the symbolic memory value.
TRITON_EXPORT void concretizeAllMemory(void)
Concretizes all the symbolic memory.
TRITON_EXPORT triton::ast::SharedAbstractNode getImmediateAst(const triton::arch::Immediate &imm)
Returns the AST corresponding to the immediate.
TRITON_EXPORT void concretizeAllRegister(void)
Concretizes all symbolic registers.
TRITON_EXPORT std::map< triton::usize, SharedSymbolicVariable > getSymbolicVariables(void) const
Returns all symbolic variables.
TRITON_EXPORT void concretizeRegister(const triton::arch::Register ®)
Concretizes a specific symbolic register.
TRITON_EXPORT triton::ast::SharedAbstractNode getOperandAst(const triton::arch::OperandWrapper &op)
Returns the AST corresponding to the operand.
TRITON_EXPORT bool isRegisterSymbolized(const triton::arch::Register ®) const
Returns true if the register expression contains a symbolic variable.
TRITON_EXPORT triton::ast::SharedAbstractNode simplify(const triton::ast::SharedAbstractNode &node) const
Processes all recorded simplifications. Returns the simplified node.
The SynthesisResult engine class.
The Synthesizer engine class.
TRITON_EXPORT SynthesisResult synthesize(const triton::ast::SharedAbstractNode &node, bool constant=true, bool subexpr=true, bool opaque=false)
Synthesizes a given node. If constant is true, perform a constant synthesis. If opaque is true,...
TRITON_EXPORT bool taintRegister(const triton::arch::Register ®)
Taints a register. Returns TAINTED if the register has been tainted correctly. Otherwise it returns t...
TRITON_EXPORT bool setTaint(const triton::arch::OperandWrapper &op, bool flag)
Sets the flag (taint or untaint) to an abstract operand (Register or Memory).
TRITON_EXPORT bool setTaintMemory(const triton::arch::MemoryAccess &mem, bool flag)
Sets the flag (taint or untaint) to a memory.
TRITON_EXPORT bool untaintMemory(triton::uint64 addr)
Untaints an address. Returns !TAINTED if the address has been untainted correctly....
TRITON_EXPORT bool isTainted(const triton::arch::OperandWrapper &op) const
Abstract taint verification. Returns true if the operand is tainted.
TRITON_EXPORT std::unordered_set< const triton::arch::Register * > getTaintedRegisters(void) const
Returns the tainted registers.
TRITON_EXPORT bool isMemoryTainted(triton::uint64 addr, triton::uint32 size=1) const
Returns true if the addr is tainted.
TRITON_EXPORT bool taintUnion(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
Abstract union tainting.
TRITON_EXPORT bool setTaintRegister(const triton::arch::Register ®, bool flag)
Sets the flag (taint or untaint) to a register.
TRITON_EXPORT bool taintAssignment(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
Abstract assignment tainting.
TRITON_EXPORT bool untaintRegister(const triton::arch::Register ®)
Untaints a register. Returns !TAINTED if the register has been untainted correctly....
TRITON_EXPORT bool taintMemory(triton::uint64 addr)
Taints an address. Returns TAINTED if the address has been tainted correctly. Otherwise it returns th...
TRITON_EXPORT bool isRegisterTainted(const triton::arch::Register ®) const
Returns true if the register is tainted.
TRITON_EXPORT const std::unordered_set< triton::uint64 > & getTaintedMemory(void) const
Returns the tainted addresses.
The exception class used by the Triton's Context.
The exception class used by all engines.
register_e
Types of register.
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
std::shared_ptr< triton::ast::AstContext > SharedAstContext
Shared AST context.
mode_e
Enumerates all kinds of mode.
mode_e
All types of representation mode.
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
std::shared_ptr< triton::engines::symbolic::SymbolicVariable > SharedSymbolicVariable
Shared Symbolic variable.
@ VOLATILE_EXPRESSION
Assigned to a volatile expression.
@ UNDEFINED_VARIABLE
Undefined assignment.
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
std::uint8_t uint8
unisgned 8-bits