1
0
Fork 0

Added patches and relocations

This commit is contained in:
torusrxxx 2017-12-29 16:59:01 +08:00 committed by Duncan Ogilvie
parent 6c472a34e4
commit 606d3cec2e
4 changed files with 40 additions and 19 deletions

View File

@ -459,14 +459,29 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
space.flags = RichTextPainter::FlagNone;
space.text = " ";
RichTextPainter::CustomRichText_t curByte;
curByte.textColor = mBytesColor;
curByte.textBackground = mBytesBackgroundColor;
curByte.highlightColor = ConfigColor("DisassemblyRelocationUnderlineColor");
curByte.highlightWidth = 1;
curByte.flags = RichTextPainter::FlagAll;
curByte.text = formatOpcodeString(mInstBuffer.at(rowOffset));
curByte.textColor = mBytesColor;
curByte.textBackground = mBytesBackgroundColor;
curByte.highlight = false;
richBytes.push_back(curByte);
formatOpcodeString(mInstBuffer.at(rowOffset), richBytes);
for(int i = 0; i < richBytes.size(); i++)
{
RichTextPainter::CustomRichText_t & curByte1 = richBytes.at(i);
if(!DbgFunctions()->PatchGet(cur_addr + i))
{
curByte1.textColor = mBytesColor;
curByte1.textBackground = mBytesBackgroundColor;
}
else
{
curByte1.textColor = mModifiedBytesColor;
curByte1.textBackground = mModifiedBytesBackgroundColor;
}
curByte1.highlight = DbgFunctions()->ModRelocationAtAddr(cur_addr + i, nullptr);
}
if(mCodeFoldingManager && mCodeFoldingManager->isFolded(cur_addr))
{
curByte.textColor = mBytesColor;

View File

@ -329,27 +329,31 @@ void QBeaEngine::UpdateConfig()
_tokenizer.UpdateConfig();
}
QString formatOpcodeString(const Instruction_t & inst)
void formatOpcodeString(const Instruction_t & inst, RichTextPainter::List & list)
{
QString output;
unsigned char offset = 0;
output = QString(inst.dump.toHex()).toUpper();
RichTextPainter::CustomRichText_t curByte;
assert(list.empty()); //List must be empty before use
curByte.highlightColor = ConfigColor("DisassemblyRelocationUnderlineColor");
curByte.highlightWidth = 1;
curByte.flags = RichTextPainter::FlagAll;
curByte.highlight = false;
for(int i = 0; i < inst.dump.size(); i++)
{
curByte.text = ToByteString(inst.dump.at(i));
list.push_back(curByte);
}
if(inst.prefixSize > 0)
{
output.insert(inst.prefixSize * 2, ':');
offset++;
list.at(inst.prefixSize - 1).text.append(':');
}
output.insert((inst.opcodeSize + inst.prefixSize) * 2 + offset, ' ');
offset++;
list.at(inst.opcodeSize + inst.prefixSize - 1).text.append(' ');
if(inst.group1Size > 0)
{
output.insert((inst.opcodeSize + inst.prefixSize + inst.group1Size) * 2 + offset, ' ');
offset++;
list.at(inst.opcodeSize + inst.prefixSize + inst.group1Size - 1).text.append(' ');
}
if(inst.group2Size > 0)
{
output.insert((inst.opcodeSize + inst.prefixSize + inst.group1Size + inst.group2Size) * 2 + offset, ' ');
offset++;
list.at(inst.opcodeSize + inst.prefixSize + inst.group1Size + inst.group2Size - 1).text.append(' ');
}
/*if(inst.group3Size > 0)
{
@ -357,5 +361,4 @@ QString formatOpcodeString(const Instruction_t & inst)
}
output += QString("|%1.%2.%3.%4").arg(inst.opcodeSize).arg(inst.group1Size).arg(inst.group2Size).arg(inst.group3Size);
*/
return output;
}

View File

@ -72,6 +72,6 @@ private:
uint8_t flaginfo[ZYDIS_CPUFLAG_MAX_VALUE + 1];
};
QString formatOpcodeString(const Instruction_t & inst);
void formatOpcodeString(const Instruction_t & inst, RichTextPainter::List & list);
#endif // QBEAENGINE_H

View File

@ -1495,9 +1495,12 @@ void CPUDisassembly::pushSelectionInto(bool copyBytes, QTextStream & stream, QTe
duint cur_addr = rvaToVa(inst.rva);
QString address = getAddrText(cur_addr, 0, addressLen > sizeof(duint) * 2 + 1);
QString bytes;
QString bytesHtml;
if(copyBytes)
{
bytes += formatOpcodeString(inst);
RichTextPainter::List richText;
formatOpcodeString(inst, richText);
RichTextPainter::htmlRichText(richText, bytesHtml, bytes);
}
QString disassembly;
QString htmlDisassembly;