1
0
Fork 0

GUI: various changes with number -> string conversion

This commit is contained in:
mrexodia 2016-10-02 16:08:52 +02:00
parent 2665ba2a4d
commit 5d23c58e6f
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
16 changed files with 133 additions and 152 deletions

View File

@ -300,7 +300,7 @@ void HexDump::copyRvaSlot()
duint base = DbgFunctions()->ModBaseFromAddr(addr);
if(base)
{
QString addrText = QString("%1").arg(addr - base, 0, 16, QChar('0')).toUpper();
QString addrText = ToHexString(addr - base);
Bridge::CopyToClipboard(addrText);
}
else

View File

@ -118,9 +118,9 @@ void CPUDisassembly::addFollowReferenceMenuItem(QString name, dsint value, QMenu
newAction->setFont(QFont("Courier New", 8));
menu->addAction(newAction);
if(isFollowInCPU)
newAction->setObjectName(QString("CPU|") + QString("%1").arg(value, sizeof(dsint) * 2, 16, QChar('0')).toUpper());
newAction->setObjectName(QString("CPU|") + ToPtrString(value));
else
newAction->setObjectName(QString(isReferences ? "REF|" : "DUMP|") + QString("%1").arg(value, sizeof(dsint) * 2, 16, QChar('0')).toUpper());
newAction->setObjectName(QString(isReferences ? "REF|" : "DUMP|") + ToPtrString(value));
connect(newAction, SIGNAL(triggered()), this, SLOT(followActionSlot()));
}
@ -164,7 +164,7 @@ void CPUDisassembly::setupFollowReferenceMenu(dsint wVA, QMenu* menu, bool isRef
addFollowReferenceMenuItem(tr("&Address: ") + segment + QString(arg.mnemonic).toUpper().trimmed(), arg.value, menu, isReferences, isFollowInCPU);
if(arg.value != arg.constant)
{
QString constant = QString("%1").arg(arg.constant, 1, 16, QChar('0')).toUpper();
QString constant = ToHexString(arg.constant);
if(DbgMemIsValidReadPtr(arg.constant))
addFollowReferenceMenuItem(tr("&Constant: ") + constant, arg.constant, menu, isReferences, isFollowInCPU);
}
@ -183,7 +183,7 @@ void CPUDisassembly::setupFollowReferenceMenu(dsint wVA, QMenu* menu, bool isRef
for(int i = 0; i < instr.argcount; i++)
{
const DISASM_ARG arg = instr.arg[i];
QString constant = QString("%1").arg(arg.constant, 1, 16, QChar('0')).toUpper();
QString constant = ToHexString(arg.constant);
if(DbgMemIsValidReadPtr(arg.constant))
addFollowReferenceMenuItem(tr("Address: ") + constant, arg.constant, menu, isReferences, isFollowInCPU);
else if(arg.constant)
@ -821,7 +821,7 @@ void CPUDisassembly::setCommentSlot()
return;
duint wVA = rvaToVa(getInitialSelection());
LineEditDialog mLineEdit(this);
QString addr_text = QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(wVA);
char comment_text[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt((duint)wVA, comment_text))
{
@ -896,8 +896,8 @@ void CPUDisassembly::toggleArgumentSlot()
duint argument_end = 0;
if(!DbgArgumentOverlaps(start, end))
{
QString start_text = QString("%1").arg(start, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString end_text = QString("%1").arg(end, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString start_text = ToPtrString(start);
QString end_text = ToPtrString(end);
QString cmd = "argumentadd " + start_text + "," + end_text;
DbgCmdExec(cmd.toUtf8().constData());
@ -909,7 +909,7 @@ void CPUDisassembly::toggleArgumentSlot()
if(DbgArgumentGet(i, &argument_start, &argument_end))
break;
}
QString start_text = QString("%1").arg(argument_start, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString start_text = ToPtrString(argument_start);
QString cmd = "argumentdel " + start_text;
DbgCmdExec(cmd.toUtf8().constData());
@ -1092,7 +1092,7 @@ void CPUDisassembly::followActionSlot()
DbgCmdExec(QString().sprintf("dump \"%s\"", action->objectName().mid(5).toUtf8().constData()).toUtf8().constData());
else if(action->objectName().startsWith("REF|"))
{
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(rvaToVa(getInitialSelection()));
QString value = action->objectName().mid(4);
DbgCmdExec(QString("findref \"" + value + "\", " + addrText).toUtf8().constData());
emit displayReferencesWidget();
@ -1116,9 +1116,9 @@ void CPUDisassembly::gotoNextSlot()
void CPUDisassembly::findReferencesSlot()
{
QString addrStart = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrEnd = QString("%1").arg(rvaToVa(getSelectionEnd()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrDisasm = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrStart = ToPtrString(rvaToVa(getSelectionStart()));
QString addrEnd = ToPtrString(rvaToVa(getSelectionEnd()));
QString addrDisasm = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("findrefrange " + addrStart + ", " + addrEnd + ", " + addrDisasm).toUtf8().constData());
emit displayReferencesWidget();
}
@ -1244,7 +1244,7 @@ void CPUDisassembly::binaryEditSlot()
mMemPage->read(data, selStart, selSize);
hexEdit.mHexEdit->setData(QByteArray((const char*)data, selSize));
delete [] data;
hexEdit.setWindowTitle(tr("Edit code at %1").arg(rvaToVa(selStart), sizeof(dsint) * 2, 16, QChar('0')).toUpper());
hexEdit.setWindowTitle(tr("Edit code at %1").arg(ToPtrString(rvaToVa(selStart))));
if(hexEdit.exec() != QDialog::Accepted)
return;
dsint dataSize = hexEdit.mHexEdit->data().size();
@ -1262,7 +1262,7 @@ void CPUDisassembly::binaryFillSlot()
hexEdit.showKeepSize(false);
hexEdit.mHexEdit->setOverwriteMode(false);
dsint selStart = getSelectionStart();
hexEdit.setWindowTitle(tr("Fill code at %1").arg(rvaToVa(selStart), sizeof(dsint) * 2, 16, QChar('0')).toUpper());
hexEdit.setWindowTitle(tr("Fill code at %1").arg(ToPtrString(rvaToVa(selStart))));
if(hexEdit.exec() != QDialog::Accepted)
return;
QString pattern = hexEdit.mHexEdit->pattern();
@ -1387,7 +1387,7 @@ void CPUDisassembly::copySelectionSlot(bool copyBytes)
{
if(j)
bytes += " ";
bytes += QString("%1").arg((unsigned char)(instBuffer.at(i).dump.at(j)), 2, 16, QChar('0')).toUpper();
bytes += ToByteString((unsigned char)(instBuffer.at(i).dump.at(j)));
}
QString disassembly;
for(const auto & token : instBuffer.at(i).tokens.tokens)
@ -1416,7 +1416,7 @@ void CPUDisassembly::copySelectionNoBytesSlot()
void CPUDisassembly::copyAddressSlot()
{
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(rvaToVa(getInitialSelection()));
Bridge::CopyToClipboard(addrText);
}
@ -1426,7 +1426,7 @@ void CPUDisassembly::copyRvaSlot()
duint base = DbgFunctions()->ModBaseFromAddr(addr);
if(base)
{
QString addrText = QString("%1").arg(addr - base, 0, 16, QChar('0')).toUpper();
QString addrText = ToHexString(addr - base);
Bridge::CopyToClipboard(addrText);
}
else
@ -1492,7 +1492,7 @@ void CPUDisassembly::findCommandSlot()
return;
}
QString addr_text = QString("%1").arg(va, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(va);
dsint size = mMemPage->getSize();
DbgCmdExec(QString("findasm \"%1\", %2, .%3, %4").arg(mLineEdit.editText).arg(addr_text).arg(size).arg(refFindType).toUtf8().constData());

View File

@ -423,7 +423,7 @@ void CPUDump::setLabelSlot()
duint wVA = rvaToVa(getSelectionStart());
LineEditDialog mLineEdit(this);
QString addr_text = QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(wVA);
char label_text[MAX_COMMENT_SIZE] = "";
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
mLineEdit.setText(QString(label_text));
@ -1132,111 +1132,111 @@ void CPUDump::selectionSet(const SELECTIONDATA* selection)
void CPUDump::memoryAccessSingleshootSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 0, a").toUtf8().constData());
}
void CPUDump::memoryAccessRestoreSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 1, a").toUtf8().constData());
}
void CPUDump::memoryWriteSingleshootSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 0, w").toUtf8().constData());
}
void CPUDump::memoryWriteRestoreSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 1, w").toUtf8().constData());
}
void CPUDump::memoryExecuteSingleshootSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 0, x").toUtf8().constData());
}
void CPUDump::memoryExecuteRestoreSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 1, x").toUtf8().constData());
}
void CPUDump::memoryRemoveSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpmc " + addr_text).toUtf8().constData());
}
void CPUDump::hardwareAccess1Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 1").toUtf8().constData());
}
void CPUDump::hardwareAccess2Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 2").toUtf8().constData());
}
void CPUDump::hardwareAccess4Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 4").toUtf8().constData());
}
void CPUDump::hardwareAccess8Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 8").toUtf8().constData());
}
void CPUDump::hardwareWrite1Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 1").toUtf8().constData());
}
void CPUDump::hardwareWrite2Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 2").toUtf8().constData());
}
void CPUDump::hardwareWrite4Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 4").toUtf8().constData());
}
void CPUDump::hardwareWrite8Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 8").toUtf8().constData());
}
void CPUDump::hardwareExecuteSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", x").toUtf8().constData());
}
void CPUDump::hardwareRemoveSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphwc " + addr_text).toUtf8().constData());
}
void CPUDump::findReferencesSlot()
{
QString addrStart = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrEnd = QString("%1").arg(rvaToVa(getSelectionEnd()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrDisasm = QString("%1").arg(mDisas->rvaToVa(mDisas->getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrStart = ToPtrString(rvaToVa(getSelectionStart()));
QString addrEnd = ToPtrString(rvaToVa(getSelectionEnd()));
QString addrDisasm = ToPtrString(mDisas->rvaToVa(mDisas->getSelectionStart()));
DbgCmdExec(QString("findrefrange " + addrStart + ", " + addrEnd + ", " + addrDisasm).toUtf8().constData());
emit displayReferencesWidget();
}
@ -1268,7 +1268,7 @@ void CPUDump::binaryFillSlot()
hexEdit.showKeepSize(false);
hexEdit.mHexEdit->setOverwriteMode(false);
dsint selStart = getSelectionStart();
hexEdit.setWindowTitle(tr("Fill data at %1").arg(rvaToVa(selStart), sizeof(dsint) * 2, 16, QChar('0')).toUpper());
hexEdit.setWindowTitle(tr("Fill data at %1").arg(ToPtrString(rvaToVa(selStart))));
if(hexEdit.exec() != QDialog::Accepted)
return;
QString pattern = hexEdit.mHexEdit->pattern();
@ -1355,7 +1355,7 @@ void CPUDump::findPattern()
dsint addr = rvaToVa(getSelectionStart());
if(hexEdit.entireBlock())
addr = DbgMemFindBaseAddr(addr, 0);
QString addrText = QString("%1").arg(addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(addr);
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&").toUtf8().constData());
emit displayReferencesWidget();
}
@ -1392,8 +1392,8 @@ void CPUDump::followDataDumpSlot()
void CPUDump::selectionUpdatedSlot()
{
QString selStart = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString selEnd = QString("%1").arg(rvaToVa(getSelectionEnd()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString selStart = ToPtrString(rvaToVa(getSelectionStart()));
QString selEnd = ToPtrString(rvaToVa(getSelectionEnd()));
QString info = tr("Dump");
char mod[MAX_MODULE_SIZE] = "";
if(DbgFunctions()->ModNameFromAddr(rvaToVa(getSelectionStart()), mod, true))
@ -1406,7 +1406,7 @@ void CPUDump::yaraSlot()
YaraRuleSelectionDialog yaraDialog(this);
if(yaraDialog.exec() == QDialog::Accepted)
{
QString addrText = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("yara \"%0\",%1").arg(yaraDialog.getSelectedFile()).arg(addrText).toUtf8().constData());
emit displayReferencesWidget();
}

View File

@ -232,11 +232,11 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
// Module RVA
curRva = parVA - modbase;
if(modbase)
info += QString(":$%1 ").arg(curRva, 0, 16, QChar('0')).toUpper();
info += QString(":$%1 ").arg(ToHexString(curRva));
// File offset
curOffset = DbgFunctions()->VaToFileOffset(parVA);
info += QString("#%1 ").arg(curOffset, 0, 16, QChar('0')).toUpper();
info += QString("#%1 ").arg(ToHexString(curOffset));
}
// Function/label name
@ -321,7 +321,7 @@ void CPUInfoBox::setupFollowMenu(QMenu* menu, duint wVA)
addFollowMenuItem(menu, tr("&Address: ") + segment + QString(arg.mnemonic).toUpper().trimmed(), arg.value);
if(arg.value != arg.constant)
{
QString constant = QString("%1").arg(arg.constant, 1, 16, QChar('0')).toUpper();
QString constant = QString("%1").arg(ToHexString(arg.constant));
if(DbgMemIsValidReadPtr(arg.constant))
addFollowMenuItem(menu, tr("&Constant: ") + constant, arg.constant);
}
@ -386,7 +386,7 @@ void CPUInfoBox::setupWatchMenu(QMenu* menu, duint wVA)
addWatchMenuItem(menu, tr("&Address: ") + segment + QString(arg.mnemonic).toUpper().trimmed(), arg.value);
if(arg.value != arg.constant)
{
QString constant = QString("%1").arg(arg.constant, 1, 16, QChar('0')).toUpper();
QString constant = QString("%1").arg(ToHexString(arg.constant));
if(DbgMemIsValidReadPtr(arg.constant))
addWatchMenuItem(menu, tr("&Constant: ") + constant, arg.constant);
}

View File

@ -389,17 +389,17 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e)
{
case bp_enabled:
// breakpoint exists and is enabled --> disable breakpoint
wCmd = "bd " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
wCmd = "bd " + ToPtrString(wVA);
DbgCmdExec(wCmd.toUtf8().constData());
break;
case bp_disabled:
// is disabled --> delete
wCmd = "bc " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
wCmd = "bc " + ToPtrString(wVA);
DbgCmdExec(wCmd.toUtf8().constData());
break;
case bp_non_existent:
// no breakpoint was found --> create breakpoint
wCmd = "bp " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
wCmd = "bp " + ToPtrString(wVA);
DbgCmdExec(wCmd.toUtf8().constData());
break;
}

View File

@ -822,7 +822,7 @@ void CPUStack::followDisasmSlot()
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(duint)))
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
{
QString addrText = QString("%1").arg(selectedData, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(selectedData);
DbgCmdExec(QString("disasm " + addrText).toUtf8().constData());
}
}
@ -833,7 +833,7 @@ void CPUStack::followDumpPtrSlot()
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(duint)))
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
{
QString addrText = QString("%1").arg(selectedData, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(selectedData);
DbgCmdExec(QString("dump " + addrText).toUtf8().constData());
}
}
@ -861,7 +861,7 @@ void CPUStack::followStackSlot()
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(duint)))
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
{
QString addrText = QString("%1").arg(selectedData, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(selectedData);
DbgCmdExec(QString("sdump " + addrText).toUtf8().constData());
}
}
@ -898,7 +898,7 @@ void CPUStack::binaryFillSlot()
hexEdit.showKeepSize(false);
hexEdit.mHexEdit->setOverwriteMode(false);
dsint selStart = getSelectionStart();
hexEdit.setWindowTitle(tr("Fill data at %1").arg(rvaToVa(selStart), sizeof(dsint) * 2, 16, QChar('0')).toUpper());
hexEdit.setWindowTitle(tr("Fill data at %1").arg(ToPtrString(rvaToVa(selStart))));
if(hexEdit.exec() != QDialog::Accepted)
return;
QString pattern = hexEdit.mHexEdit->pattern();
@ -961,85 +961,85 @@ void CPUStack::binaryPasteIgnoreSizeSlot()
// Copied from "CPUDump.cpp".
void CPUStack::hardwareAccess1Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 1").toUtf8().constData());
}
void CPUStack::hardwareAccess2Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 2").toUtf8().constData());
}
void CPUStack::hardwareAccess4Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 4").toUtf8().constData());
}
void CPUStack::hardwareAccess8Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 8").toUtf8().constData());
}
void CPUStack::hardwareWrite1Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 1").toUtf8().constData());
}
void CPUStack::hardwareWrite2Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 2").toUtf8().constData());
}
void CPUStack::hardwareWrite4Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 4").toUtf8().constData());
}
void CPUStack::hardwareWrite8Slot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 8").toUtf8().constData());
}
void CPUStack::hardwareRemoveSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bphwc " + addr_text).toUtf8().constData());
}
void CPUStack::memoryAccessSingleshootSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bpm " + addr_text + ", 0, a").toUtf8().constData());
}
void CPUStack::memoryAccessRestoreSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bpm " + addr_text + ", 1, a").toUtf8().constData());
}
void CPUStack::memoryWriteSingleshootSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bpm " + addr_text + ", 0, w").toUtf8().constData());
}
void CPUStack::memoryWriteRestoreSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bpm " + addr_text + ", 1, w").toUtf8().constData());
}
void CPUStack::memoryRemoveSlot()
{
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addr_text = ToPtrString(rvaToVa(getInitialSelection()));
DbgCmdExec(QString("bpmc " + addr_text).toUtf8().constData());
}
@ -1054,7 +1054,7 @@ void CPUStack::findPattern()
dsint addr = rvaToVa(getSelectionStart());
if(hexEdit.entireBlock())
addr = DbgMemFindBaseAddr(addr, 0);
QString addrText = QString("%1").arg(addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(addr);
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&").toUtf8().constData());
emit displayReferencesWidget();
}

