mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Limit Hexdump Scrolling from 0 to RVA_MAX
This commit is contained in:
parent
d3b8bcb62a
commit
1c58e2706c
14
src/Cutter.h
14
src/Cutter.h
@ -29,8 +29,20 @@
|
|||||||
|
|
||||||
#define Core() (CutterCore::getInstance())
|
#define Core() (CutterCore::getInstance())
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Type to be used for all kinds of addresses/offsets in r2 address space.
|
||||||
|
*/
|
||||||
typedef ut64 RVA;
|
typedef ut64 RVA;
|
||||||
#define RVA_INVALID UT64_MAX
|
|
||||||
|
/*!
|
||||||
|
* \brief Maximum value of RVA. Do NOT use this for specifying invalid values, use RVA_INVALID instead.
|
||||||
|
*/
|
||||||
|
#define RVA_MAX UT64_MAX
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Value for specifying an invalid RVA.
|
||||||
|
*/
|
||||||
|
#define RVA_INVALID RVA_MAX
|
||||||
|
|
||||||
class RCoreLocked
|
class RCoreLocked
|
||||||
{
|
{
|
||||||
|
@ -796,9 +796,10 @@ void HexdumpWidget::removeBottomLinesWithoutScroll(QTextEdit *textEdit, int line
|
|||||||
QTextCursor textCursor = textEdit->textCursor();
|
QTextCursor textCursor = textEdit->textCursor();
|
||||||
for (int i = 0; i < lines; i++) {
|
for (int i = 0; i < lines; i++) {
|
||||||
QTextCursor cursor(block);
|
QTextCursor cursor(block);
|
||||||
cursor.select(QTextCursor::BlockUnderCursor);
|
|
||||||
cursor.removeSelectedText();
|
|
||||||
block = block.previous();
|
block = block.previous();
|
||||||
|
//cursor.select(QTextCursor::BlockUnderCursor);
|
||||||
|
cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
|
||||||
|
cursor.removeSelectedText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,29 +838,46 @@ void HexdumpWidget::scrollChanged()
|
|||||||
|
|
||||||
int firstLine = getDisplayedLined(ui->hexHexText);
|
int firstLine = getDisplayedLined(ui->hexHexText);
|
||||||
if (firstLine < (bufferLines / 2)) {
|
if (firstLine < (bufferLines / 2)) {
|
||||||
first_loaded_address -= bufferLines * cols;
|
int loadLines = bufferLines;
|
||||||
auto hexdump = fetchHexdump(first_loaded_address, bufferLines);
|
RVA shift = static_cast<RVA>(loadLines * cols);
|
||||||
prependWithoutScroll(ui->hexOffsetText, hexdump[0]);
|
if (shift > first_loaded_address) {
|
||||||
prependWithoutScroll(ui->hexHexText, hexdump[1]);
|
loadLines = static_cast<int>(first_loaded_address / cols);
|
||||||
prependWithoutScroll(ui->hexASCIIText, hexdump[2]);
|
shift = first_loaded_address;
|
||||||
|
}
|
||||||
|
first_loaded_address -= shift;
|
||||||
|
last_loaded_address -= shift;
|
||||||
|
|
||||||
removeBottomLinesWithoutScroll(ui->hexOffsetText, bufferLines);
|
if (loadLines > 0) {
|
||||||
removeBottomLinesWithoutScroll(ui->hexHexText, bufferLines);
|
auto hexdump = fetchHexdump(first_loaded_address, loadLines);
|
||||||
removeBottomLinesWithoutScroll(ui->hexASCIIText, bufferLines);
|
prependWithoutScroll(ui->hexOffsetText, hexdump[0]);
|
||||||
|
prependWithoutScroll(ui->hexHexText, hexdump[1]);
|
||||||
|
prependWithoutScroll(ui->hexASCIIText, hexdump[2]);
|
||||||
|
|
||||||
ui->hexOffsetText->verticalScrollBar()->setValue(ui->hexHexText->verticalScrollBar()->value());
|
removeBottomLinesWithoutScroll(ui->hexOffsetText, loadLines);
|
||||||
ui->hexASCIIText->verticalScrollBar()->setValue(ui->hexHexText->verticalScrollBar()->value());
|
removeBottomLinesWithoutScroll(ui->hexHexText, loadLines);
|
||||||
|
removeBottomLinesWithoutScroll(ui->hexASCIIText, loadLines);
|
||||||
|
|
||||||
|
ui->hexOffsetText->verticalScrollBar()->setValue(ui->hexHexText->verticalScrollBar()->value());
|
||||||
|
ui->hexASCIIText->verticalScrollBar()->setValue(ui->hexHexText->verticalScrollBar()->value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int blocks = ui->hexHexText->document()->blockCount();
|
int blocks = ui->hexHexText->document()->blockCount();
|
||||||
int lastLine = getDisplayedLined(ui->hexHexText, true);
|
int lastLine = getDisplayedLined(ui->hexHexText, true);
|
||||||
if (blocks - lastLine < (bufferLines / 2)) {
|
if (blocks - lastLine < (bufferLines / 2)) {
|
||||||
auto hexdump = fetchHexdump(last_loaded_address, bufferLines);
|
int loadLines = bufferLines;
|
||||||
last_loaded_address += bufferLines * cols;
|
RVA shift = static_cast<RVA>(loadLines * cols);
|
||||||
removeTopLinesWithoutScroll(ui->hexOffsetText, bufferLines);
|
if (last_loaded_address > RVA_MAX - shift) {
|
||||||
removeTopLinesWithoutScroll(ui->hexHexText, bufferLines);
|
shift = RVA_MAX - last_loaded_address;
|
||||||
removeTopLinesWithoutScroll(ui->hexASCIIText, bufferLines);
|
loadLines = static_cast<int>(shift / cols);
|
||||||
|
}
|
||||||
|
auto hexdump = fetchHexdump(last_loaded_address, loadLines);
|
||||||
|
last_loaded_address += shift;
|
||||||
|
first_loaded_address += shift;
|
||||||
|
|
||||||
|
removeTopLinesWithoutScroll(ui->hexOffsetText, loadLines);
|
||||||
|
removeTopLinesWithoutScroll(ui->hexHexText, loadLines);
|
||||||
|
removeTopLinesWithoutScroll(ui->hexASCIIText, loadLines);
|
||||||
appendWithoutScroll(ui->hexOffsetText, hexdump[0]);
|
appendWithoutScroll(ui->hexOffsetText, hexdump[0]);
|
||||||
appendWithoutScroll(ui->hexHexText, hexdump[1]);
|
appendWithoutScroll(ui->hexHexText, hexdump[1]);
|
||||||
appendWithoutScroll(ui->hexASCIIText, hexdump[2]);
|
appendWithoutScroll(ui->hexASCIIText, hexdump[2]);
|
||||||
|
Loading…
Reference in New Issue
Block a user