libTriton  version 0.7 build 1409
bindings.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_PIN_PYTHONBINDINGS_H
9 #define TRITON_PIN_PYTHONBINDINGS_H
10 
11 /* libTriton */
13 #include <triton/api.hpp>
14 #include <triton/tritonTypes.hpp>
15 
16 #include <map>
17 #include <set>
18 #include <list>
19 
20 #include <pin.H>
21 
22 /* pintool */
23 #include "snapshot.hpp"
24 #include "trigger.hpp"
25 #include "utils.hpp"
26 
27 
29 namespace tracer {
35  namespace pintool {
43  extern Trigger analysisTrigger;
45 
47  extern Snapshot snapshot;
48 
50  extern PyMethodDef pintoolCallbacks[];
51 
53  bool execScript(const char* fileName);
54 
55  #if IS_PY3
56  PyObject* initpintool(void);
58  #else
59  void initpintool(void);
61  #endif
62 
64  void initPythonArgs(int argc, char* argv[]);
65 
67  namespace options {
74  enum cb_kind {
86  };
87 
89  extern char* startAnalysisFromSymbol;
90 
92  extern bool startAnalysisFromEntry;
93 
95  extern std::set<triton::__uint> startAnalysisFromAddress;
96 
98  extern std::set<triton::__uint> startAnalysisFromOffset;
99 
101  extern std::set<triton::__uint> stopAnalysisFromAddress;
102 
104  extern std::set<triton::__uint> stopAnalysisFromOffset;
105 
107  extern PyObject* callbackAfter;
108 
110  extern PyObject* callbackBefore;
111 
113  extern PyObject* callbackBeforeIRProc;
114 
116  extern PyObject* callbackFini;
117 
119  extern PyObject* callbackSignals;
120 
122  extern PyObject* callbackSyscallEntry;
123 
125  extern PyObject* callbackSyscallExit;
126 
128  extern PyObject* callbackImageLoad;
129 
131  extern std::map<const char*, PyObject*> callbackRoutineEntry;
132 
134  extern std::map<const char*, PyObject*> callbackRoutineExit;
135 
137  extern std::list<const char*> imageWhitelist;
138 
140  extern std::list<const char*> imageBlacklist;
141 
144 
146  };
147 
149  namespace callbacks {
156  void after(triton::arch::Instruction* inst);
158 
160  void before(triton::arch::Instruction* inst);
161 
164 
166  void fini(void);
167 
169  void routine(triton::uint32 threadId, PyObject* callback);
170 
172  void signals(triton::uint32 threadId, triton::sint32 sig);
173 
176 
179 
181  void imageLoad(std::string imagePath, triton::__uint imageBase, triton::__uint imageSize);
182 
185 
188 
190  };
191 
193  };
195 };
196 
197 #endif /* TRITON_PIN_PYTHONBINDINGS_H */
PyObject * callbackAfter
Callback called after the instruction processing.
Definition: init.cpp:122
This class is used when to represent an instruction.
Definition: instruction.hpp:47
After the instruction processing.
Definition: bindings.hpp:76
void preProcessing(triton::arch::Instruction *inst, triton::uint32 threadId)
Pre processing configuration.
Definition: callbacks.cpp:202
Snapshot snapshot
Snapshot engine.
Definition: main.cpp:204
PyObject * callbackSyscallEntry
Callback called before the syscall processing.
Definition: init.cpp:128
void beforeIRProc(triton::arch::Instruction *inst)
Callback called before the IR processing.
Definition: callbacks.cpp:75
Before the syscall processing.
Definition: bindings.hpp:83
At the end of the execution.
Definition: bindings.hpp:79
PyObject * callbackSyscallExit
Callback called after the syscall processing.
Definition: init.cpp:129
When a signal occurs.
Definition: bindings.hpp:82
PyObject * callbackBeforeIRProc
Callback called before the IR processing.
Definition: init.cpp:124
void routine(triton::uint32 threadId, PyObject *callback)
Callback called before and after routine processing.
Definition: callbacks.cpp:114
After the syscall processing.
Definition: bindings.hpp:84
void initpintool(void)
The initialization of the pintool python 2 module.
Definition: init.cpp:163
When an image is loaded.
Definition: bindings.hpp:85
PyMethodDef pintoolCallbacks[]
Python callbacks of the pintool module.
Definition: bindings.cpp:569
PyObject * callbackBefore
Callback called before the instruction processing.
Definition: init.cpp:123
std::list< const char * > imageWhitelist
An image white list.
Definition: init.cpp:133
std::map< const char *, PyObject * > callbackRoutineEntry
Callback called before routine processing.
Definition: init.cpp:134
cb_kind
Kind of callback.
Definition: bindings.hpp:75
void before(triton::arch::Instruction *inst)
Callback called before the instruction processing.
Definition: callbacks.cpp:53
void syscallExit(triton::uint32 threadId, triton::uint32 std)
Callback called after the syscall processing.
Definition: callbacks.cpp:163
triton::uint32 targetThreadId
TID focused during the JIT.
Definition: init.cpp:140
std::list< const char * > imageBlacklist
An image black list.
Definition: init.cpp:132
void fini(void)
Callback called at the end of the execution.
Definition: callbacks.cpp:97
std::map< const char *, PyObject * > callbackRoutineExit
Callback callled after routine processing.
Definition: init.cpp:135
void signals(triton::uint32 threadId, triton::sint32 sig)
Callback called when a signal occurs.
Definition: callbacks.cpp:125
std::set< triton::__uint > stopAnalysisFromAddress
Stop analysis from address.
Definition: init.cpp:138
std::set< triton::__uint > startAnalysisFromAddress
Start analysis from a symbol.
Definition: init.cpp:136
void after(triton::arch::Instruction *inst)
Callback called after the instruction processing.
Definition: callbacks.cpp:31
std::set< triton::__uint > stopAnalysisFromOffset
Stop analysis from an offset.
Definition: init.cpp:139
PyObject * callbackImageLoad
Callback called when an image is loaded.
Definition: init.cpp:126
std::set< triton::__uint > startAnalysisFromOffset
Start analysis from an offset.
Definition: init.cpp:137
std::int32_t sint32
signed 32-bits
Definition: tritonTypes.hpp:52
std::uint32_t uint32
unisgned 32-bits
Definition: tritonTypes.hpp:31
void syscallEntry(triton::uint32 threadId, triton::uint32 std)
Callback called before the syscall processing.
Definition: callbacks.cpp:144
Before the routine processing.
Definition: bindings.hpp:80
void initPythonArgs(int argc, char *argv[])
The initialization of the pintool python arguments.
Definition: init.cpp:247
bool startAnalysisFromEntry
Start analysis from the entry point.
Definition: init.cpp:130
PyObject * callbackSignals
Callback called when a signal occurs.
Definition: init.cpp:127
Before the instruction processing.
Definition: bindings.hpp:77
PyObject * callbackFini
Callback called at the end of the execution.
Definition: init.cpp:125
void imageLoad(std::string imagePath, triton::__uint imageBase, triton::__uint imageSize)
Callback called when an image is loaded.
Definition: callbacks.cpp:182
char * startAnalysisFromSymbol
Start analysis from a symbol.
Definition: init.cpp:131
unsigned long long __uint
unsigned long long if the arch is 64-bits.
Definition: tritonTypes.hpp:71
void postProcessing(triton::arch::Instruction *inst, triton::uint32 threadId)
Post processing configuration.
Definition: callbacks.cpp:221
The Tracer namespace.
Definition: api.cpp:12
After the routine processing.
Definition: bindings.hpp:81
Trigger analysisTrigger
Lock / Unlock InsertCall.
Definition: main.cpp:201
bool execScript(const char *fileName)
The python script which will be executed by Pin.
Definition: init.cpp:227