GUI: show weird selections in the GUI
This commit is contained in:
parent
ebf3db1095
commit
f70d780219
|
|
@ -453,7 +453,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
|
|||
int jumpsize = paintJumpsGraphic(painter, x + funcsize, y - 1, wRVA, branchType != Instruction_t::None && branchType != Instruction_t::Call); //jump line
|
||||
|
||||
//draw bytes
|
||||
auto richBytes = getRichBytes(instr);
|
||||
auto richBytes = getRichBytes(instr, wIsSelected);
|
||||
RichTextPainter::paintRichText(painter, x, y, getColumnWidth(col), getRowHeight(), jumpsize + funcsize, richBytes, mFontMetrics);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1615,7 +1615,7 @@ void Disassembly::prepareDataRange(dsint startRva, dsint endRva, const std::func
|
|||
}
|
||||
}
|
||||
|
||||
RichTextPainter::List Disassembly::getRichBytes(const Instruction_t & instr) const
|
||||
RichTextPainter::List Disassembly::getRichBytes(const Instruction_t & instr, bool isSelected) const
|
||||
{
|
||||
RichTextPainter::List richBytes;
|
||||
std::vector<std::pair<size_t, bool>> realBytes;
|
||||
|
|
@ -1625,16 +1625,19 @@ RichTextPainter::List Disassembly::getRichBytes(const Instruction_t & instr) con
|
|||
if(!richBytes.empty() && richBytes.back().text.endsWith(' '))
|
||||
richBytes.back().text.chop(1); //remove trailing space if exists
|
||||
|
||||
auto selectionFromVa = rvaToVa(mSelection.fromIndex);
|
||||
auto selectionToVa = rvaToVa(mSelection.toIndex);
|
||||
for(size_t i = 0; i < richBytes.size(); i++)
|
||||
{
|
||||
auto byteIdx = realBytes[i].first;
|
||||
auto byteAddr = cur_addr + byteIdx;
|
||||
auto isReal = realBytes[i].second;
|
||||
RichTextPainter::CustomRichText_t & curByte = richBytes.at(i);
|
||||
DBGRELOCATIONINFO relocInfo;
|
||||
curByte.highlightColor = mDisassemblyRelocationUnderlineColor;
|
||||
if(DbgFunctions()->ModRelocationAtAddr(cur_addr + byteIdx, &relocInfo))
|
||||
if(DbgFunctions()->ModRelocationAtAddr(byteAddr, &relocInfo))
|
||||
{
|
||||
bool prevInSameReloc = relocInfo.rva < cur_addr + byteIdx - DbgFunctions()->ModBaseFromAddr(cur_addr + byteIdx);
|
||||
bool prevInSameReloc = relocInfo.rva < byteAddr - DbgFunctions()->ModBaseFromAddr(byteAddr);
|
||||
curByte.highlight = isReal;
|
||||
curByte.highlightConnectPrev = i > 0 && prevInSameReloc;
|
||||
}
|
||||
|
|
@ -1645,7 +1648,7 @@ RichTextPainter::List Disassembly::getRichBytes(const Instruction_t & instr) con
|
|||
}
|
||||
|
||||
DBGPATCHINFO patchInfo;
|
||||
if(isReal && DbgFunctions()->PatchGetEx(cur_addr + byteIdx, &patchInfo))
|
||||
if(isReal && DbgFunctions()->PatchGetEx(byteAddr, &patchInfo))
|
||||
{
|
||||
if((unsigned char)(instr.dump.at(byteIdx)) == patchInfo.newbyte)
|
||||
{
|
||||
|
|
@ -1663,6 +1666,15 @@ RichTextPainter::List Disassembly::getRichBytes(const Instruction_t & instr) con
|
|||
curByte.textColor = mBytesColor;
|
||||
curByte.textBackground = mBytesBackgroundColor;
|
||||
}
|
||||
|
||||
if(curByte.textBackground.alpha() == 0)
|
||||
{
|
||||
auto byteSelected = byteAddr >= selectionFromVa && byteAddr <= selectionToVa;
|
||||
if(isSelected && !byteSelected)
|
||||
curByte.textBackground = mBackgroundColor;
|
||||
else if(!isSelected && byteSelected)
|
||||
curByte.textBackground = mSelectionColor;
|
||||
}
|
||||
}
|
||||
|
||||
if(mCodeFoldingManager && mCodeFoldingManager->isFolded(cur_addr))
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public:
|
|||
QString getAddrText(dsint cur_addr, char label[MAX_LABEL_SIZE], bool getLabel = true);
|
||||
void prepareDataCount(const QList<dsint> & wRVAs, QList<Instruction_t>* instBuffer);
|
||||
void prepareDataRange(dsint startRva, dsint endRva, const std::function<bool(int, const Instruction_t &)> & disassembled);
|
||||
RichTextPainter::List getRichBytes(const Instruction_t & instr) const;
|
||||
RichTextPainter::List getRichBytes(const Instruction_t & instr, bool isSelected) const;
|
||||
|
||||
//misc
|
||||
void setCodeFoldingManager(CodeFoldingHelper* CodeFoldingManager);
|
||||
|
|
|
|||
|
|
@ -1478,7 +1478,7 @@ void CPUDisassembly::pushSelectionInto(bool copyBytes, QTextStream & stream, QTe
|
|||
QString bytes;
|
||||
QString bytesHtml;
|
||||
if(copyBytes)
|
||||
RichTextPainter::htmlRichText(getRichBytes(inst), bytesHtml, bytes);
|
||||
RichTextPainter::htmlRichText(getRichBytes(inst, false), bytesHtml, bytes);
|
||||
QString disassembly;
|
||||
QString htmlDisassembly;
|
||||
if(htmlStream)
|
||||
|
|
|
|||
Loading…
Reference in New Issue