libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
context.hpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
8#ifndef TRITON_CONTEXT_H
9#define TRITON_CONTEXT_H
10
12#include <triton/ast.hpp>
13#include <triton/astContext.hpp>
15#include <triton/basicBlock.hpp>
16#include <triton/callbacks.hpp>
17#include <triton/dllexport.hpp>
18#include <triton/immediate.hpp>
20#include <triton/irBuilder.hpp>
23#include <triton/modes.hpp>
25#include <triton/register.hpp>
33
34
35
37namespace triton {
45 class Context {
46 private:
48 inline void checkArchitecture(void) const;
49
51 inline void checkIrBuilder(void) const;
52
54 inline void checkSymbolic(void) const;
55
57 inline void checkSolver(void) const;
58
60 inline void checkTaint(void) const;
61
63 inline void checkLifting(void) const;
64
65
66 protected:
69
72
75
78
81
84
87
90
93
94
95 public:
98
100 TRITON_EXPORT Context();
101
104
106 TRITON_EXPORT ~Context();
107
108
109
110 /* Architecture API ============================================================================== */
111
113 TRITON_EXPORT bool isArchitectureValid(void) const;
114
116 TRITON_EXPORT triton::arch::architecture_e getArchitecture(void) const;
117
119 TRITON_EXPORT triton::arch::endianness_e getEndianness(void) const;
120
122 TRITON_EXPORT triton::arch::CpuInterface* getCpuInstance(void);
123
126
128 TRITON_EXPORT void clearArchitecture(void);
129
131 TRITON_EXPORT bool isFlag(triton::arch::register_e regId) const;
132
134 TRITON_EXPORT bool isFlag(const triton::arch::Register& reg) const;
135
137 TRITON_EXPORT bool isRegister(triton::arch::register_e regId) const;
138
140 TRITON_EXPORT bool isRegister(const triton::arch::Register& reg) const;
141
143 TRITON_EXPORT const triton::arch::Register& getRegister(triton::arch::register_e id) const;
144
146 TRITON_EXPORT const triton::arch::Register& getRegister(const std::string& name) const;
147
149 TRITON_EXPORT const triton::arch::Register& getParentRegister(const triton::arch::Register& reg) const;
150
153
155 TRITON_EXPORT bool isRegisterValid(triton::arch::register_e regId) const;
156
158 TRITON_EXPORT bool isRegisterValid(const triton::arch::Register& reg) const;
159
161 TRITON_EXPORT bool isThumb(void) const;
162
164 TRITON_EXPORT void setThumb(bool state);
165
167 TRITON_EXPORT triton::uint32 getGprBitSize(void) const;
168
170 TRITON_EXPORT triton::uint32 getGprSize(void) const;
171
173 TRITON_EXPORT triton::uint32 getNumberOfRegisters(void) const;
174
176 TRITON_EXPORT const triton::arch::Instruction getNopInstruction(void) const;
177
179 TRITON_EXPORT const std::unordered_map<triton::arch::register_e, const triton::arch::Register>& getAllRegisters(void) const;
180
182 TRITON_EXPORT const std::unordered_map<triton::uint64, triton::uint8, IdentityHash<triton::uint64>>& getConcreteMemory(void) const;
183
185 TRITON_EXPORT std::set<const triton::arch::Register*> getParentRegisters(void) const;
186
188 TRITON_EXPORT triton::uint8 getConcreteMemoryValue(triton::uint64 addr, bool execCallbacks=true) const;
189
191 TRITON_EXPORT triton::uint512 getConcreteMemoryValue(const triton::arch::MemoryAccess& mem, bool execCallbacks=true) const;
192
194 TRITON_EXPORT std::vector<triton::uint8> getConcreteMemoryAreaValue(triton::uint64 baseAddr, triton::usize size, bool execCallbacks=true) const;
195
197 TRITON_EXPORT triton::uint512 getConcreteRegisterValue(const triton::arch::Register& reg, bool execCallbacks=true) const;
198
205 TRITON_EXPORT void setConcreteMemoryValue(triton::uint64 addr, triton::uint8 value, bool execCallbacks=true);
206
213 TRITON_EXPORT void setConcreteMemoryValue(const triton::arch::MemoryAccess& mem, const triton::uint512& value, bool execCallbacks=true);
214
221 TRITON_EXPORT void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const std::vector<triton::uint8>& values, bool execCallbacks=true);
222
229 TRITON_EXPORT void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const void* area, triton::usize size, bool execCallbacks=true);
230
237 TRITON_EXPORT void setConcreteRegisterValue(const triton::arch::Register& reg, const triton::uint512& value, bool execCallbacks=true);
238
240 TRITON_EXPORT void setConcreteState(triton::arch::Architecture& other);
241
243 TRITON_EXPORT bool isConcreteMemoryValueDefined(const triton::arch::MemoryAccess& mem) const;
244
246 TRITON_EXPORT bool isConcreteMemoryValueDefined(triton::uint64 baseAddr, triton::usize size=1) const;
247
249 TRITON_EXPORT void clearConcreteMemoryValue(const triton::arch::MemoryAccess& mem);
250
252 TRITON_EXPORT void clearConcreteMemoryValue(triton::uint64 baseAddr, triton::usize size=1);
253
255 TRITON_EXPORT void disassembly(triton::arch::Instruction& inst) const;
256
258 TRITON_EXPORT void disassembly(triton::arch::BasicBlock& block, triton::uint64 addr=0) const;
259
261 TRITON_EXPORT std::vector<triton::arch::Instruction> disassembly(triton::uint64 addr, triton::usize count) const;
262
264 TRITON_EXPORT triton::arch::BasicBlock disassembly(triton::uint64 addr, bool(*filterCallback)(std::vector<triton::arch::Instruction>&)) const;
265
267 TRITON_EXPORT triton::arch::BasicBlock disassembly(triton::uint64 addr) const;
268
269
270
271 /* Processing API ================================================================================ */
272
275
278
280 TRITON_EXPORT void initEngines(void);
281
283 TRITON_EXPORT void removeEngines(void);
284
286 TRITON_EXPORT void reset(void);
287
288
289
290 /* IR API ======================================================================================== */
291
294
297
300
301
302
303 /* AST Representation API ======================================================================== */
304
307
310
311
312
313 /* Callbacks API ================================================================================= */
314
316 template <typename T> void addCallback(triton::callbacks::callback_e kind, T cb) {
317 this->callbacks.addCallback(kind, cb);
318 }
319
321 template <typename T> void removeCallback(triton::callbacks::callback_e kind, T cb) {
322 this->callbacks.removeCallback(kind, cb);
323 }
324
326 TRITON_EXPORT void clearCallbacks(void);
327
330
333
335 TRITON_EXPORT void processCallbacks(triton::callbacks::callback_e kind, const triton::arch::Register& reg);
336
337
338
339 /* Modes API====================================================================================== */
340
342 TRITON_EXPORT void setMode(triton::modes::mode_e mode, bool flag);
343
345 TRITON_EXPORT bool isModeEnabled(triton::modes::mode_e mode) const;
346
348 TRITON_EXPORT void clearModes(void);
349
350
351
352 /* Symbolic engine API =========================================================================== */
353
356
358 TRITON_EXPORT std::unordered_map<triton::arch::register_e, triton::engines::symbolic::SharedSymbolicExpression> getSymbolicRegisters(void) const;
359
361 TRITON_EXPORT std::unordered_map<triton::uint64, triton::engines::symbolic::SharedSymbolicExpression> getSymbolicMemory(void) const;
362
365
368
371
374
376 TRITON_EXPORT std::vector<triton::uint8> getSymbolicMemoryAreaValue(triton::uint64 baseAddr, triton::usize size);
377
380
383
386
389
392
395
398
401
404
407
409 TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable newSymbolicVariable(triton::uint32 varSize, const std::string& alias="");
410
413
416
419
422
425
428
431
433 TRITON_EXPORT triton::ast::SharedAbstractNode simplify(const triton::ast::SharedAbstractNode& node, bool usingSolver=false, bool usingLLVM=false) const;
434
436 TRITON_EXPORT triton::arch::BasicBlock simplify(const triton::arch::BasicBlock& block, bool padding=false) const;
437
440
443
445 TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable getSymbolicVariable(const std::string& symVarName) const;
446
448 TRITON_EXPORT const std::vector<triton::engines::symbolic::PathConstraint>& getPathConstraints(void) const;
449
451 TRITON_EXPORT std::vector<triton::engines::symbolic::PathConstraint> getPathConstraints(triton::usize start, triton::usize end) const;
452
454 TRITON_EXPORT std::vector<triton::engines::symbolic::PathConstraint> getPathConstraintsOfThread(triton::uint32 threadId) const;
455
458
460 TRITON_EXPORT std::vector<triton::ast::SharedAbstractNode> getPredicatesToReachAddress(triton::uint64 addr);
461
463 TRITON_EXPORT triton::usize getSizeOfPathConstraints(void) const;
464
466 TRITON_EXPORT void pushPathConstraint(const triton::ast::SharedAbstractNode& node, const std::string& comment="");
467
470
472 TRITON_EXPORT void popPathConstraint(void);
473
475 TRITON_EXPORT void clearPathConstraints(void);
476
478 TRITON_EXPORT bool isSymbolicExpressionExists(triton::usize symExprId) const;
479
481 TRITON_EXPORT bool isMemorySymbolized(const triton::arch::MemoryAccess& mem) const;
482
484 TRITON_EXPORT bool isMemorySymbolized(triton::uint64 addr, triton::uint32 size=1) const;
485
487 TRITON_EXPORT bool isRegisterSymbolized(const triton::arch::Register& reg) const;
488
490 TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable symbolizeExpression(triton::usize exprId, triton::uint32 symVarSize, const std::string& symVarAlias="");
491
493 TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable symbolizeMemory(const triton::arch::MemoryAccess& mem, const std::string& symVarAlias="");
494
496 TRITON_EXPORT void symbolizeMemory(triton::uint64 addr, triton::usize size);
497
499 TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable symbolizeRegister(const triton::arch::Register& reg, const std::string& symVarAlias="");
500
502 TRITON_EXPORT void concretizeAllMemory(void);
503
505 TRITON_EXPORT void concretizeAllRegister(void);
506
508 TRITON_EXPORT void concretizeMemory(const triton::arch::MemoryAccess& mem);
509
511 TRITON_EXPORT void concretizeMemory(triton::uint64 addr);
512
514 TRITON_EXPORT void concretizeRegister(const triton::arch::Register& reg);
515
517 TRITON_EXPORT std::unordered_map<triton::usize, triton::engines::symbolic::SharedSymbolicExpression> sliceExpressions(const triton::engines::symbolic::SharedSymbolicExpression& expr);
518
520 TRITON_EXPORT std::vector<triton::engines::symbolic::SharedSymbolicExpression> getTaintedSymbolicExpressions(void) const;
521
523 TRITON_EXPORT std::unordered_map<triton::usize, triton::engines::symbolic::SharedSymbolicExpression> getSymbolicExpressions(void) const;
524
526 TRITON_EXPORT std::map<triton::usize, triton::engines::symbolic::SharedSymbolicVariable> getSymbolicVariables(void) const;
527
530
533
534
535
536 /* Solver engine API ============================================================================= */
537
545 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;
546
554 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;
555
557 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;
558
560 TRITON_EXPORT triton::engines::solver::solver_e getSolver(void) const;
561
563 TRITON_EXPORT const triton::engines::solver::SolverInterface* getSolverInstance(void) const;
564
566 TRITON_EXPORT void setSolver(triton::engines::solver::solver_e kind);
567
569 TRITON_EXPORT void setCustomSolver(triton::engines::solver::SolverInterface* customSolver);
570
572 TRITON_EXPORT bool isSolverValid(void) const;
573
576
579
581 TRITON_EXPORT void setSolverTimeout(triton::uint32 ms);
582
584 TRITON_EXPORT void setSolverMemoryLimit(triton::uint32 limit);
585
586
587
588 /* Taint engine API ============================================================================== */
589
592
594 TRITON_EXPORT const std::unordered_set<triton::uint64>& getTaintedMemory(void) const;
595
597 TRITON_EXPORT std::unordered_set<const triton::arch::Register*> getTaintedRegisters(void) const;
598
600 TRITON_EXPORT bool isTainted(const triton::arch::OperandWrapper& op) const;
601
603 TRITON_EXPORT bool isMemoryTainted(triton::uint64 addr, triton::uint32 size=1) const;
604
606 TRITON_EXPORT bool isMemoryTainted(const triton::arch::MemoryAccess& mem) const;
607
609 TRITON_EXPORT bool isRegisterTainted(const triton::arch::Register& reg) const;
610
612 TRITON_EXPORT bool setTaint(const triton::arch::OperandWrapper& op, bool flag);
613
615 TRITON_EXPORT bool setTaintMemory(const triton::arch::MemoryAccess& mem, bool flag);
616
618 TRITON_EXPORT bool setTaintRegister(const triton::arch::Register& reg, bool flag);
619
621 TRITON_EXPORT bool taintMemory(triton::uint64 addr);
622
624 TRITON_EXPORT bool taintMemory(const triton::arch::MemoryAccess& mem);
625
627 TRITON_EXPORT bool taintRegister(const triton::arch::Register& reg);
628
630 TRITON_EXPORT bool untaintMemory(triton::uint64 addr);
631
633 TRITON_EXPORT bool untaintMemory(const triton::arch::MemoryAccess& mem);
634
636 TRITON_EXPORT bool untaintRegister(const triton::arch::Register& reg);
637
639 TRITON_EXPORT bool taintUnion(const triton::arch::OperandWrapper& op1, const triton::arch::OperandWrapper& op2);
640
642 TRITON_EXPORT bool taintUnion(const triton::arch::MemoryAccess& memDst, const triton::arch::Immediate& imm);
643
645 TRITON_EXPORT bool taintUnion(const triton::arch::MemoryAccess& memDst, const triton::arch::MemoryAccess& memSrc);
646
648 TRITON_EXPORT bool taintUnion(const triton::arch::MemoryAccess& memDst, const triton::arch::Register& regSrc);
649
651 TRITON_EXPORT bool taintUnion(const triton::arch::Register& regDst, const triton::arch::Immediate& imm);
652
654 TRITON_EXPORT bool taintUnion(const triton::arch::Register& regDst, const triton::arch::MemoryAccess& memSrc);
655
657 TRITON_EXPORT bool taintUnion(const triton::arch::Register& regDst, const triton::arch::Register& regSrc);
658
660 TRITON_EXPORT bool taintAssignment(const triton::arch::OperandWrapper& op1, const triton::arch::OperandWrapper& op2);
661
663 TRITON_EXPORT bool taintAssignment(const triton::arch::MemoryAccess& memDst, const triton::arch::Immediate& imm);
664
666 TRITON_EXPORT bool taintAssignment(const triton::arch::MemoryAccess& memDst, const triton::arch::MemoryAccess& memSrc);
667
669 TRITON_EXPORT bool taintAssignment(const triton::arch::MemoryAccess& memDst, const triton::arch::Register& regSrc);
670
672 TRITON_EXPORT bool taintAssignment(const triton::arch::Register& regDst, const triton::arch::Immediate& imm);
673
675 TRITON_EXPORT bool taintAssignment(const triton::arch::Register& regDst, const triton::arch::MemoryAccess& memSrc);
676
678 TRITON_EXPORT bool taintAssignment(const triton::arch::Register& regDst, const triton::arch::Register& regSrc);
679
680
681
682 /* Synthesizer engine API ============================================================================== */
683
685 TRITON_EXPORT triton::engines::synthesis::SynthesisResult synthesize(const triton::ast::SharedAbstractNode& node, bool constant=true, bool subexpr=true, bool opaque=false);
686
687
688
689 /* Lifters engine API ================================================================================= */
690
692 TRITON_EXPORT std::ostream& liftToLLVM(std::ostream& stream, const triton::ast::SharedAbstractNode& node, const char* fname="__triton", bool optimize=false);
693
695 TRITON_EXPORT std::ostream& liftToLLVM(std::ostream& stream, const triton::engines::symbolic::SharedSymbolicExpression& expr, const char* fname="__triton", bool optimize=false);
696
698 TRITON_EXPORT std::ostream& liftToPython(std::ostream& stream, const triton::engines::symbolic::SharedSymbolicExpression& expr, bool icomment=false);
699
701 TRITON_EXPORT std::ostream& liftToSMT(std::ostream& stream, const triton::engines::symbolic::SharedSymbolicExpression& expr, bool assert_=false, bool icomment=false);
702
704 TRITON_EXPORT std::ostream& liftToDot(std::ostream& stream, const triton::ast::SharedAbstractNode& node);
705
707 TRITON_EXPORT std::ostream& liftToDot(std::ostream& stream, const triton::engines::symbolic::SharedSymbolicExpression& expr);
708
711 };
712
714};
715
716#endif /* TRITON_CONTEXT_H */
This is the main Triton Context class.
Definition context.hpp:45
TRITON_EXPORT bool setTaintRegister(const triton::arch::Register &reg, bool flag)
[taint api] - Sets the flag (taint or untaint) to a register.
Definition context.cpp:1233
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable newSymbolicVariable(triton::uint32 varSize, const std::string &alias="")
[symbolic api] - Returns a new symbolic variable.
Definition context.cpp:801
TRITON_EXPORT const triton::arch::Register & getParentRegister(const triton::arch::Register &reg) const
[architecture api] - Returns parent Register from a register.
Definition context.cpp:301
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.
Definition context.cpp:1399
TRITON_EXPORT bool setTaintMemory(const triton::arch::MemoryAccess &mem, bool flag)
[taint api] - Sets the flag (taint or untaint) to a memory.
Definition context.cpp:1226
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.
Definition context.cpp:723
TRITON_EXPORT void setArchitecture(triton::arch::architecture_e arch)
[architecture api] - Initializes an architecture.
Definition context.cpp:255
TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression & getSymbolicRegister(const triton::arch::Register &reg) const
[symbolic api] - Returns the symbolic expression assigned to the parent register.
Definition context.cpp:867
TRITON_EXPORT const std::vector< triton::engines::symbolic::PathConstraint > & getPathConstraints(void) const
[symbolic api] - Returns the logical conjunction vector of path constraints.
Definition context.cpp:947
TRITON_EXPORT triton::uint512 getConcreteRegisterValue(const triton::arch::Register &reg, bool execCallbacks=true) const
[architecture api] - Returns the concrete value of a register.
Definition context.cpp:386
TRITON_EXPORT void concretizeMemory(const triton::arch::MemoryAccess &mem)
[symbolic api] - Concretizes symbolic memory cells.
Definition context.cpp:1043
TRITON_EXPORT void setCustomSolver(triton::engines::solver::SolverInterface *customSolver)
Initializes a custom solver.
Definition context.cpp:1106
TRITON_EXPORT const std::unordered_map< triton::uint64, triton::uint8, IdentityHash< triton::uint64 > > & getConcreteMemory(void) const
[architecture api] - Returns all memory.
Definition context.cpp:356
TRITON_EXPORT bool isArchitectureValid(void) const
[Architecture api] - Returns true if the architecture is valid.
Definition context.cpp:233
triton::ast::SharedAstContext astCtxt
The AST Context interface.
Definition context.hpp:89
TRITON_EXPORT const std::unordered_map< triton::arch::register_e, const triton::arch::Register > & getAllRegisters(void) const
[architecture api] - Returns all registers.
Definition context.cpp:351
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.
Definition context.cpp:729
TRITON_EXPORT bool isThumb(void) const
[architecture api] - Returns true if the execution mode is Thumb. Only useful for Arm32.
Definition context.cpp:321
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable symbolizeRegister(const triton::arch::Register &reg, const std::string &symVarAlias="")
[symbolic api] - Converts a symbolic register expression to a symbolic variable.
Definition context.cpp:741
triton::engines::symbolic::SymbolicEngine * symbolic
The symbolic engine.
Definition context.hpp:83
TRITON_EXPORT triton::engines::symbolic::SymbolicEngine * getSymbolicEngine(void)
[symbolic api] - Returns the instance of the symbolic engine.
Definition context.cpp:717
triton::arch::ShortcutRegister registers
A shortcut to access to a Register class from a register name.
Definition context.hpp:97
TRITON_EXPORT bool isRegisterTainted(const triton::arch::Register &reg) const
[taint api] - Returns true if the register is tainted.
Definition context.cpp:1214
TRITON_EXPORT void initEngines(void)
[proccesing api] - Initializes everything.
Definition context.cpp:543
TRITON_EXPORT void setSolver(triton::engines::solver::solver_e kind)
Initializes a predefined solver.
Definition context.cpp:1100
TRITON_EXPORT void setMode(triton::modes::mode_e mode, bool flag)
[modes api] - Enables or disables a specific mode.
Definition context.cpp:699
TRITON_EXPORT void popPathConstraint(void)
[symbolic api] - Pops the last constraints added to the path predicate.
Definition context.cpp:995
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.
Definition context.cpp:1136
TRITON_EXPORT triton::arch::endianness_e getEndianness(void) const
[architecture api] - Returns the endianness as triton::arch::endianness_e.
Definition context.cpp:243
TRITON_EXPORT triton::ast::SharedAbstractNode simplifyAstViaLLVM(const triton::ast::SharedAbstractNode &node) const
[lifting api] - Lifts and simplify an AST using LLVM
Definition context.cpp:1411
TRITON_EXPORT triton::uint512 getConcreteVariableValue(const triton::engines::symbolic::SharedSymbolicVariable &symVar) const
[symbolic api] - Gets the concrete value of a symbolic variable.
Definition context.cpp:923
TRITON_EXPORT std::unordered_set< const triton::arch::Register * > getTaintedRegisters(void) const
[taint api] - Returns the tainted registers.
Definition context.cpp:1190
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.
Definition context.cpp:1061
TRITON_EXPORT triton::arch::exception_e processing(triton::arch::Instruction &inst)
[proccesing api] - Processes an instruction and updates engines according to the instruction semantic...
Definition context.cpp:606
TRITON_EXPORT bool isMemoryTainted(triton::uint64 addr, triton::uint32 size=1) const
[taint api] - Returns true if the address:size is tainted.
Definition context.cpp:1202
TRITON_EXPORT bool untaintRegister(const triton::arch::Register &reg)
[taint api] - Untaints a register. Returns !TAINTED if the register has been untainted correctly....
Definition context.cpp:1270
TRITON_EXPORT void setAstRepresentationMode(triton::ast::representations::mode_e mode)
[AST representation api] - Sets the AST representation.
Definition context.cpp:648
TRITON_EXPORT void reset(void)
[proccesing api] - Resets everything.
Definition context.cpp:595
TRITON_EXPORT std::vector< triton::uint8 > getSymbolicMemoryAreaValue(triton::uint64 baseAddr, triton::usize size)
[symbolic api] - Returns the symbolic values of a memory area.
Definition context.cpp:885
TRITON_EXPORT bool isRegisterSymbolized(const triton::arch::Register &reg) const
[symbolic api] - Returns true if the register expression contains a symbolic variable.
Definition context.cpp:1025
TRITON_EXPORT bool isMemorySymbolized(const triton::arch::MemoryAccess &mem) const
[symbolic api] - Returns true if memory cell expressions contain symbolic variables.
Definition context.cpp:1013
TRITON_EXPORT bool isModeEnabled(triton::modes::mode_e mode) const
[modes api] - Returns true if the mode is enabled.
Definition context.cpp:704
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 context.cpp:843
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...
Definition context.cpp:819
triton::arch::Architecture arch
The architecture entry.
Definition context.hpp:71
TRITON_EXPORT const triton::arch::Instruction getNopInstruction(void) const
Returns a NOP instruction according to the architecture.
Definition context.cpp:346
TRITON_EXPORT Context()
Constructor of the Context.
Definition context.cpp:175
TRITON_EXPORT void setConcreteState(triton::arch::Architecture &other)
[architecture api] - Defines a concrete state.
Definition context.cpp:451
TRITON_EXPORT bool taintRegister(const triton::arch::Register &reg)
[taint api] - Taints a register. Returns TAINTED if the register has been tainted correctly....
Definition context.cpp:1252
TRITON_EXPORT bool isSymbolicExpressionExists(triton::usize symExprId) const
[symbolic api] - Returns true if the symbolic expression ID exists.
Definition context.cpp:1007
void removeCallback(triton::callbacks::callback_e kind, T cb)
[callbacks api] - Removes a callback.
Definition context.hpp:321
TRITON_EXPORT bool isFlag(triton::arch::register_e regId) const
[architecture api] - Returns true if the register id is a flag.
Definition context.cpp:271
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 ...
Definition context.cpp:1373
TRITON_EXPORT triton::engines::taint::TaintEngine * getTaintEngine(void)
[taint api] - Returns the instance of the taint engine.
Definition context.cpp:1178
TRITON_EXPORT triton::usize getSizeOfPathConstraints(void) const
[symbolic api] - Returns the size of the path constraints
Definition context.cpp:965
TRITON_EXPORT void disassembly(triton::arch::Instruction &inst) const
[architecture api] - Disassembles the instruction and setup operands.
Definition context.cpp:510
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.
Definition context.cpp:674
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 context.cpp:837
void addCallback(triton::callbacks::callback_e kind, T cb)
[callbacks api] - Adds a callback.
Definition context.hpp:316
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 context.cpp:380
TRITON_EXPORT void setSolverMemoryLimit(triton::uint32 limit)
[solver api] - Defines a solver memory consumption limit (in megabytes).
Definition context.cpp:1169
TRITON_EXPORT triton::ast::SharedAstContext getAstContext(void)
[IR builder api] - Returns the AST context. Used as AST builder.
Definition context.cpp:635
TRITON_EXPORT void removeSymbolicExpression(const triton::engines::symbolic::SharedSymbolicExpression &expr)
[symbolic api] - Removes the symbolic expression corresponding to the id.
Definition context.cpp:807
TRITON_EXPORT void setThumb(bool state)
[architecture api] - Sets CPU state to Thumb mode.
Definition context.cpp:326
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...
Definition context.cpp:1118
TRITON_EXPORT triton::uint32 getGprBitSize(void) const
[architecture api] - Returns the bit in byte of the General Purpose Registers.
Definition context.cpp:331
TRITON_EXPORT void concretizeAllMemory(void)
[symbolic api] - Concretizes all symbolic memory cells.
Definition context.cpp:1031
triton::engines::taint::TaintEngine * taint
The taint engine.
Definition context.hpp:80
TRITON_EXPORT const triton::arch::Register & getRegister(triton::arch::register_e id) const
[architecture api] - Returns Register from regId.
Definition context.cpp:291
TRITON_EXPORT bool taintUnion(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
[taint api] - Abstract union tainting.
Definition context.cpp:1276
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...
Definition context.cpp:813
TRITON_EXPORT void setConcreteVariableValue(const triton::engines::symbolic::SharedSymbolicVariable &symVar, const triton::uint512 &value)
[symbolic api] - Sets the concrete value of a symbolic variable.
Definition context.cpp:929
triton::modes::SharedModes modes
The modes.
Definition context.hpp:74
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...
Definition context.cpp:795
TRITON_EXPORT std::vector< triton::engines::symbolic::SharedSymbolicExpression > getTaintedSymbolicExpressions(void) const
[symbolic api] - Returns the list of the tainted symbolic expressions.
Definition context.cpp:1067
TRITON_EXPORT triton::ast::SharedAbstractNode getRegisterAst(const triton::arch::Register &reg)
[symbolic api] - Returns the AST corresponding to the register.
Definition context.cpp:783
TRITON_EXPORT ~Context()
Destructor of the Context.
Definition context.cpp:189
TRITON_EXPORT triton::uint8 getSymbolicMemoryValue(triton::uint64 address)
[symbolic api] - Returns the symbolic memory value.
Definition context.cpp:873
TRITON_EXPORT bool isTainted(const triton::arch::OperandWrapper &op) const
[taint api] - Abstract taint verification. Returns true if the operand is tainted.
Definition context.cpp:1196
triton::engines::solver::SolverEngine * solver
The solver engine.
Definition context.hpp:86
TRITON_EXPORT bool isRegister(triton::arch::register_e regId) const
[architecture api] - Returns true if the regId is a register.
Definition context.cpp:281
triton::arch::IrBuilder * irBuilder
The IR builder.
Definition context.hpp:92
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...
Definition context.cpp:897
TRITON_EXPORT std::vector< triton::ast::SharedAbstractNode > getPredicatesToReachAddress(triton::uint64 addr)
[symbolic api] - Returns path predicates which may reach the targeted address.
Definition context.cpp:977
TRITON_EXPORT bool untaintMemory(triton::uint64 addr)
[taint api] - Untaints an address. Returns !TAINTED if the address has been untainted correctly....
Definition context.cpp:1258
TRITON_EXPORT triton::arch::CpuInterface * getCpuInstance(void)
[architecture api] - Returns the instance of the current CPU used.
Definition context.cpp:248
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...
Definition context.cpp:831
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicVariable getSymbolicVariable(triton::usize symVarId) const
[symbolic api] - Returns the symbolic variable corresponding to the symbolic variable id.
Definition context.cpp:935
triton::engines::lifters::LiftingEngine * lifting
The lifting engine.
Definition context.hpp:77
TRITON_EXPORT void concretizeAllRegister(void)
[symbolic api] - Concretizes all symbolic register.
Definition context.cpp:1037
TRITON_EXPORT triton::engines::solver::solver_e getSolver(void) const
Returns the kind of solver as triton::engines::solver::solver_e.
Definition context.cpp:1088
TRITON_EXPORT triton::arch::architecture_e getArchitecture(void) const
[architecture api] - Returns the architecture as triton::arch::architecture_e.
Definition context.cpp:238
TRITON_EXPORT triton::ast::SharedAbstractNode getImmediateAst(const triton::arch::Immediate &imm)
[symbolic api] - Returns the AST corresponding to the immediate.
Definition context.cpp:759
TRITON_EXPORT triton::uint32 getGprSize(void) const
[architecture api] - Returns the size in byte of the General Purpose Registers.
Definition context.cpp:336
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,...
Definition context.cpp:1393
TRITON_EXPORT void setSolverTimeout(triton::uint32 ms)
[solver api] - Defines a solver timeout (in milliseconds).
Definition context.cpp:1163
TRITON_EXPORT triton::ast::representations::mode_e getAstRepresentationMode(void) const
[AST representation api] - Returns the AST representation as triton::ast::representation_e.
Definition context.cpp:643
TRITON_EXPORT bool isSolverValid(void) const
Returns true if the solver is valid.
Definition context.cpp:1112
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.
Definition context.cpp:861
TRITON_EXPORT triton::uint8 getConcreteMemoryValue(triton::uint64 addr, bool execCallbacks=true) const
[architecture api] - Returns the concrete value of a memory cell.
Definition context.cpp:368
TRITON_EXPORT void concretizeRegister(const triton::arch::Register &reg)
[symbolic api] - Concretizes a symbolic register.
Definition context.cpp:1055
TRITON_EXPORT void setConcreteMemoryValue(triton::uint64 addr, triton::uint8 value, bool execCallbacks=true)
[architecture api] - Sets the concrete value of a memory cell.
Definition context.cpp:392
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.
Definition context.cpp:855
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....
Definition context.cpp:1363
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...
Definition context.cpp:1152
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.
Definition context.cpp:623
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>
Definition context.cpp:1079
TRITON_EXPORT bool taintMemory(triton::uint64 addr)
[taint api] - Taints an address. Returns TAINTED if the address has been tainted correctly....
Definition context.cpp:1240
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 symbolic register expression and links this expression to the instru...
Definition context.cpp:825
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.
Definition context.cpp:414
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.
Definition context.cpp:983
TRITON_EXPORT triton::ast::SharedAbstractNode getOperandAst(const triton::arch::OperandWrapper &op)
[symbolic api] - Returns the AST corresponding to the operand.
Definition context.cpp:747
TRITON_EXPORT void clearConcreteMemoryValue(const triton::arch::MemoryAccess &mem)
Clears concrete values assigned to the memory cells.
Definition context.cpp:498
TRITON_EXPORT void clearArchitecture(void)
[architecture api] - Clears the architecture states (registers and memory).
Definition context.cpp:265
TRITON_EXPORT const std::unordered_set< triton::uint64 > & getTaintedMemory(void) const
[taint api] - Returns the tainted addresses.
Definition context.cpp:1184
TRITON_EXPORT std::set< const triton::arch::Register * > getParentRegisters(void) const
[architecture api] - Returns all parent registers.
Definition context.cpp:362
TRITON_EXPORT triton::uint32 getNumberOfRegisters(void) const
[architecture api] - Returns the number of registers according to the CPU architecture.
Definition context.cpp:341
TRITON_EXPORT void setConcreteRegisterValue(const triton::arch::Register &reg, const triton::uint512 &value, bool execCallbacks=true)
[architecture api] - Sets the concrete value of a register.
Definition context.cpp:440
TRITON_EXPORT triton::uint512 getSymbolicRegisterValue(const triton::arch::Register &reg)
[symbolic api] - Returns the symbolic register value.
Definition context.cpp:891
TRITON_EXPORT bool taintAssignment(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
[taint api] - Abstract assignment tainting.
Definition context.cpp:1318
TRITON_EXPORT triton::engines::symbolic::SharedSymbolicExpression getSymbolicExpression(triton::usize symExprId) const
[symbolic api] - Returns the symbolic expression corresponding to an id.
Definition context.cpp:917
TRITON_EXPORT void clearPathConstraints(void)
[symbolic api] - Clears the current path predicate.
Definition context.cpp:1001
TRITON_EXPORT triton::ast::SharedAbstractNode getPathPredicate(void)
[symbolic api] - Returns the current path predicate as an AST of logical conjunction of each taken br...
Definition context.cpp:971
TRITON_EXPORT void clearCallbacks(void)
[callbacks api] - Clears recorded callbacks.
Definition context.cpp:669
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.
Definition context.cpp:959
TRITON_EXPORT void removeEngines(void)
[proccesing api] - Removes everything.
Definition context.cpp:571
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...
Definition context.cpp:1124
TRITON_EXPORT void clearModes(void)
[modes api] - Clears recorded modes.
Definition context.cpp:709
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 context.cpp:1073
TRITON_EXPORT bool isRegisterValid(triton::arch::register_e regId) const
[architecture api] - Returns true if the regId is a register or a flag.
Definition context.cpp:311
triton::callbacks::Callbacks callbacks
The Callbacks interface.
Definition context.hpp:68
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....
Definition context.cpp:1387
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 context.cpp:1220
TRITON_EXPORT const triton::engines::solver::SolverInterface * getSolverInstance(void) const
Returns the instance of the initialized solver.
Definition context.cpp:1094
TRITON_EXPORT triton::ast::SharedAbstractNode getMemoryAst(const triton::arch::MemoryAccess &mem)
[symbolic api] - Returns the AST corresponding to the memory.
Definition context.cpp:771
TRITON_EXPORT bool isConcreteMemoryValueDefined(const triton::arch::MemoryAccess &mem) const
Returns true if memory cells have a defined concrete value.
Definition context.cpp:486
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.
Definition context.cpp:1130
The abstract architecture class.
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 immediate.
Definition immediate.hpp:37
This class is used to represent an instruction.
The IR builder.
Definition irBuilder.hpp:40
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.
Definition register.hpp:44
This is used as a shortcut to access to registers.
The callbacks class.
Definition callbacks.hpp:79
TRITON_EXPORT void removeCallback(triton::callbacks::callback_e kind, ComparableFunctor< void(triton::Context &, const triton::arch::MemoryAccess &)> cb)
Deletes a GET_CONCRETE_MEMORY_VALUE callback.
TRITON_EXPORT void addCallback(triton::callbacks::callback_e kind, ComparableFunctor< void(triton::Context &, const triton::arch::MemoryAccess &)> cb)
Adds a GET_CONCRETE_MEMORY_VALUE callback.
Definition callbacks.cpp:26
This class is used to interface with solvers.
This interface is used to interface with solvers.
The SynthesisResult engine class.
register_e
Types of register.
Definition archEnums.hpp:68
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition ast.hpp:59
std::shared_ptr< triton::ast::AstContext > SharedAstContext
Shared AST context.
Definition ast.hpp:65
mode_e
Enumerates all kinds of mode.
std::shared_ptr< triton::modes::Modes > SharedModes
Shared Modes.
Definition modes.hpp:66
mode_e
All types of representation mode.
Definition astEnums.hpp:98
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
Definition ast.hpp:40
std::shared_ptr< triton::engines::symbolic::SymbolicVariable > SharedSymbolicVariable
Shared Symbolic variable.
Definition ast.hpp:43
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
The Triton namespace.