libTriton version 1.0 build 1590
Loading...
Searching...
No Matches
pythonObjects.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
9#ifndef TRITON_PYOBJECT_H
10#define TRITON_PYOBJECT_H
11
13
14#include <triton/archEnums.hpp>
15#include <triton/ast.hpp>
16#include <triton/basicBlock.hpp>
17#include <triton/bitsVector.hpp>
18#include <triton/immediate.hpp>
22#include <triton/register.hpp>
26
27
28
30namespace triton {
36 class Context;
37
39 namespace bindings {
47 namespace python {
55 PyObject* PyAstNode(const triton::ast::SharedAbstractNode& node);
56
58 template <typename T> PyObject* PyBitsVector(const T& op);
59
61 PyObject* PyImmediate(const triton::arch::Immediate& imm);
62
64 PyObject* PyBasicBlock(void);
65
67 PyObject* PyBasicBlock(const triton::arch::BasicBlock& block);
68
70 PyObject* PyBasicBlock(std::vector<triton::arch::Instruction>& insts);
71
73 PyObject* PyInstruction(void);
74
76 PyObject* PyInstruction(const triton::arch::Instruction& inst);
77
79 PyObject* PyInstruction(const void* opcodes, triton::uint32 opSize);
80
82 PyObject* PyInstruction(triton::uint64 addr, const void* opcodes, triton::uint32 opSize);
83
85 PyObject* PyMemoryAccess(const triton::arch::MemoryAccess& mem);
86
89
91 PyObject* PyTritonContext(void);
92
95
97 PyObject* PyTritonContextRef(triton::Context& ctx);
98
100 PyObject* PyAstContext(const triton::ast::SharedAstContext& actx);
101
103 PyObject* PyRegister(const triton::arch::Register& reg);
104
107
110
113
114 /* AstNode ======================================================== */
115
117 typedef struct {
118 PyObject_HEAD
121
123 extern PyTypeObject AstNode_Type;
124
125 /* BitsVector ====================================================== */
126
128 typedef struct {
129 PyObject_HEAD
132
134 extern PyTypeObject BitsVector_Type;
135
136 /* Basic Block ===================================================== */
137
139 typedef struct {
140 PyObject_HEAD
143
145 extern PyTypeObject BasicBlock_Type;
146
147 /* Immediate ====================================================== */
148
150 typedef struct {
151 PyObject_HEAD
154
156 extern PyTypeObject Immediate_Type;
157
158 /* Instruction ==================================================== */
159
161 typedef struct {
162 PyObject_HEAD
165
167 extern PyTypeObject Instruction_Type;
168
169 /* MemoryAccess =================================================== */
170
172 typedef struct {
173 PyObject_HEAD
176
178 extern PyTypeObject MemoryAccess_Type;
179
180 /* PathConstraint ================================================= */
181
183 typedef struct {
184 PyObject_HEAD
187
189 extern PyTypeObject PathConstraint_Type;
190
191 /* Register ======================================================= */
192
194 typedef struct {
195 PyObject_HEAD
198
200 extern PyTypeObject Register_Type;
201
202 /* TrytonContext ======================================================= */
203
205 typedef struct {
206 PyObject_HEAD
207 triton::Context* ctx;
208 bool ref;
209 PyObject* regAttr;
211
213 extern PyTypeObject TritonContextObject_Type;
214
215 /* AstContext ======================================================= */
216
218 typedef struct {
219 PyObject_HEAD
222
224 extern PyTypeObject AstContextObject_Type;
225
226 /* SolverModel ==================================================== */
227
229 typedef struct {
230 PyObject_HEAD
233
235 extern PyTypeObject SolverModel_Type;
236
237 /* SymbolicExpression ============================================= */
238
240 typedef struct {
241 PyObject_HEAD
244
246 extern PyTypeObject SymbolicExpression_Type;
247
248 /* SymbolicVariable =============================================== */
249
251 typedef struct {
252 PyObject_HEAD
255
257 extern PyTypeObject SymbolicVariable_Type;
258
260 };
262 };
264};
265
266
268#define PyAstNode_AsAstNode(v) (((triton::bindings::python::AstNode_Object*)(v))->node)
269
271#define PyBitsVector_Check(v) ((v)->ob_type == &triton::bindings::python::BitsVector_Type)
272
274#define PyBitsVector_AsBitsVector(v) (((triton::bindings::python::BitsVector_Object*)(v))->bv)
275
277#define PyBasicBlock_Check(v) ((v)->ob_type == &triton::bindings::python::BasicBlock_Type)
278
280#define PyBasicBlock_AsBasicBlock(v) (((triton::bindings::python::BasicBlock_Object*)(v))->block)
281
283#define PyImmediate_Check(v) ((v)->ob_type == &triton::bindings::python::Immediate_Type)
284
286#define PyImmediate_AsImmediate(v) (((triton::bindings::python::Immediate_Object*)(v))->imm)
287
289#define PyInstruction_Check(v) ((v)->ob_type == &triton::bindings::python::Instruction_Type)
290
292#define PyInstruction_AsInstruction(v) (((triton::bindings::python::Instruction_Object*)(v))->inst)
293
295#define PyMemoryAccess_Check(v) ((v)->ob_type == &triton::bindings::python::MemoryAccess_Type)
296
298#define PyMemoryAccess_AsMemoryAccess(v) (((triton::bindings::python::MemoryAccess_Object*)(v))->mem)
299
301#define PyPathConstraint_Check(v) ((v)->ob_type == &triton::bindings::python::PathConstraint_Type)
302
304#define PyPathConstraint_AsPathConstraint(v) (((triton::bindings::python::PathConstraint_Object*)(v))->pc)
305
307#define PyTritonContext_Check(v) ((v)->ob_type == &triton::bindings::python::TritonContext_Type)
308
310#define PyTritonContext_AsTritonContext(v) (((triton::bindings::python::TritonContext_Object*)(v))->ctx)
311
313#define PyAstContext_Check(v) ((v)->ob_type == &triton::bindings::python::AstContext_Type)
314
316#define PyAstContext_AsAstContext(v) (((triton::bindings::python::AstContext_Object*)(v))->actx)
317
319#define PyRegister_Check(v) ((v)->ob_type == &triton::bindings::python::Register_Type)
320
322#define PyRegister_AsRegister(v) (((triton::bindings::python::Register_Object*)(v))->reg)
323
325#define PySolverModel_Check(v) ((v)->ob_type == &triton::bindings::python::SolverModel_Type)
326
328#define PySolverModel_AsSolverModel(v) (((triton::bindings::python::SolverModel_Object*)(v))->model)
329
331#define PyAstNode_Check(v) ((v)->ob_type == &triton::bindings::python::AstNode_Type)
332
334#define PySymbolicExpression_Check(v) ((v)->ob_type == &triton::bindings::python::SymbolicExpression_Type)
335
337#define PySymbolicExpression_AsSymbolicExpression(v) (((triton::bindings::python::SymbolicExpression_Object*)(v))->symExpr)
338
340#define PySymbolicVariable_Check(v) ((v)->ob_type == &triton::bindings::python::SymbolicVariable_Type)
341
343#define PySymbolicVariable_AsSymbolicVariable(v) (((triton::bindings::python::SymbolicVariable_Object*)(v))->symVar)
344
345#endif /* TRITON_PYOBJECT_H */
This is the main Triton Context class.
Definition context.hpp:45
This class is used to represent a basic block.
This class is used to deal with registers and memory as bits vector.
This class is used to represent an immediate.
Definition immediate.hpp:37
This class is used to represent an instruction.
This class is used to represent a memory access.
This class is used when an instruction has a register operand.
Definition register.hpp:44
This class is used to represent a constraint model solved.
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
PyTypeObject AstNode_Type
pyAstNode type.
PyObject * PyTritonContextRef(triton::Context &ctx)
Creates a TritonContext python class which is a reference to another Context.
PyObject * PyPathConstraint(const triton::engines::symbolic::PathConstraint &pc)
Creates the PathConstraint python class.
PyTypeObject BasicBlock_Type
pyBasicBlock type.
PyTypeObject SymbolicVariable_Type
pySymbolicVariable type.
PyObject * PySymbolicVariable(const triton::engines::symbolic::SharedSymbolicVariable &symVar)
Creates the SymbolicVariable python class.
PyObject * PySolverModel(const triton::engines::solver::SolverModel &model)
Creates the SolverModel python class.
PyObject * PyImmediate(const triton::arch::Immediate &imm)
Creates the Immediate python class.
PyTypeObject PathConstraint_Type
pyPathConstraint type.
PyTypeObject SymbolicExpression_Type
pySymbolicExpression type.
PyTypeObject Instruction_Type
pyInstruction type.
PyTypeObject BitsVector_Type
pyBitsVector type.
PyObject * PyAstContext(const triton::ast::SharedAstContext &actx)
Creates an AstContext python class.
PyObject * PyBasicBlock(void)
Creates the BasicBlock python class.
PyObject * PyInstruction(void)
Creates the Instruction python class.
PyTypeObject Register_Type
pyRegister type.
PyTypeObject SolverModel_Type
pySolverModel type.
PyTypeObject MemoryAccess_Type
pyMemory type.
PyObject * PyRegister(const triton::arch::Register &reg)
Creates the Register python class.
PyObject * PyTritonContext(void)
Creates the new TritonContext python class.
PyObject * PySymbolicExpression(const triton::engines::symbolic::SharedSymbolicExpression &symExpr)
Creates the SymbolicExpression python class.
PyTypeObject Immediate_Type
pyImmediate type.
PyObject * PyMemoryAccess(const triton::arch::MemoryAccess &mem)
Creates the Memory python class.
PyTypeObject TritonContextObject_Type
pyRegister type.
PyObject * PyAstNode(const triton::ast::SharedAbstractNode &node)
Creates the AstNode python class.
PyTypeObject AstContextObject_Type
pyRegister type.
std::shared_ptr< triton::engines::symbolic::SymbolicVariable > SharedSymbolicVariable
Shared Symbolic variable.
Definition ast.hpp:43
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
Definition ast.hpp:40
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
The Triton namespace.
bool ref
Pointer to the cpp triton context.
PyObject * regAttr
Determine if this instance is a reference or not.