-
-
Notifications
You must be signed in to change notification settings - Fork 342
Expand file tree
/
Copy pathRegionBuffer.cpp
More file actions
72 lines (58 loc) · 1.23 KB
/
Copy pathRegionBuffer.cpp
File metadata and controls
72 lines (58 loc) · 1.23 KB
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
66
67
68
69
70
71
72
/*
* Copyright (C) 2006 - 2025 Evan Teran <evan.teran@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "RegionBuffer.h"
#include "IDebugger.h"
#include "IProcess.h"
#include "edb.h"
/**
* @brief
*/
RegionBuffer::RegionBuffer(std::shared_ptr<IRegion> region)
: region_(std::move(region)) {
setOpenMode(QIODevice::ReadOnly);
}
/**
* @brief
*/
RegionBuffer::RegionBuffer(std::shared_ptr<IRegion> region, QObject *parent)
: QIODevice(parent), region_(std::move(region)) {
setOpenMode(QIODevice::ReadOnly);
}
/**
* @brief
*/
void RegionBuffer::setRegion(std::shared_ptr<IRegion> region) {
region_ = std::move(region);
reset();
}
/**
* @brief
*/
qint64 RegionBuffer::readData(char *data, qint64 maxSize) {
if (region_) {
if (IProcess *process = edb::v1::debugger_core->process()) {
const edb::address_t start = region_->start() + pos();
const edb::address_t end = region_->start() + region_->size();
if (start + maxSize > end) {
maxSize = end - start;
}
if (maxSize == 0) {
return 0;
}
if (process->readBytes(start, data, maxSize)) {
return maxSize;
}
return -1;
}
}
return -1;
}
/**
* @brief
*/
qint64 RegionBuffer::writeData(const char *, qint64) {
return -1;
}