libTriton  version 0.6 build 1367
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 
56  void initBindings(int argc, char* argv[]);
57 
59  namespace options {
66  enum cb_kind {
78  };
79 
81  extern char* startAnalysisFromSymbol;
82 
84  extern bool startAnalysisFromEntry;
85 
87  extern std::set<triton::__uint> startAnalysisFromAddress;
88 
90  extern std::set<triton::__uint> startAnalysisFromOffset;
91 
93  extern std::set<triton::__uint> stopAnalysisFromAddress;
94 
96  extern std::set<triton::__uint> stopAnalysisFromOffset;
97 
99  extern PyObject* callbackAfter;
100 
102  extern PyObject* callbackBefore;
103 
105  extern PyObject* callbackBeforeIRProc;
106 
108  extern PyObject* callbackFini;
109 
111  extern PyObject* callbackSignals;
112 
114  extern PyObject* callbackSyscallEntry;
115 
117  extern PyObject* callbackSyscallExit;
118 
120  extern PyObject* callbackImageLoad;
121 
123  extern std::map<const char*, PyObject*> callbackRoutineEntry;
124 
126  extern std::map<const char*, PyObject*> callbackRoutineExit;
127 
129  extern std::list<const char*> imageWhitelist;
130 
132  extern std::list<const char*> imageBlacklist;
133 
136 
138  };
139 
141  namespace callbacks {
148  void after(triton::arch::Instruction* inst);
150 
152  void before(triton::arch::Instruction* inst);
153 
156 
158  void fini(void);
159 
161  void routine(triton::uint32 threadId, PyObject* callback);
162 
164  void signals(triton::uint32 threadId, triton::sint32 sig);
165 
168 
170  void syscallExit(triton::uint32 threadId, triton::uint32 std);
171 
173  void imageLoad(std::string imagePath, triton::__uint imageBase, triton::__uint imageSize);
174 
177 
180 
182  };
183 
185  };
187 };
188 
189 #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:46
After the instruction processing.
Definition: bindings.hpp:68
void preProcessing(triton::arch::Instruction *inst, triton::uint32 threadId)
Pre processing configuration.
Definition: callbacks.cpp:202
Snapshot snapshot
Snapshot engine.
Definition: main.cpp:208
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:75
At the end of the execution.
Definition: bindings.hpp:71
PyObject * callbackSyscallExit
Callback called after the syscall processing.
Definition: init.cpp:129
When a signal occurs.
Definition: bindings.hpp:74
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:76
When an image is loaded.
Definition: bindings.hpp:77
PyMethodDef pintoolCallbacks[]
Python callbacks of the pintool module.
Definition: bindings.cpp:572
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:67
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
void initBindings(int argc, char *argv[])
The initialization of the Pin&#39;s Python env.
Definition: init.cpp:144
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:72
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:69
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:73
Trigger analysisTrigger
Lock / Unlock InsertCall.
Definition: main.cpp:205
bool execScript(const char *fileName)
The python script which will be executed by Pin.
Definition: init.cpp:207