Some hexdump fixes

This commit is contained in:
xarkes 2018-01-27 14:11:30 +01:00
parent 2703ec274d
commit 372021dadc
2 changed files with 17 additions and 7 deletions

View File

@ -144,6 +144,12 @@ QString CutterCore::sanitizeStringForCommand(QString s)
return s.replace(regexp, "_"); return s.replace(regexp, "_");
} }
/**
* @brief CutterCore::cmd send a command to radare2
* @param str the command you want to execute
* Note that if you want to seek to an address, you should use CutterCore::seek
* @return command output
*/
QString CutterCore::cmd(const QString &str) QString CutterCore::cmd(const QString &str)
{ {
CORE_LOCK(); CORE_LOCK();
@ -341,19 +347,23 @@ void CutterCore::setImmediateBase(const QString &r2BaseName, RVA offset)
emit instructionChanged(offset); emit instructionChanged(offset);
} }
void CutterCore::seek(QString addr) void CutterCore::seek(ut64 offset)
{ {
// Slower than using the API, but the API is not complete // Slower than using the API, but the API is not complete
// which means we either have to duplicate code from radare2 // which means we either have to duplicate code from radare2
// here, or refactor radare2 API. // here, or refactor radare2 API.
CORE_LOCK(); CORE_LOCK();
cmd(QString("s %1").arg(addr)); if (offset == RVA_INVALID)
{
return;
}
cmd(QString("s %1").arg(offset));
// cmd already does emit seekChanged(core_->offset); // cmd already does emit seekChanged(core_->offset);
} }
void CutterCore::seek(ut64 offset) void CutterCore::seek(QString offset)
{ {
seek(QString::number(offset)); seek(offset.toULongLong());
} }
void CutterCore::seekPrev() void CutterCore::seekPrev()

View File

@ -296,8 +296,8 @@ void HexdumpWidget::refresh(RVA addr)
// TODO: Figure out how to calculate a sane value for this // TODO: Figure out how to calculate a sane value for this
bufferLines = qhelpers::getMaxFullyDisplayedLines(ui->hexHexText); bufferLines = qhelpers::getMaxFullyDisplayedLines(ui->hexHexText);
//RVA cur_addr = addr - (bufferLines * cols);
RVA cur_addr = addr - (bufferLines * cols); RVA cur_addr = addr;
first_loaded_address = cur_addr; first_loaded_address = cur_addr;
last_loaded_address = cur_addr + (3 * bufferLines) * cols; last_loaded_address = cur_addr + (3 * bufferLines) * cols;
QElapsedTimer getHexdumpTimer; QElapsedTimer getHexdumpTimer;
@ -679,7 +679,7 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size)
QString address = RAddressString(start_address); QString address = RAddressString(start_address);
QString argument = QString("%1 " + address).arg(size); QString argument = QString("%1@" + address).arg(size);
// Get selected combos // Get selected combos
QString arch = ui->parseArchComboBox->currentText(); QString arch = ui->parseArchComboBox->currentText();
QString bits = ui->parseBitsComboBox->currentText(); QString bits = ui->parseBitsComboBox->currentText();