libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
callbacks.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_CALLBACKS_H
9#define TRITON_CALLBACKS_H
10
11#include <atomic>
12#include <list>
13
14#include <triton/ast.hpp>
17#include <triton/dllexport.hpp>
19#include <triton/register.hpp>
21
22
23
25namespace triton {
31 class Context;
32
34 namespace callbacks {
47
54
61
68
76
78
79 class Callbacks {
80 private:
82 triton::Context& ctx;
83
85 std::atomic<bool> mget;
86
88 std::atomic<bool> mload;
89
91 std::atomic<bool> mput;
92
94 std::atomic<bool> mstore;
95
97 std::atomic<bool> defined;
98
99 protected:
101 std::list<triton::callbacks::getConcreteMemoryValueCallback> getConcreteMemoryValueCallbacks;
102
104 std::list<triton::callbacks::getConcreteRegisterValueCallback> getConcreteRegisterValueCallbacks;
105
107 std::list<triton::callbacks::setConcreteMemoryValueCallback> setConcreteMemoryValueCallbacks;
108
110 std::list<triton::callbacks::setConcreteRegisterValueCallback> setConcreteRegisterValueCallbacks;
111
113 std::list<triton::callbacks::symbolicSimplificationCallback> symbolicSimplificationCallbacks;
114
116 triton::usize countCallbacks(void) const;
117
119 template <typename T> void removeSingleCallback(std::list<T>& container, T cb);
120
121 public:
123 TRITON_EXPORT Callbacks(triton::Context& ctx);
124
127
130
133
136
139
141 TRITON_EXPORT void clearCallbacks(void);
142
145
148
151
154
157
160
163
165 TRITON_EXPORT void processCallbacks(triton::callbacks::callback_e kind, const triton::arch::MemoryAccess& mem, const triton::uint512& value);
166
168 TRITON_EXPORT void processCallbacks(triton::callbacks::callback_e kind, const triton::arch::Register& reg);
169
171 TRITON_EXPORT void processCallbacks(triton::callbacks::callback_e kind, const triton::arch::Register& reg, const triton::uint512& value);
172
174 TRITON_EXPORT bool isDefined(triton::callbacks::callback_e kind) const;
175
177 TRITON_EXPORT bool isDefined(void) const;
178 };
179
181 };
183};
184
185#endif /* TRITON_CALLBACKS_H */
This is the main Triton Context class.
Definition context.hpp:45
This class is used to represent a memory access.
This class is used when an instruction has a register operand.
Definition register.hpp:44
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.
std::list< triton::callbacks::symbolicSimplificationCallback > symbolicSimplificationCallbacks
[c++] Callbacks for all symbolic simplifications.
TRITON_EXPORT void clearCallbacks(void)
Clears recorded callbacks.
Definition callbacks.cpp:91
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
std::list< triton::callbacks::setConcreteMemoryValueCallback > setConcreteMemoryValueCallbacks
[c++] Callbacks for all concrete memory needs (STORE).
triton::usize countCallbacks(void) const
Returns the number of callbacks recorded.
std::list< triton::callbacks::getConcreteMemoryValueCallback > getConcreteMemoryValueCallbacks
[c++] Callbacks for all concrete memory needs (LOAD).
std::list< triton::callbacks::setConcreteRegisterValueCallback > setConcreteRegisterValueCallbacks
[c++] Callbacks for all concrete register needs (PUT).
TRITON_EXPORT Callbacks(triton::Context &ctx)
Constructor.
Definition callbacks.cpp:17
TRITON_EXPORT bool isDefined(void) const
Returns true if at least one callback is defined.
void removeSingleCallback(std::list< T > &container, T cb)
Trys to find and remove the callback, raises an exception if not able.
std::list< triton::callbacks::getConcreteRegisterValueCallback > getConcreteRegisterValueCallbacks
[c++] Callbacks for all concrete register needs (GET).
TRITON_EXPORT triton::ast::SharedAbstractNode processCallbacks(triton::callbacks::callback_e kind, triton::ast::SharedAbstractNode node)
Processes callbacks according to the kind and the C++ polymorphism.
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition ast.hpp:59
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
The Triton namespace.