libTriton  version 0.6 build 1375
api.hpp
Go to the documentation of this file.
1 /*
3 ** Copyright (C) - Triton
4 **
5 ** This program is under the terms of the BSD License.
6 */
7 
8 #ifndef TRITON_API_H
9 #define TRITON_API_H
10 
11 #include <triton/architecture.hpp>
12 #include <triton/ast.hpp>
13 #include <triton/astContext.hpp>
15 #include <triton/callbacks.hpp>
16 #include <triton/dllexport.hpp>
17 #include <triton/immediate.hpp>
18 #include <triton/instruction.hpp>
19 #include <triton/irBuilder.hpp>
20 #include <triton/memoryAccess.hpp>
21 #include <triton/modes.hpp>
23 #include <triton/register.hpp>
24 #include <triton/registers_e.hpp>
26 #include <triton/taintEngine.hpp>
27 #include <triton/tritonTypes.hpp>
28 #include <triton/z3Interface.hpp>
29 #include <triton/z3Solver.hpp>
30 
31 
32 
34 namespace triton {
42  class API {
43  protected:
46 
49 
52 
55 
58 
61 
64 
67 
70 
71 
72  public:
74  TRITON_EXPORT API();
75 
77  TRITON_EXPORT ~API();
78 
79 
80  /* Architecture API ============================================================================== */
81 
83  TRITON_EXPORT bool isArchitectureValid(void) const;
84 
86  TRITON_EXPORT triton::arch::architectures_e getArchitecture(void) const;
87 
89  TRITON_EXPORT void checkArchitecture(void) const;
90 
92  TRITON_EXPORT triton::arch::CpuInterface* getCpu(void);
93 
96 
98  TRITON_EXPORT void clearArchitecture(void);
99 
101  TRITON_EXPORT bool isFlag(triton::arch::registers_e regId) const;
102 
104  TRITON_EXPORT bool isFlag(const triton::arch::Register& reg) const;
105 
107  TRITON_EXPORT bool isRegister(triton::arch::registers_e regId) const;
108 
110  TRITON_EXPORT bool isRegister(const triton::arch::Register& reg) const;
111 
113  TRITON_EXPORT const triton::arch::Register& getRegister(triton::arch::registers_e id) const;
114 
116  TRITON_EXPORT const triton::arch::Register& getParentRegister(const triton::arch::Register& reg) const;
117 
120 
122  TRITON_EXPORT bool isRegisterValid(triton::arch::registers_e regId) const;
123 
125  TRITON_EXPORT bool isRegisterValid(const triton::arch::Register& reg) const;
126 
128  TRITON_EXPORT triton::uint32 getGprBitSize(void) const;
129 
131  TRITON_EXPORT triton::uint32 getGprSize(void) const;
132 
134  TRITON_EXPORT triton::uint32 getNumberOfRegisters(void) const;
135 
137  TRITON_EXPORT const std::unordered_map<triton::arch::registers_e, const triton::arch::Register>& getAllRegisters(void) const;
138 
140  TRITON_EXPORT std::set<const triton::arch::Register*> getParentRegisters(void) const;
141 
143  TRITON_EXPORT triton::uint8 getConcreteMemoryValue(triton::uint64 addr, bool execCallbacks=true) const;
144 
146  TRITON_EXPORT triton::uint512 getConcreteMemoryValue(const triton::arch::MemoryAccess& mem, bool execCallbacks=true) const;
147 
149  TRITON_EXPORT std::vector<triton::uint8> getConcreteMemoryAreaValue(triton::uint64 baseAddr, triton::usize size, bool execCallbacks=true) const;
150 
152  TRITON_EXPORT triton::uint512 getConcreteRegisterValue(const triton::arch::Register& reg, bool execCallbacks=true) const;
153 
160  TRITON_EXPORT void setConcreteMemoryValue(triton::uint64 addr, triton::uint8 value);
161 
168  TRITON_EXPORT void setConcreteMemoryValue(const triton::arch::MemoryAccess& mem, const triton::uint512& value);
169 
176  TRITON_EXPORT void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const std::vector<triton::uint8>& values);
177 
184  TRITON_EXPORT void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const triton::uint8* area, triton::usize size);
185 
192  TRITON_EXPORT void setConcreteRegisterValue(const triton::arch::Register& reg, const triton::uint512& value);
193 
195  TRITON_EXPORT bool isMemoryMapped(triton::uint64 baseAddr, triton::usize size=1);
196 
198  TRITON_EXPORT void unmapMemory(triton::uint64 baseAddr, triton::usize size=1);
199 
201  TRITON_EXPORT void disassembly(triton::arch::Instruction& inst) const;
202 
203 
204 
205  /* Processing API ================================================================================ */
206 
208  TRITON_EXPORT bool processing(triton::arch::Instruction& inst);
209 
211  TRITON_EXPORT void initEngines(void);
212 
214  TRITON_EXPORT void removeEngines(void);
215 
217  TRITON_EXPORT void reset(void);
218 
219 
220 
221  /* IR API ======================================================================================== */
222 
224  TRITON_EXPORT void checkIrBuilder(void) const;
225 
227  TRITON_EXPORT bool buildSemantics(triton::arch::Instruction& inst);
228 
230  TRITON_EXPORT triton::ast::AstContext& getAstContext(void);
231 
232 
233 
234 
235  /* AST Representation API ======================================================================== */
236 
238  TRITON_EXPORT triton::uint32 getAstRepresentationMode(void) const;
239 
241  TRITON_EXPORT void setAstRepresentationMode(triton::uint32 mode);
242 
243 
244 
245  /* Callbacks API ================================================================================= */
246 
249 
252 
255 
258 
261 
263  TRITON_EXPORT void removeAllCallbacks(void);
264 
267 
270 
273 
276 
279 
282 
284  TRITON_EXPORT void processCallbacks(triton::callbacks::callback_e kind, const triton::arch::MemoryAccess& mem) const;
285 
287  TRITON_EXPORT void processCallbacks(triton::callbacks::callback_e kind, const triton::arch::Register& reg) const;
288 
289 
290 
291  /* Modes API====================================================================================== */
292 
294  TRITON_EXPORT void checkModes(void) const;
295 
297  TRITON_EXPORT void enableMode(enum triton::modes::mode_e mode, bool flag);
298 
300  TRITON_EXPORT bool isModeEnabled(enum triton::modes::mode_e mode) const;
301 
302 
303 
304  /* Symbolic engine API =========================================================================== */
305 
307  TRITON_EXPORT void checkSymbolic(void) const;
308 
311 
313  TRITON_EXPORT std::map<triton::arch::registers_e, triton::engines::symbolic::SharedSymbolicExpression> getSymbolicRegisters(void) const;
314 
316  TRITON_EXPORT std::map<triton::uint64, triton::engines::symbolic::SharedSymbolicExpression> getSymbolicMemory(void) const;
317 
320 
323 
325  TRITON_EXPORT triton::uint8 getSymbolicMemoryValue(triton::uint64 address);
326 
329 
331  TRITON_EXPORT std::vector<triton::uint8> getSymbolicMemoryAreaValue(triton::uint64 baseAddr, triton::usize size);
332 
335 
337  TRITON_EXPORT triton::engines::symbolic::SymbolicVariable* convertExpressionToSymbolicVariable(triton::usize exprId, triton::uint32 symVarSize, const std::string& symVarComment="");
338 
340  TRITON_EXPORT triton::engines::symbolic::SymbolicVariable* convertMemoryToSymbolicVariable(const triton::arch::MemoryAccess& mem, const std::string& symVarComment="");
341 
343  TRITON_EXPORT triton::engines::symbolic::SymbolicVariable* convertRegisterToSymbolicVariable(const triton::arch::Register& reg, const std::string& symVarComment="");
344 
347 
350 
353 
356 
359 
362 
365 
368 
371 
373  TRITON_EXPORT triton::engines::symbolic::SymbolicVariable* newSymbolicVariable(triton::uint32 varSize, const std::string& comment="");
374 
376  TRITON_EXPORT void removeSymbolicExpression(triton::usize symExprId);
377 
380 
383 
386 
389 
392 
395 
398 
400  TRITON_EXPORT triton::ast::SharedAbstractNode processSimplification(const triton::ast::SharedAbstractNode& node, bool z3=false) const;
401 
404 
407 
409  TRITON_EXPORT triton::engines::symbolic::SymbolicVariable* getSymbolicVariableFromName(const std::string& symVarName) const;
410 
412  TRITON_EXPORT const std::vector<triton::engines::symbolic::PathConstraint>& getPathConstraints(void) const;
413 
416 
419 
421  TRITON_EXPORT void clearPathConstraints(void);
422 
424  TRITON_EXPORT void enableSymbolicEngine(bool flag);
425 
427  TRITON_EXPORT bool isSymbolicEngineEnabled(void) const;
428 
430  TRITON_EXPORT bool isSymbolicExpressionIdExists(triton::usize symExprId) const;
431 
433  TRITON_EXPORT bool isMemorySymbolized(const triton::arch::MemoryAccess& mem) const;
434 
436  TRITON_EXPORT bool isMemorySymbolized(triton::uint64 addr, triton::uint32 size=1) const;
437 
439  TRITON_EXPORT bool isRegisterSymbolized(const triton::arch::Register& reg) const;
440 
442  TRITON_EXPORT void concretizeAllMemory(void);
443 
445  TRITON_EXPORT void concretizeAllRegister(void);
446 
448  TRITON_EXPORT void concretizeMemory(const triton::arch::MemoryAccess& mem);
449 
451  TRITON_EXPORT void concretizeMemory(triton::uint64 addr);
452 
454  TRITON_EXPORT void concretizeRegister(const triton::arch::Register& reg);
455 
458 
460  TRITON_EXPORT std::map<triton::usize, triton::engines::symbolic::SharedSymbolicExpression> sliceExpressions(const triton::engines::symbolic::SharedSymbolicExpression& expr);
461 
463  TRITON_EXPORT std::list<triton::engines::symbolic::SharedSymbolicExpression> getTaintedSymbolicExpressions(void) const;
464 
466  TRITON_EXPORT std::unordered_map<triton::usize, triton::engines::symbolic::SharedSymbolicExpression> getSymbolicExpressions(void) const;
467 
469  TRITON_EXPORT const std::unordered_map<triton::usize, triton::engines::symbolic::SymbolicVariable*>& getSymbolicVariables(void) const;
470 
473 
475  TRITON_EXPORT void setConcreteVariableValue(const triton::engines::symbolic::SymbolicVariable& symVar, const triton::uint512& value);
476 
477 
478 
479  /* Solver engine API ============================================================================= */
480 
482  TRITON_EXPORT void checkSolver(void) const;
483 
491  TRITON_EXPORT std::map<triton::uint32, triton::engines::solver::SolverModel> getModel(const triton::ast::SharedAbstractNode& node) const;
492 
500  TRITON_EXPORT std::list<std::map<triton::uint32, triton::engines::solver::SolverModel>> getModels(const triton::ast::SharedAbstractNode& node, triton::uint32 limit) const;
501 
503  TRITON_EXPORT bool isSat(const triton::ast::SharedAbstractNode& node) const;
504 
505 
506 
507  /* Z3 interface API ============================================================================== */
508 
510  TRITON_EXPORT void checkZ3Interface(void) const;
511 
513  TRITON_EXPORT triton::uint512 evaluateAstViaZ3(const triton::ast::SharedAbstractNode& node) const;
514 
517 
518 
519 
520  /* Taint engine API ============================================================================== */
521 
523  TRITON_EXPORT void checkTaint(void) const;
524 
527 
529  TRITON_EXPORT const std::set<triton::uint64>& getTaintedMemory(void) const;
530 
532  TRITON_EXPORT std::set<const triton::arch::Register*> getTaintedRegisters(void) const;
533 
535  TRITON_EXPORT void enableTaintEngine(bool flag);
536 
538  TRITON_EXPORT bool isTaintEngineEnabled(void) const;
539 
541  TRITON_EXPORT bool isTainted(const triton::arch::OperandWrapper& op) const;
542 
544  TRITON_EXPORT bool isMemoryTainted(triton::uint64 addr, triton::uint32 size=1) const;
545 
547  TRITON_EXPORT bool isMemoryTainted(const triton::arch::MemoryAccess& mem) const;
548 
550  TRITON_EXPORT bool isRegisterTainted(const triton::arch::Register& reg) const;
551 
553  TRITON_EXPORT bool setTaint(const triton::arch::OperandWrapper& op, bool flag);
554 
556  TRITON_EXPORT bool setTaintMemory(const triton::arch::MemoryAccess& mem, bool flag);
557 
559  TRITON_EXPORT bool setTaintRegister(const triton::arch::Register& reg, bool flag);
560 
562  TRITON_EXPORT bool taintMemory(triton::uint64 addr);
563 
565  TRITON_EXPORT bool taintMemory(const triton::arch::MemoryAccess& mem);
566 
568  TRITON_EXPORT bool taintRegister(const triton::arch::Register& reg);
569 
571  TRITON_EXPORT bool untaintMemory(triton::uint64 addr);
572 
574  TRITON_EXPORT bool untaintMemory(const triton::arch::MemoryAccess& mem);
575 
577  TRITON_EXPORT bool untaintRegister(const triton::arch::Register& reg);
578 
580  TRITON_EXPORT bool taintUnion(const triton::arch::OperandWrapper& op1, const triton::arch::OperandWrapper& op2);
581 
583  TRITON_EXPORT bool taintAssignment(const triton::arch::OperandWrapper& op1, const triton::arch::OperandWrapper& op2);
584 
586  TRITON_EXPORT bool taintUnionMemoryImmediate(const triton::arch::MemoryAccess& memDst);
587 
589  TRITON_EXPORT bool taintUnionMemoryMemory(const triton::arch::MemoryAccess& memDst, const triton::arch::MemoryAccess& memSrc);
590 
592  TRITON_EXPORT bool taintUnionMemoryRegister(const triton::arch::MemoryAccess& memDst, const triton::arch::Register& regSrc);
593 
595  TRITON_EXPORT bool taintUnionRegisterImmediate(const triton::arch::Register& regDst);
596 
598  TRITON_EXPORT bool taintUnionRegisterMemory(const triton::arch::Register& regDst, const triton::arch::MemoryAccess& memSrc);
599 
601  TRITON_EXPORT bool taintUnionRegisterRegister(const triton::arch::Register& regDst, const triton::arch::Register& regSrc);
602 
604  TRITON_EXPORT bool taintAssignmentMemoryImmediate(const triton::arch::MemoryAccess& memDst);
605 
607  TRITON_EXPORT bool taintAssignmentMemoryMemory(const triton::arch::MemoryAccess& memDst, const triton::arch::MemoryAccess& memSrc);
608 
610  TRITON_EXPORT bool taintAssignmentMemoryRegister(const triton::arch::MemoryAccess& memDst, const triton::arch::Register& regSrc);
611 
613  TRITON_EXPORT bool taintAssignmentRegisterImmediate(const triton::arch::Register& regDst);
614 
616  TRITON_EXPORT bool taintAssignmentRegisterMemory(const triton::arch::Register& regDst, const triton::arch::MemoryAccess& memSrc);
617 
619  TRITON_EXPORT bool taintAssignmentRegisterRegister(const triton::arch::Register& regDst, const triton::arch::Register& regSrc);
620  };
621 
623 };
624 
625 #endif /* TRITON_API_H */
TRITON_EXPORT bool taintUnion(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
[taint api] - Abstract union tainting.
Definition: api.cpp:1099
TRITON_EXPORT bool isArchitectureValid(void) const
[Architecture api] - Returns true if the architecture is valid.
Definition: api.cpp:209
TRITON_EXPORT bool isTaintEngineEnabled(void) const
[taint api] - Returns true if the taint engine is enabled.
Definition: api.cpp:1013
TRITON_EXPORT bool isRegister(triton::arch::registers_e regId) const
[architecture api] - Returns true if the regId is a register.
Definition: api.cpp:258
TRITON_EXPORT triton::uint32 getGprSize(void) const
[architecture api] - Returns the size in byte of the General Purpose Registers.
Definition: api.cpp:298
TRITON_EXPORT void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const std::vector< triton::uint8 > &values)
[architecture api] - Sets the concrete value of a memory area.
Definition: api.cpp:356
triton::arch::Architecture arch
The architecture entry.
Definition: api.hpp:48
TRITON_EXPORT void checkZ3Interface(void) const
[z3 api] - Raises an exception if the z3 interface is not initialized.
Definition: api.cpp:962
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 shared symbolic abstract expression and links this expression to the...
Definition: api.cpp:682
The abstract architecture class.
This class is used when to represent an instruction.
Definition: instruction.hpp:46
TRITON_EXPORT bool setTaintMemory(const triton::arch::MemoryAccess &mem, bool flag)
[taint api] - Sets the flag (taint or untaint) to a memory.
Definition: api.cpp:1049
TRITON_EXPORT bool taintUnionRegisterMemory(const triton::arch::Register &regDst, const triton::arch::MemoryAccess &memSrc)
[taint api] - Taints RegisterMemory with union. Returns true if the regDst or memSrc are TAINTED...
Definition: api.cpp:1135
TRITON_EXPORT bool taintAssignmentMemoryMemory(const triton::arch::MemoryAccess &memDst, const triton::arch::MemoryAccess &memSrc)
[taint api] - Taints MemoryMemory with assignment. Returns true if the memDst is tainted.
Definition: api.cpp:1153
registers_e
The list of registers.
Definition: registers_e.hpp:28
TRITON_EXPORT bool isMemoryMapped(triton::uint64 baseAddr, triton::usize size=1)
[architecture api] - Returns true if the range [baseAddr:size] is mapped into the internal memory rep...
Definition: api.cpp:374
TRITON_EXPORT bool isSat(const triton::ast::SharedAbstractNode &node) const
Returns true if an expression is satisfiable.
Definition: api.cpp:953
TRITON_EXPORT void addPathConstraint(const triton::arch::Instruction &inst, const triton::engines::symbolic::SharedSymbolicExpression &expr)
[symbolic api] - Adds a path constraint.
Definition: api.cpp:824
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 shared symbolic memory expression and links this expression to the i...
Definition: api.cpp:688
TRITON_EXPORT bool taintUnionMemoryImmediate(const triton::arch::MemoryAccess &memDst)
[taint api] - Taints MemoryImmediate with union. Returns true if the memDst is TAINTED.
Definition: api.cpp:1111
TRITON_EXPORT triton::ast::SharedAbstractNode getPathConstraintsAst(void)
[symbolic api] - Returns the logical conjunction AST of path constraints.
Definition: api.cpp:818
TRITON_EXPORT bool taintAssignment(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
[taint api] - Abstract assignment tainting.
Definition: api.cpp:1105
mode_e
Enumerates all kinds of mode.
Definition: modes.hpp:32
TRITON_EXPORT bool processing(triton::arch::Instruction &inst)
[proccesing api] - Processes an instruction and updates engines according to the instruction semantic...
Definition: api.cpp:453
TRITON_EXPORT void initEngines(void)
[proccesing api] - Initializes everything.
Definition: api.cpp:395
TRITON_EXPORT void reset(void)
[proccesing api] - Resets everything.
Definition: api.cpp:443
TRITON_EXPORT triton::ast::SharedAbstractNode getMemoryAst(const triton::arch::MemoryAccess &mem)
[symbolic api] - Returns the AST corresponding to the memory.
Definition: api.cpp:640
TRITON_EXPORT bool taintAssignmentMemoryRegister(const triton::arch::MemoryAccess &memDst, const triton::arch::Register &regSrc)
[taint api] - Taints MemoryRegister with assignment. Returns true if the memDst is tainted...
Definition: api.cpp:1159
TRITON_EXPORT triton::uint512 getConcreteRegisterValue(const triton::arch::Register &reg, bool execCallbacks=true) const
[architecture api] - Returns the concrete value of a register.
Definition: api.cpp:338
TRITON_EXPORT const std::vector< triton::engines::symbolic::PathConstraint > & getPathConstraints(void) const
[symbolic api] - Returns the logical conjunction vector of path constraints.
Definition: api.cpp:812
TRITON_EXPORT triton::ast::SharedAbstractNode processCallbacks(triton::callbacks::callback_e kind, triton::ast::SharedAbstractNode node) const
[callbacks api] - Processes callbacks according to the kind and the C++ polymorphism.
Definition: api.cpp:551
TRITON_EXPORT void enableMode(enum triton::modes::mode_e mode, bool flag)
[modes api] - Enables or disables a specific mode.
Definition: api.cpp:573
TRITON_EXPORT triton::uint512 evaluateAstViaZ3(const triton::ast::SharedAbstractNode &node) const
[z3 api] - Evaluates a Triton&#39;s AST via Z3 and returns a concrete value.
Definition: api.cpp:968
TRITON_EXPORT triton::arch::CpuInterface * getCpu(void)
[architecture api] - Returns the CPU instance.
Definition: api.cpp:225
TRITON_EXPORT triton::engines::symbolic::SymbolicVariable * newSymbolicVariable(triton::uint32 varSize, const std::string &comment="")
[symbolic api] - Returns a new symbolic variable.
Definition: api.cpp:670
TRITON_EXPORT bool isRegisterSymbolized(const triton::arch::Register &reg) const
[symbolic api] - Returns true if the register expression contains a symbolic variable.
Definition: api.cpp:866
TRITON_EXPORT triton::engines::symbolic::SymbolicVariable * convertMemoryToSymbolicVariable(const triton::arch::MemoryAccess &mem, const std::string &symVarComment="")
[symbolic api] - Converts a symbolic memory expression to a symbolic variable.
Definition: api.cpp:604
triton::engines::symbolic::SymbolicEngine * symbolic
The symbolic engine.
Definition: api.hpp:57
TRITON_EXPORT triton::engines::symbolic::SymbolicVariable * getSymbolicVariableFromName(const std::string &symVarName) const
[symbolic api] - Returns the symbolic variable corresponding to the symbolic variable name...
Definition: api.cpp:806
TRITON_EXPORT std::vector< triton::uint8 > getSymbolicMemoryAreaValue(triton::uint64 baseAddr, triton::usize size)
[symbolic api] - Returns the symbolic values of a memory area.
Definition: api.cpp:760
TRITON_EXPORT void concretizeMemory(const triton::arch::MemoryAccess &mem)
[symbolic api] - Concretizes a specific symbolic memory reference.
Definition: api.cpp:884
TRITON_EXPORT void setArchitecture(triton::arch::architectures_e arch)
[architecture api] - Initializes an architecture.
Definition: api.cpp:232
TRITON_EXPORT triton::ast::SharedAbstractNode getImmediateAst(const triton::arch::Immediate &imm)
[symbolic api] - Returns the AST corresponding to the immediate.
Definition: api.cpp:628
AST Context - Used as AST builder.
Definition: astContext.hpp:43
TRITON_EXPORT bool isRegisterTainted(const triton::arch::Register &reg) const
[taint api] - Returns true if the register is tainted.
Definition: api.cpp:1037
TRITON_EXPORT triton::ast::AstContext & getAstContext(void)
[IR builder api] - Returns the AST context. Used as AST builder.
Definition: api.cpp:475
TRITON_EXPORT bool taintAssignmentRegisterImmediate(const triton::arch::Register &regDst)
[taint api] - Taints RegisterImmediate with assignment. Returns always false.
Definition: api.cpp:1165
The Triton namespace.
Definition: api.cpp:195
TRITON_EXPORT triton::engines::symbolic::SymbolicEngine * getSymbolicEngine(void)
[symbolic api] - Returns the instance of the symbolic engine.
Definition: api.cpp:592
TRITON_EXPORT void enableSymbolicEngine(bool flag)
[symbolic api] - Enables or disables the symbolic execution engine.
Definition: api.cpp:836
TRITON_EXPORT void clearPathConstraints(void)
[symbolic api] - Clears the logical conjunction vector of path constraints.
Definition: api.cpp:830
triton::callbacks::Callbacks callbacks
The Callbacks interface.
Definition: api.hpp:45
TRITON_EXPORT void concretizeRegister(const triton::arch::Register &reg)
[symbolic api] - Concretizes a specific symbolic register reference.
Definition: api.cpp:896
TRITON_EXPORT void checkSolver(void) const
[solver api] - Raises an exception if the solver engine is not initialized.
Definition: api.cpp:935
TRITON_EXPORT const std::set< triton::uint64 > & getTaintedMemory(void) const
[taint api] - Returns the tainted addresses.
Definition: api.cpp:995
TRITON_EXPORT const triton::uint512 & getConcreteVariableValue(const triton::engines::symbolic::SymbolicVariable &symVar) const
[symbolic api] - Gets the concrete value of a symbolic variable.
Definition: api.cpp:788
TRITON_EXPORT triton::arch::architectures_e getArchitecture(void) const
[architecture api] - Returns the architecture as triton::arch::architectures_e.
Definition: api.cpp:214
triton::ast::AstContext astCtxt
The AST Context interface.
Definition: api.hpp:63
This class is used as operand wrapper.
TRITON_EXPORT bool taintAssignmentMemoryImmediate(const triton::arch::MemoryAccess &memDst)
[taint api] - Taints MemoryImmediate with assignment. Returns always false.
Definition: api.cpp:1147
TRITON_EXPORT bool untaintRegister(const triton::arch::Register &reg)
[taint api] - Untaints a register. Returns !TAINTED if the register has been untainted correctly...
Definition: api.cpp:1093
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition: ast.hpp:54
TRITON_EXPORT std::map< triton::usize, triton::engines::symbolic::SharedSymbolicExpression > sliceExpressions(const triton::engines::symbolic::SharedSymbolicExpression &expr)
[symbolic api] - Slices all expressions from a given one.
Definition: api.cpp:908
This is used as C++ API.
Definition: api.hpp:42
TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression & getSymbolicRegister(const triton::arch::Register &reg) const
[symbolic api] - Returns the shared symbolic expression corresponding to the parent register...
Definition: api.cpp:742
TRITON_EXPORT void checkModes(void) const
[modes api] - Raises an exception if modes interface is not initialized.
triton::arch::IrBuilder * irBuilder
The IR builder.
Definition: api.hpp:66
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)...
Definition: api.cpp:1043
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.
Definition: api.cpp:332
The modes class.
Definition: modes.hpp:42
This class is used when an instruction has a register operand.
Definition: register.hpp:44
TRITON_EXPORT void removeEngines(void)
[proccesing api] - Removes everything.
Definition: api.cpp:420
TRITON_EXPORT bool taintUnionMemoryRegister(const triton::arch::MemoryAccess &memDst, const triton::arch::Register &regSrc)
[taint api] - Taints MemoryRegister with union. Returns true if the memDst or regSrc are TAINTED...
Definition: api.cpp:1123
TRITON_EXPORT ~API()
Destructor of the API.
Definition: api.cpp:201
triton::engines::taint::TaintEngine * taint
The taint engine.
Definition: api.hpp:54
TRITON_EXPORT triton::ast::SharedAbstractNode processZ3Simplification(const triton::ast::SharedAbstractNode &node) const
[z3 api] - Converts a Triton&#39;s AST to a Z3&#39;s AST, perform a Z3 simplification and returns a Triton&#39;s ...
Definition: api.cpp:974
TRITON_EXPORT const triton::arch::Register & getRegister(triton::arch::registers_e id) const
[architecture api] - Returns Register from regId.
Definition: api.cpp:268
TRITON_EXPORT void concretizeAllMemory(void)
[symbolic api] - Concretizes all symbolic memory references.
Definition: api.cpp:872
TRITON_EXPORT std::map< triton::arch::registers_e, triton::engines::symbolic::SharedSymbolicExpression > getSymbolicRegisters(void) const
[symbolic api] - Returns the map of symbolic registers defined.
Definition: api.cpp:730
TRITON_EXPORT triton::ast::SharedAbstractNode unrollAst(const triton::ast::SharedAbstractNode &node)
[symbolic api] - Unrolls the SSA form of a given AST.
Definition: api.cpp:902
TRITON_EXPORT void unmapMemory(triton::uint64 baseAddr, triton::usize size=1)
[architecture api] - Removes the range [baseAddr:size] from the internal memory representation.
Definition: api.cpp:380
triton::ast::Z3Interface * z3Interface
The Z3 interface between Triton and Z3.
Definition: api.hpp:69
TRITON_EXPORT bool isSymbolicEngineEnabled(void) const
[symbolic api] - Returns true if the symbolic execution engine is enabled.
Definition: api.cpp:842
This class is used to represent an immediate.
Definition: immediate.hpp:36
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicExpression getSymbolicExpressionFromId(triton::usize symExprId) const
[symbolic api] - Returns the shared symbolic expression corresponding to an id.
Definition: api.cpp:782
TRITON_EXPORT void enableTaintEngine(bool flag)
[taint api] - Enables or disables the taint engine.
Definition: api.cpp:1007
TRITON_EXPORT void disassembly(triton::arch::Instruction &inst) const
[architecture api] - Disassembles the instruction and setup operands. You must define an architecture...
Definition: api.cpp:386
TRITON_EXPORT void setConcreteRegisterValue(const triton::arch::Register &reg, const triton::uint512 &value)
[architecture api] - Sets the concrete value of a register.
Definition: api.cpp:368
TRITON_EXPORT bool taintAssignmentRegisterMemory(const triton::arch::Register &regDst, const triton::arch::MemoryAccess &memSrc)
[taint api] - Taints RegisterMemory with assignment. Returns true if the regDst is tainted...
Definition: api.cpp:1171
TRITON_EXPORT void setConcreteVariableValue(const triton::engines::symbolic::SymbolicVariable &symVar, const triton::uint512 &value)
[symbolic api] - Sets the concrete value of a symbolic variable.
Definition: api.cpp:794
This class is used to represent a memory access.
TRITON_EXPORT bool buildSemantics(triton::arch::Instruction &inst)
[IR builder api] - Builds the instruction semantics. Returns true if the instruction is supported...
Definition: api.cpp:469
TRITON_EXPORT triton::uint32 getAstRepresentationMode(void) const
[AST representation api] - Returns the AST representation mode as triton::ast::representations::mode_...
Definition: api.cpp:483
TRITON_EXPORT std::map< triton::uint32, triton::engines::solver::SolverModel > getModel(const triton::ast::SharedAbstractNode &node) const
[solver api] - Computes and returns a model from a symbolic constraint.
Definition: api.cpp:941
TRITON_EXPORT triton::ast::SharedAbstractNode getOperandAst(const triton::arch::OperandWrapper &op)
[symbolic api] - Returns the AST corresponding to the operand.
Definition: api.cpp:616
TRITON_EXPORT triton::engines::taint::TaintEngine * getTaintEngine(void)
[taint api] - Returns the instance of the taint engine.
Definition: api.cpp:989
TRITON_EXPORT triton::uint8 getConcreteMemoryValue(triton::uint64 addr, bool execCallbacks=true) const
[architecture api] - Returns the concrete value of a memory cell.
Definition: api.cpp:320
TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression & createSymbolicFlagExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::Register &flag, const std::string &comment="")
[symbolic api] - Returns the new shared symbolic flag expression and links this expression to the ins...
Definition: api.cpp:700
TRITON_EXPORT void setConcreteMemoryValue(triton::uint64 addr, triton::uint8 value)
[architecture api] - Sets the concrete value of a memory cell.
Definition: api.cpp:344
This interface is used as abstract CPU interface. All CPU must use this interface.
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> ...
Definition: api.cpp:920
The IR builder.
Definition: irBuilder.hpp:38
std::uint64_t uint64
unisgned 64-bits
Definition: tritonTypes.hpp:34
TRITON_EXPORT void checkArchitecture(void) const
[architecture api] - Raises an exception if the architecture is not initialized.
Definition: api.cpp:219
TRITON_EXPORT triton::ast::SharedAbstractNode getRegisterAst(const triton::arch::Register &reg)
[symbolic api] - Returns the AST corresponding to the register.
Definition: api.cpp:652
TRITON_EXPORT bool taintUnionMemoryMemory(const triton::arch::MemoryAccess &memDst, const triton::arch::MemoryAccess &memSrc)
[taint api] - Taints MemoryMemory with union. Returns true if the memDst or memSrc are TAINTED...
Definition: api.cpp:1117
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
Definition: ast.hpp:38
TRITON_EXPORT bool taintMemory(triton::uint64 addr)
[taint api] - Taints an address. Returns TAINTED if the address has been tainted correctly. Otherwise it returns the last defined state.
Definition: api.cpp:1063
TRITON_EXPORT triton::engines::symbolic::SymbolicVariable * getSymbolicVariableFromId(triton::usize symVarId) const
[symbolic api] - Returns the symbolic variable corresponding to the symbolic variable id...
Definition: api.cpp:800
TRITON_EXPORT triton::engines::symbolic::SymbolicVariable * convertExpressionToSymbolicVariable(triton::usize exprId, triton::uint32 symVarSize, const std::string &symVarComment="")
[symbolic api] - Converts a symbolic expression to a symbolic variable. symVarSize must be in bits...
Definition: api.cpp:598
std::uint32_t uint32
unisgned 32-bits
Definition: tritonTypes.hpp:31
TRITON_EXPORT bool untaintMemory(triton::uint64 addr)
[taint api] - Untaints an address. Returns !TAINTED if the address has been untainted correctly...
Definition: api.cpp:1081
TRITON_EXPORT API()
Constructor of the API.
Definition: api.cpp:197
The callbacks class.
Definition: callbacks.hpp:86
TRITON_EXPORT std::list< std::map< triton::uint32, triton::engines::solver::SolverModel > > getModels(const triton::ast::SharedAbstractNode &node, triton::uint32 limit) const
[solver api] - Computes and returns several models from a symbolic constraint. The limit is the numbe...
Definition: api.cpp:947
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 shared symbolic volatile expression and links this expression to the...
Definition: api.cpp:706
TRITON_EXPORT void checkTaint(void) const
[taint api] - Raises an exception if the taint engine is not initialized.
Definition: api.cpp:983
triton::engines::solver::SolverInterface * solver
The solver engine.
Definition: api.hpp:60
The interface between Triton and Z3.
Definition: z3Interface.hpp:34
TRITON_EXPORT triton::uint32 getNumberOfRegisters(void) const
[architecture api] - Returns the number of registers according to the CPU architecture.
Definition: api.cpp:303
TRITON_EXPORT bool isFlag(triton::arch::registers_e regId) const
[architecture api] - Returns true if the register id is a flag.
Definition: api.cpp:248
TRITON_EXPORT std::set< const triton::arch::Register * > getParentRegisters(void) const
[architecture api] - Returns all parent registers.
Definition: api.cpp:314
TRITON_EXPORT triton::uint32 getGprBitSize(void) const
[architecture api] - Returns the bit in byte of the General Purpose Registers.
Definition: api.cpp:293
TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression & createSymbolicRegisterExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::Register &reg, const std::string &comment="")
[symbolic api] - Returns the new shared symbolic register expression and links this expression to the...
Definition: api.cpp:694
TRITON_EXPORT bool isSymbolicExpressionIdExists(triton::usize symExprId) const
[symbolic api] - Returns true if the symbolic expression ID exists.
Definition: api.cpp:848
TRITON_EXPORT std::map< triton::uint64, triton::engines::symbolic::SharedSymbolicExpression > getSymbolicMemory(void) const
[symbolic api] - Returns the map (<Addr : SymExpr>) of symbolic memory defined.
Definition: api.cpp:736
TRITON_EXPORT bool taintUnionRegisterImmediate(const triton::arch::Register &regDst)
[taint api] - Taints RegisterImmediate with union. Returns true if the regDst is TAINTED.
Definition: api.cpp:1129
This interface is used to interface with solvers.
TRITON_EXPORT void addCallback(triton::callbacks::getConcreteMemoryValueCallback cb)
[callbacks api] - Adds a GET_CONCRETE_MEMORY_VALUE callback (LOAD).
Definition: api.cpp:496
TRITON_EXPORT void assignSymbolicExpressionToRegister(const triton::engines::symbolic::SharedSymbolicExpression &se, const triton::arch::Register &reg)
[symbolic api] - Assigns a symbolic expression to a register.
Definition: api.cpp:718
TRITON_EXPORT bool isTainted(const triton::arch::OperandWrapper &op) const
[taint api] - Abstract taint verification. Returns true if the operand is tainted.
Definition: api.cpp:1019
std::uint8_t uint8
unisgned 8-bits
Definition: tritonTypes.hpp:25
TRITON_EXPORT void concretizeAllRegister(void)
[symbolic api] - Concretizes all symbolic register references.
Definition: api.cpp:878
TRITON_EXPORT bool isRegisterValid(triton::arch::registers_e regId) const
[architecture api] - Returns true if the regId is a register or a flag.
Definition: api.cpp:283
The taint engine class.
Definition: taintEngine.hpp:52
TRITON_EXPORT void checkIrBuilder(void) const
[IR builder api] - Raises an exception if the IR builder is not initialized.
Definition: api.cpp:463
triton::modes::Modes modes
The modes.
Definition: api.hpp:51
TRITON_EXPORT void checkSymbolic(void) const
[symbolic api] - Raises an exception if the symbolic engine is not initialized.
Definition: api.cpp:586
TRITON_EXPORT void removeAllCallbacks(void)
[callbacks api] - Removes all recorded callbacks.
Definition: api.cpp:521
TRITON_EXPORT bool taintUnionRegisterRegister(const triton::arch::Register &regDst, const triton::arch::Register &regSrc)
[taint api] - Taints RegisterRegister with union. Returns true if the regDst or regSrc are TAINTED...
Definition: api.cpp:1141
TRITON_EXPORT const triton::arch::Register & getParentRegister(const triton::arch::Register &reg) const
[architecture api] - Returns parent Register from a register.
Definition: api.cpp:273
TRITON_EXPORT triton::engines::symbolic::SymbolicVariable * convertRegisterToSymbolicVariable(const triton::arch::Register &reg, const std::string &symVarComment="")
[symbolic api] - Converts a symbolic register expression to a symbolic variable.
Definition: api.cpp:610
TRITON_EXPORT const std::unordered_map< triton::arch::registers_e, const triton::arch::Register > & getAllRegisters(void) const
[architecture api] - Returns all registers.
Definition: api.cpp:308
boost::multiprecision::uint512_t uint512
unsigned 512-bits
Definition: tritonTypes.hpp:43
TRITON_EXPORT bool isMemorySymbolized(const triton::arch::MemoryAccess &mem) const
[symbolic api] - Returns true if memory cell expressions contain symbolic variables.
Definition: api.cpp:854
TRITON_EXPORT std::list< triton::engines::symbolic::SharedSymbolicExpression > getTaintedSymbolicExpressions(void) const
[symbolic api] - Returns the list of the tainted symbolic expressions.
Definition: api.cpp:914
TRITON_EXPORT bool isMemoryTainted(triton::uint64 addr, triton::uint32 size=1) const
[taint api] - Returns true if the address:size is tainted.
Definition: api.cpp:1025
TRITON_EXPORT void assignSymbolicExpressionToMemory(const triton::engines::symbolic::SharedSymbolicExpression &se, const triton::arch::MemoryAccess &mem)
[symbolic api] - Assigns a symbolic expression to a memory.
Definition: api.cpp:712
TRITON_EXPORT bool taintRegister(const triton::arch::Register &reg)
[taint api] - Taints a register. Returns TAINTED if the register has been tainted correctly...
Definition: api.cpp:1075
TRITON_EXPORT triton::uint8 getSymbolicMemoryValue(triton::uint64 address)
[symbolic api] - Returns the symbolic memory value.
Definition: api.cpp:748
TRITON_EXPORT std::set< const triton::arch::Register * > getTaintedRegisters(void) const
[taint api] - Returns the tainted registers.
Definition: api.cpp:1001
TRITON_EXPORT const std::unordered_map< triton::usize, triton::engines::symbolic::SymbolicVariable * > & getSymbolicVariables(void) const
[symbolic api] - Returns all symbolic variables as a map of <SymVarId : SymVar>
Definition: api.cpp:926
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
Definition: tritonTypes.hpp:67
TRITON_EXPORT void setAstRepresentationMode(triton::uint32 mode)
[AST representation api] - Sets the AST representation mode.
Definition: api.cpp:488
TRITON_EXPORT void clearArchitecture(void)
[architecture api] - Clears the architecture states (registers and memory).
Definition: api.cpp:242
TRITON_EXPORT bool taintAssignmentRegisterRegister(const triton::arch::Register &regDst, const triton::arch::Register &regSrc)
[taint api] - Taints RegisterRegister with assignment. Returns true if the regDst is tainted...
Definition: api.cpp:1177
TRITON_EXPORT void removeCallback(triton::callbacks::getConcreteMemoryValueCallback cb)
[callbacks api] - Deletes a GET_CONCRETE_MEMORY_VALUE callback (LOAD).
Definition: api.cpp:526
TRITON_EXPORT triton::uint512 getSymbolicRegisterValue(const triton::arch::Register &reg)
[symbolic api] - Returns the symbolic register value.
Definition: api.cpp:766
TRITON_EXPORT void removeSymbolicExpression(triton::usize symExprId)
[symbolic api] - Removes the symbolic expression corresponding to the id.
Definition: api.cpp:676
TRITON_EXPORT triton::ast::SharedAbstractNode processSimplification(const triton::ast::SharedAbstractNode &node, bool z3=false) const
[symbolic api] - Processes all recorded simplifications. Returns the simplified node.
Definition: api.cpp:772
TRITON_EXPORT bool setTaintRegister(const triton::arch::Register &reg, bool flag)
[taint api] - Sets the flag (taint or untaint) to a register.
Definition: api.cpp:1056
TRITON_EXPORT bool isModeEnabled(enum triton::modes::mode_e mode) const
[modes api] - Returns true if the mode is enabled.
Definition: api.cpp:578
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicExpression newSymbolicExpression(const triton::ast::SharedAbstractNode &node, const std::string &comment="")
[symbolic api] - Returns a new shared symbolic expression. Note that if there are simplification pass...
Definition: api.cpp:664