small performance improvements (#1133)
* fix issue 1127 * fix issue 1127 * convert to hex faster * restored * restored
This commit is contained in:
parent
ae59629583
commit
ad26f81dce
|
|
@ -440,7 +440,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
|
|||
if(i)
|
||||
richBytes.push_back(space);
|
||||
auto byte = (unsigned char)dump.at(i);
|
||||
curByte.text = QString("%1").arg(byte, 2, 16, QChar('0')).toUpper();
|
||||
curByte.text = ToByteString(byte);
|
||||
DBGPATCHINFO patchInfo;
|
||||
if(DbgFunctions()->PatchGetEx(cur_addr + i, &patchInfo))
|
||||
curByte.textColor = byte == patchInfo.newbyte ? mModifiedBytesColor : mRestoredBytesColor;
|
||||
|
|
@ -877,7 +877,7 @@ void Disassembly::keyPressEvent(QKeyEvent* event)
|
|||
duint dest = DbgGetBranchDestination(rvaToVa(getInitialSelection()));
|
||||
if(!dest)
|
||||
return;
|
||||
QString cmd = "disasm " + QString("%1").arg(dest, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
QString cmd = "disasm " + ToPtrString(dest);
|
||||
DbgCmdExec(cmd.toUtf8().constData());
|
||||
}
|
||||
else
|
||||
|
|
@ -1928,7 +1928,7 @@ QString Disassembly::getAddrText(dsint cur_addr, char label[MAX_LABEL_SIZE])
|
|||
*label_ = 0;
|
||||
if(label)
|
||||
strcpy_s(label, MAX_LABEL_SIZE, label_);
|
||||
return addrText;
|
||||
return std::move(addrText);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ void HexDump::setupCopyMenu()
|
|||
|
||||
void HexDump::copyAddressSlot()
|
||||
{
|
||||
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
QString addrText = ToPtrString(rvaToVa(getInitialSelection()));
|
||||
Bridge::CopyToClipboard(addrText);
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ void HexDump::mousePressEvent(QMouseEvent* event)
|
|||
if(!DbgIsDebugging())
|
||||
return;
|
||||
MessageBeep(MB_OK);
|
||||
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
QString addrText = ToPtrString(rvaToVa(getInitialSelection()));
|
||||
Bridge::CopyToClipboard(addrText);
|
||||
return;
|
||||
}
|
||||
|
|
@ -697,7 +697,7 @@ QString HexDump::byteToString(byte_t byte, ByteViewMode_e mode)
|
|||
{
|
||||
case HexByte:
|
||||
{
|
||||
wStr = QString("%1").arg((unsigned char)byte, 2, 16, QChar('0')).toUpper();
|
||||
wStr = ToByteString((unsigned char)byte);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -742,7 +742,7 @@ QString HexDump::wordToString(uint16 word, WordViewMode_e mode)
|
|||
{
|
||||
case HexWord:
|
||||
{
|
||||
wStr = QString("%1").arg((unsigned short)word, 4, 16, QChar('0')).toUpper();
|
||||
wStr = ToWordString((unsigned short)word);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -268,15 +268,15 @@ void ReferenceView::setBreakpointAt(int row, BPSetAction action)
|
|||
if((wBpType & bp_normal) == bp_normal)
|
||||
{
|
||||
if(action == Toggle || action == Remove)
|
||||
wCmd = "bc " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bc " + ToPtrString(wVA);
|
||||
else if(action == Disable)
|
||||
wCmd = "bpd " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bpd " + ToPtrString(wVA);
|
||||
else if(action == Enable)
|
||||
wCmd = "bpe " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bpe " + ToPtrString(wVA);
|
||||
}
|
||||
else if(wBpType == bp_none && (action == Toggle || action == Enable))
|
||||
{
|
||||
wCmd = "bp " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bp " + ToPtrString(wVA);
|
||||
}
|
||||
|
||||
DbgCmdExecDirect(wCmd.toUtf8().constData());
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ void BreakpointsView::reloadData()
|
|||
mHardBPTable->setRowCount(wBPList.count);
|
||||
for(wI = 0; wI < wBPList.count; wI++)
|
||||
{
|
||||
QString addr_text = QString("%1").arg(wBPList.bp[wI].addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
QString addr_text = ToPtrString(wBPList.bp[wI].addr);
|
||||
mHardBPTable->setCellContent(wI, 0, addr_text);
|
||||
mHardBPTable->setCellContent(wI, 1, QString(wBPList.bp[wI].name));
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ void BreakpointsView::reloadData()
|
|||
mSoftBPTable->setRowCount(wBPList.count);
|
||||
for(wI = 0; wI < wBPList.count; wI++)
|
||||
{
|
||||
QString addr_text = QString("%1").arg(wBPList.bp[wI].addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
QString addr_text = ToPtrString(wBPList.bp[wI].addr);
|
||||
mSoftBPTable->setCellContent(wI, 0, addr_text);
|
||||
mSoftBPTable->setCellContent(wI, 1, QString(wBPList.bp[wI].name));
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ void BreakpointsView::reloadData()
|
|||
mMemBPTable->setRowCount(wBPList.count);
|
||||
for(wI = 0; wI < wBPList.count; wI++)
|
||||
{
|
||||
QString addr_text = QString("%1").arg(wBPList.bp[wI].addr, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
QString addr_text = ToPtrString(wBPList.bp[wI].addr);
|
||||
mMemBPTable->setCellContent(wI, 0, addr_text);
|
||||
mMemBPTable->setCellContent(wI, 1, QString(wBPList.bp[wI].name));
|
||||
|
||||
|
|
|
|||
|
|
@ -649,7 +649,7 @@ void CPUDisassembly::toggleInt3BPActionSlot()
|
|||
|
||||
if((wBpType & bp_normal) == bp_normal)
|
||||
{
|
||||
wCmd = "bc " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bc " + ToPtrString(wVA);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -663,7 +663,7 @@ void CPUDisassembly::toggleInt3BPActionSlot()
|
|||
if(msgyn.exec() == QMessageBox::No)
|
||||
return;
|
||||
}
|
||||
wCmd = "bp " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bp " + ToPtrString(wVA);
|
||||
}
|
||||
|
||||
DbgCmdExec(wCmd.toUtf8().constData());
|
||||
|
|
@ -679,11 +679,11 @@ void CPUDisassembly::toggleHwBpActionSlot()
|
|||
|
||||
if((wBpType & bp_hardware) == bp_hardware)
|
||||
{
|
||||
wCmd = "bphwc " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bphwc " + ToPtrString(wVA);
|
||||
}
|
||||
else
|
||||
{
|
||||
wCmd = "bphws " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bphws " + ToPtrString(wVA);
|
||||
}
|
||||
|
||||
DbgCmdExec(wCmd.toUtf8().constData());
|
||||
|
|
@ -731,17 +731,17 @@ void CPUDisassembly::setHwBpAt(duint va, int slot)
|
|||
|
||||
if(wSlotIndex < 0) // Slot not used
|
||||
{
|
||||
wCmd = "bphws " + QString("%1").arg(va, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bphws " + ToPtrString(va);
|
||||
DbgCmdExec(wCmd.toUtf8().constData());
|
||||
}
|
||||
else // Slot used
|
||||
{
|
||||
wCmd = "bphwc " + QString("%1").arg((duint)(wBPList.bp[wSlotIndex].addr), sizeof(duint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bphwc " + ToPtrString((duint)(wBPList.bp[wSlotIndex].addr));
|
||||
DbgCmdExec(wCmd.toUtf8().constData());
|
||||
|
||||
Sleep(200);
|
||||
|
||||
wCmd = "bphws " + QString("%1").arg(va, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
wCmd = "bphws " + ToPtrString(va);
|
||||
DbgCmdExec(wCmd.toUtf8().constData());
|
||||
}
|
||||
if(wBPList.count)
|
||||
|
|
@ -763,7 +763,7 @@ void CPUDisassembly::setNewOriginHereActionSlot()
|
|||
if(msg.exec() == QMessageBox::No)
|
||||
return;
|
||||
}
|
||||
QString wCmd = "cip=" + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
QString wCmd = "cip=" + ToPtrString(wVA);
|
||||
DbgCmdExec(wCmd.toUtf8().constData());
|
||||
}
|
||||
|
||||
|
|
@ -773,7 +773,7 @@ void CPUDisassembly::setLabelSlot()
|
|||
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 label_text[MAX_COMMENT_SIZE] = "";
|
||||
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
|
||||
mLineEdit.setText(QString(label_text));
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
#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)
|
||||
{
|
||||
//
|
||||
|
|
@ -18,13 +20,29 @@ static QString ToPtrString(duint Address)
|
|||
// ((int32)0xFFFF0000) == 0xFFFFFFFFFFFF0000 with sign extension
|
||||
//
|
||||
|
||||
char temp[32];
|
||||
duint mask = 0xF;
|
||||
#ifdef _WIN64
|
||||
sprintf_s(temp, "%016llX", Address);
|
||||
#else
|
||||
sprintf_s(temp, "%08X", Address);
|
||||
#endif // _WIN64
|
||||
return QString(temp);
|
||||
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
|
||||
}
|
||||
|
||||
static QString ToLongLongHexString(unsigned long long Value)
|
||||
|
|
@ -34,6 +52,24 @@ static QString ToLongLongHexString(unsigned long long 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)
|
||||
{
|
||||
char temp[32];
|
||||
|
|
|
|||
Loading…
Reference in New Issue