View File

@ -1,6 +1,7 @@
#include "GotoDialog.h"
#include "ValidateExpressionThread.h"
#include "ui_GotoDialog.h"
#include "StringUtil.h"
GotoDialog::GotoDialog(QWidget* parent, bool allowInvalidExpression, bool allowInvalidAddress)
: QDialog(parent),
@ -93,7 +94,7 @@ void GotoDialog::expressionChanged(bool validExpression, bool validPointer, dsin
{
duint offset = value;
duint va = DbgFunctions()->FileOffsetToVa(modName.toUtf8().constData(), offset);
QString addrText = QString(" %1").arg(va, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = QString(" %1").arg(ToPtrString(va));
if(va || allowInvalidAddress)
{
ui->labelError->setText(tr("<font color='#00DD00'><b>Correct expression! -&gt; </b></font>") + addrText);
@ -110,7 +111,7 @@ void GotoDialog::expressionChanged(bool validExpression, bool validPointer, dsin
else
{
duint addr = value;
QString addrText = QString(" %1").arg(addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = QString(" %1").arg(ToPtrString(addr));
if(!validPointer && !allowInvalidAddress)
{
ui->labelError->setText(tr("<font color='red'><b>Invalid memory address...</b></font>") + addrText);
@ -135,9 +136,9 @@ void GotoDialog::expressionChanged(bool validExpression, bool validPointer, dsin
addrText = QString(label);
}
else if(DbgGetModuleAt(addr, module) && !QString(label).startsWith("JMP.&"))
addrText = QString(module) + "." + QString("%1").arg(addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
addrText = QString(module) + "." + ToPtrString(addr);
else
addrText = QString("%1").arg(addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
addrText = ToPtrString(addr);
ui->labelError->setText(tr("<font color='#00DD00'><b>Correct expression! -&gt; </b></font>") + addrText);
setOkEnabled(true);
expressionText = expression;

View File

@ -965,13 +965,13 @@ void MainWindow::setLastException(unsigned int exceptionCode)
void MainWindow::findStrings()
{
DbgCmdExec(QString("strref " + QString("%1").arg(mCpuWidget->getDisasmWidget()->getSelectedVa(), sizeof(dsint) * 2, 16, QChar('0')).toUpper()).toUtf8().constData());
DbgCmdExec(QString("strref " + ToPtrString(mCpuWidget->getDisasmWidget()->getSelectedVa())).toUtf8().constData());
displayReferencesWidget();
}
void MainWindow::findModularCalls()
{
DbgCmdExec(QString("modcallfind " + QString("%1").arg(mCpuWidget->getDisasmWidget()->getSelectedVa(), sizeof(dsint) * 2, 16, QChar('0')).toUpper()).toUtf8().constData());
DbgCmdExec(QString("modcallfind " + ToPtrString(mCpuWidget->getDisasmWidget()->getSelectedVa())).toUtf8().constData());
displayReferencesWidget();
}
@ -1166,7 +1166,7 @@ void MainWindow::runSelection()
if(!DbgIsDebugging())
return;
QString command = "bp " + QString("%1").arg(mCpuWidget->getDisasmWidget()->getSelectedVa(), sizeof(dsint) * 2, 16, QChar('0')).toUpper() + ", ss";
QString command = "bp " + ToPtrString(mCpuWidget->getDisasmWidget()->getSelectedVa()) + ", ss";
if(DbgCmdExecDirect(command.toUtf8().constData()))
DbgCmdExecDirect("run");
}

View File

@ -548,7 +548,7 @@ void MemoryMapView::findPatternSlot()
duint addr = getCellContent(getInitialSelection(), 0).toULongLong(0, 16);
if(hexEdit.entireBlock())
addr = 0;
QString addrText = QString("%1").arg(addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(addr);
DbgCmdExec(QString("findmemall " + addrText + ", \"" + hexEdit.mHexEdit->pattern() + "\", &data&").toUtf8().constData());
emit showReferences();
}

View File

@ -1,6 +1,7 @@
#include "Imports.h"
#include "PageMemoryRights.h"
#include "ui_PageMemoryRights.h"
#include "StringUtil.h"
PageMemoryRights::PageMemoryRights(QWidget* parent) : QDialog(parent), ui(new Ui::PageMemoryRights)
{
@ -36,7 +37,7 @@ void PageMemoryRights::RunAddrSize(duint addrin, duint sizein, QString pagetypei
for(duint i = 0; i < nr_pages; i++)
{
actual_addr = addr + (i * PAGE_SIZE);
tableWidget->setItem(i, 0, new QTableWidgetItem(QString("%1").arg(actual_addr, sizeof(duint) * 2, 16, QChar('0')).toUpper()));
tableWidget->setItem(i, 0, new QTableWidgetItem(ToPtrString(actual_addr)));
if(DbgFunctions()->GetPageRights(actual_addr, rights))
tableWidget->setItem(i, 1, new QTableWidgetItem(QString(rights)));
}

View File

@ -188,7 +188,7 @@ void PatchDialog::groupToggle()
if(!groupStart)
return;
QString color = enabled ? "#00DD00" : "red";
QString addrText = QString("%1").arg(groupStart, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(groupStart);
QString title = "<font color='" + color + "'><b>" + QString().sprintf("%d:", group) + addrText + "</b></font>";
mGroupSelector->setGroupTitle(title);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
@ -209,7 +209,7 @@ void PatchDialog::groupPrevious()
return;
group--;
QString color = isGroupEnabled(curPatchList, group) ? "#00DD00" : "red";
QString addrText = QString("%1").arg(getGroupAddress(curPatchList, group), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(getGroupAddress(curPatchList, group));
QString title = "<font color='" + color + "'><b>" + QString().sprintf("%d:", group) + addrText + "</b></font>";
mGroupSelector->setGroupTitle(title);
mGroupSelector->setGroup(group);
@ -234,7 +234,7 @@ void PatchDialog::groupNext()
return;
group++;
QString color = isGroupEnabled(curPatchList, group) ? "#00DD00" : "red";
QString addrText = QString("%1").arg(getGroupAddress(curPatchList, group), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(getGroupAddress(curPatchList, group));
QString title = "<font color='" + color + "'><b>" + QString().sprintf("%d:", group) + addrText + "</b></font>";
mGroupSelector->setGroupTitle(title);
mGroupSelector->setGroup(group);
@ -259,7 +259,7 @@ void PatchDialog::on_listModules_itemSelectionChanged()
for(int i = 0; i < patchList.size(); i++)
{
const DBGPATCHINFO curPatch = patchList.at(i).patch;
QString addrText = QString("%1").arg(curPatch.addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(curPatch.addr);
QListWidgetItem* item = new QListWidgetItem(QString().sprintf("%d", patchList.at(i).status.group).rightJustified(4, ' ', true) + "|" + addrText + QString().sprintf(":%.2X->%.2X", curPatch.oldbyte, curPatch.newbyte), ui->listPatches);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
Qt::CheckState state = patchList.at(i).status.checked ? Qt::Checked : Qt::Unchecked;
@ -304,7 +304,7 @@ void PatchDialog::on_listPatches_itemChanged(QListWidgetItem* item) //checkbox c
}
int group = mGroupSelector->group();
QString color = isGroupEnabled(curPatchList, group) ? "#00DD00" : "red";
QString addrText = QString("%1").arg(getGroupAddress(curPatchList, group), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(getGroupAddress(curPatchList, group));
QString title = "<font color='" + color + "'><b>" + QString().sprintf("%d:", group) + addrText + "</b></font>";
mGroupSelector->setGroupTitle(title);
mGroupSelector->setPreviousEnabled(hasPreviousGroup(curPatchList, group));
@ -395,7 +395,7 @@ void PatchDialog::on_listPatches_itemSelectionChanged()
dsint groupStart = getGroupAddress(curPatchList, patch.status.group);
if(!groupStart)
return;
QString addrText = QString("%1").arg(groupStart, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(groupStart);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
DbgCmdExecDirect(QString("dump " + addrText).toUtf8().constData());
}
@ -415,7 +415,7 @@ void PatchDialog::on_btnPickGroups_clicked()
int group = mGroupSelector->group();
QString color = isGroupEnabled(curPatchList, group) ? "#00DD00" : "red";
QString addrText = QString("%1").arg(getGroupAddress(curPatchList, group), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(getGroupAddress(curPatchList, group));
QString title = "<font color='" + color + "'><b>" + QString().sprintf("%d:", group) + addrText + "</b></font>";
mGroupSelector->setGroupTitle(title);
mGroupSelector->setPreviousEnabled(hasPreviousGroup(curPatchList, group));
@ -661,7 +661,7 @@ void PatchDialog::saveAs1337(const QString & filename)
lines.push_back(">" + i.key());
bModPlaced = true;
}
QString addrText = QString("%1").arg(curPatchList.at(j).patch.addr - modbase, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
QString addrText = ToPtrString(curPatchList.at(j).patch.addr - modbase);
lines.push_back(addrText + QString().sprintf(":%.2X->%.2X", curPatchList.at(j).patch.oldbyte, curPatchList.at(j).patch.newbyte));
patches++;
}

View File

@ -38,9 +38,9 @@ void SEHChainView::updateSEHChain()
setRowCount(sehchain.total);
for(duint i = 0; i < sehchain.total; i++)
{
QString cellText = QString("%1").arg(sehchain.records[i].addr, sizeof(duint) * 2, 16, QChar('0')).toUpper();
QString cellText = ToPtrString(sehchain.records[i].addr);
setCellContent(i, 0, cellText);
cellText = QString("%1").arg(sehchain.records[i].handler, sizeof(duint) * 2, 16, QChar('0')).toUpper();
cellText = ToPtrString(sehchain.records[i].handler);
setCellContent(i, 1, cellText);
char label[MAX_LABEL_SIZE] = "";

View File

@ -234,7 +234,7 @@ void SymbolView::cbSymbolEnum(SYMBOLINFO* symbol, void* user)
StdTable* symbolList = (StdTable*)user;
dsint index = symbolList->getRowCount();
symbolList->setRowCount(index + 1);
symbolList->setCellContent(index, 0, QString("%1").arg(symbol->addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper());
symbolList->setCellContent(index, 0, ToPtrString(symbol->addr));
if(symbol->decoratedSymbol)
{
symbolList->setCellContent(index, 2, symbol->decoratedSymbol);
@ -473,11 +473,11 @@ void SymbolView::toggleBreakpoint()
if((wBpType & bp_normal) == bp_normal)
{
wCmd = "bc " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
wCmd = "bc " + ToPtrString(wVA);
}
else
{
wCmd = "bp " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
wCmd = "bp " + ToPtrString(wVA);
}
DbgCmdExec(wCmd.toUtf8().constData());

View File

@ -1,6 +1,7 @@
#include "WordEditDialog.h"
#include "ui_WordEditDialog.h"
#include "ValidateExpressionThread.h"
#include "StringUtil.h"
WordEditDialog::WordEditDialog(QWidget* parent)
: QDialog(parent),
@ -103,7 +104,7 @@ void WordEditDialog::expressionChanged(bool validExpression, bool validPointer,
saveCursorPositions();
// Byte edit line
ui->hexLineEdit->setText(QString("%1").arg(hexWord, sizeof(duint) * 2, 16, QChar('0')).toUpper());
ui->hexLineEdit->setText(ToPtrString(hexWord));
// Signed edit
ui->signedLineEdit->setText(QString::number((dsint)mWord));
// Unsigned edit
@ -126,7 +127,7 @@ void WordEditDialog::on_signedLineEdit_textEdited(const QString & arg1)
{
ui->signedLineEdit->setStyleSheet("");
ui->btnOk->setEnabled(true);
ui->expressionLineEdit->setText(QString("%1").arg((duint)value, sizeof(duint) * 2, 16, QChar('0')).toUpper());
ui->expressionLineEdit->setText(ToPtrString((duint)value));
}
else
{
@ -142,7 +143,7 @@ void WordEditDialog::on_unsignedLineEdit_textEdited(const QString & arg1)
{
ui->unsignedLineEdit->setStyleSheet("");
ui->btnOk->setEnabled(true);
ui->expressionLineEdit->setText(QString("%1").arg((duint)value, sizeof(duint) * 2, 16, QChar('0')).toUpper());
ui->expressionLineEdit->setText(ToPtrString((duint)value));
}
else
{

View File

@ -21,19 +21,19 @@ void Breakpoints::setBP(BPXTYPE type, duint va)
{
case bp_normal:
{
wCmd = "bp " + QString("%1").arg(va, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
wCmd = "bp " + ToPtrString(va);
}
break;
case bp_hardware:
{
wCmd = "bph " + QString("%1").arg(va, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
wCmd = "bph " + ToPtrString(va);
}
break;
case bp_memory:
{
wCmd = "bpm " + QString("%1").arg(va, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
wCmd = "bpm " + ToPtrString(va);
}
break;

View File

@ -8,9 +8,7 @@
#include <QLocale>
#include "Imports.h"
const QChar HexAlphabet[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
static QString ToPtrString(duint Address)
inline QString ToPtrString(duint Address)
{
//
// This function exists because of how QT handles
@ -20,57 +18,23 @@ static QString ToPtrString(duint Address)
// ((int32)0xFFFF0000) == 0xFFFFFFFFFFFF0000 with sign extension
//
duint mask = 0xF;
char temp[32];
#ifdef _WIN64
QChar temp[16];
for(int i = 0; i < 16; i += 2)
{
temp[15 - i] = HexAlphabet[(Address & mask) >> (i << 2)];
mask <<= 4;
temp[14 - i] = HexAlphabet[(Address & mask) >> ((i << 2) + 4)];
#else //x86
QChar temp[8];
for(int i = 0; i < 8; i++)
{
temp[7 - i] = HexAlphabet[(Address & mask) >> (i << 2)];
mask <<= 4;
temp[6 - i] = HexAlphabet[(Address & mask) >> ((i << 2) + 4)];
#endif //_WIN64
mask <<= 4;
}
#ifdef _WIN64
return QString(temp, 16);
#else //x86
return QString(temp, 8);
#endif //_WIN64
sprintf_s(temp, "%016llX", Address);
#else
sprintf_s(temp, "%08X", Address);
#endif // _WIN64
return QString(temp);
}
static QString ToLongLongHexString(unsigned long long Value)
inline QString ToLongLongHexString(unsigned long long Value)
{
char temp[32];
sprintf_s(temp, "%llX", Value);
return QString(temp);
}
static QString ToByteString(unsigned char Value)
{
QChar temp[2];
temp[1] = HexAlphabet[Value & 0xF];
temp[0] = HexAlphabet[(Value & 0xF0) >> 4];
return QString(temp, 2);
}
static QString ToWordString(unsigned short Value)
{
QChar temp[4];
temp[3] = HexAlphabet[Value & 0xF];
temp[2] = HexAlphabet[(Value & 0xF0) >> 4];
temp[1] = HexAlphabet[(Value & 0xF00) >> 8];
temp[0] = HexAlphabet[(Value & 0xF000) >> 12];
return QString(temp, 4);
}
static QString ToHexString(duint Value)
inline QString ToHexString(duint Value)
{
char temp[32];
#ifdef _WIN64
@ -81,7 +45,7 @@ static QString ToHexString(duint Value)
return QString(temp);
}
static QString ToDecString(dsint Value)
inline QString ToDecString(dsint Value)
{
char temp[32];
#ifdef _WIN64
@ -92,8 +56,22 @@ static QString ToDecString(dsint Value)
return QString(temp);
}
inline QString ToByteString(unsigned char Value)
{
char temp[4];
sprintf_s(temp, "%02X", Value);
return QString(temp);
}
inline QString ToWordString(unsigned short Value)
{
char temp[4];
sprintf_s(temp, "%04X", Value);
return QString(temp);
}
template<typename T>
static QString ToFloatingString(void* buffer)
inline QString ToFloatingString(void* buffer)
{
auto value = *(T*)buffer;
std::stringstream wFloatingStr;
@ -102,18 +80,18 @@ static QString ToFloatingString(void* buffer)
}
template<typename T>
static QString ToIntegralString(void* buffer)
inline QString ToIntegralString(void* buffer)
{
auto value = *(T*)buffer;
return ToLongLongHexString(value);
}
static QString ToFloatString(void* buffer)
inline QString ToFloatString(void* buffer)
{
return ToFloatingString<float>(buffer);
}
static QString ToDoubleString(void* buffer)
inline QString ToDoubleString(void* buffer)
{
return ToFloatingString<double>(buffer);
}
@ -124,13 +102,13 @@ QString ToDateString(const QDate & date);
QString GetDataTypeString(void* buffer, duint size, ENCODETYPE type);
static QDate GetCompileDate()
inline QDate GetCompileDate()
{
return QLocale("en_US").toDate(QString(__DATE__).simplified(), "MMM d yyyy");
}
template<typename T>
static T & ArchValue(T & x32value, T & x64value)
inline T & ArchValue(T & x32value, T & x64value)
{
#ifdef _WIN64
Q_UNUSED(x32value);
@ -142,7 +120,7 @@ static T & ArchValue(T & x32value, T & x64value)
}
// Format : d:hh:mm:ss.1234567
static QString FILETIMEToTime(const FILETIME & time)
inline QString FILETIMEToTime(const FILETIME & time)
{
// FILETIME is in 100ns
quint64 time100ns = (quint64)time.dwHighDateTime << 32 | (quint64)time.dwLowDateTime;