-
Notifications
You must be signed in to change notification settings - Fork 9
/
bpt_memory_events.cpp
65 lines (52 loc) · 1.53 KB
/
bpt_memory_events.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "bpt_events.hpp"
#include "bpt_bytes_io.hpp"
#include "bpt_visitor.hpp"
namespace bpt {
struct memory_event::impl {
impl(ADDRINT a, UINT32 size)
: addr(a)
, bytes(size) {
PIN_SafeCopy(static_cast<VOID*>(&bytes[0]),
reinterpret_cast<VOID*>(addr), size);
}
ADDRINT addr;
bytes_type bytes;
};
memory_event::memory_event(ADDRINT addr, UINT32 size)
: pimpl(new impl(addr, size)) {}
ADDRINT memory_event::addr() const {
return pimpl->addr;
}
const bytes_type& memory_event::bytes() const {
return pimpl->bytes;
}
load_event::load_event(ADDRINT addr, UINT32 size) : memory_event(addr, size) {}
void load_event::do_accept(visitor& out) const {
out.visit(*this);
}
store_event::store_event(ADDRINT addr, UINT32 size) : memory_event(addr, size) {}
void store_event::do_accept(visitor& out) const {
out.visit(*this);
}
std::ostream& pp(std::ostream& out, const memory_event& e,
const std::string& d) {
using namespace io::data;
return out << "0x"
<< std::hex
<< std::uppercase
<< e.addr()
<< std::dec
<< ':'
<< sizeof(ADDRINT)*8
<< d
<< e.bytes()
<< ':'
<< e.bytes().size()*8;
}
std::ostream& load_event::operator<<(std::ostream& out) const {
return pp(out, *this, " => ");
}
std::ostream& store_event::operator<<(std::ostream& out) const {
return pp(out, *this, " <= ");
}
} //namespace bpt