GUI: closes issue #1182
This commit is contained in:
parent
cb98624fad
commit
fbf0ddacca
|
|
@ -1583,21 +1583,22 @@ void Disassembly::prepareDataCount(const QList<dsint> & wRVAs, QList<Instruction
|
|||
}
|
||||
}
|
||||
|
||||
void Disassembly::prepareDataRange(dsint startRva, dsint endRva, const std::function<void(Instruction_t)> & disassembled)
|
||||
void Disassembly::prepareDataRange(dsint startRva, dsint endRva, const std::function<void(int, const Instruction_t &)> & disassembled)
|
||||
{
|
||||
dsint wAddrPrev = startRva;
|
||||
dsint wAddr = wAddrPrev;
|
||||
|
||||
int i = 0;
|
||||
while(true)
|
||||
{
|
||||
if(wAddr >= endRva)
|
||||
break;
|
||||
wAddrPrev = wAddr;
|
||||
auto wInst = std::move(DisassembleAt(wAddr));
|
||||
auto wInst = DisassembleAt(wAddr);
|
||||
wAddr += wInst.length;
|
||||
if(wAddr == wAddrPrev)
|
||||
break;
|
||||
disassembled(std::move(wInst));
|
||||
disassembled(i++, wInst);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1881,7 +1882,7 @@ bool Disassembly::historyHasNext()
|
|||
return true;
|
||||
}
|
||||
|
||||
QString Disassembly::getAddrText(dsint cur_addr, char label[MAX_LABEL_SIZE])
|
||||
QString Disassembly::getAddrText(dsint cur_addr, char label[MAX_LABEL_SIZE], bool getLabel)
|
||||
{
|
||||
QString addrText = "";
|
||||
if(mRvaDisplayEnabled) //RVA display
|
||||
|
|
@ -1914,7 +1915,7 @@ QString Disassembly::getAddrText(dsint cur_addr, char label[MAX_LABEL_SIZE])
|
|||
}
|
||||
addrText += ToPtrString(cur_addr);
|
||||
char label_[MAX_LABEL_SIZE] = "";
|
||||
if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label_)) //has label
|
||||
if(getLabel && DbgGetLabelAt(cur_addr, SEG_DEFAULT, label_)) //has label
|
||||
{
|
||||
char module[MAX_MODULE_SIZE] = "";
|
||||
if(DbgGetModuleAt(cur_addr, module) && !QString(label_).startsWith("JMP.&"))
|
||||
|
|
|
|||
|
|
@ -96,9 +96,9 @@ public:
|
|||
const dsint baseAddress() const;
|
||||
const dsint currentEIP() const;
|
||||
|
||||
QString getAddrText(dsint cur_addr, char label[MAX_LABEL_SIZE]);
|
||||
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<void(Instruction_t)> & disassembled);
|
||||
void prepareDataRange(dsint startRva, dsint endRva, const std::function<void(int, const Instruction_t &)> & disassembled);
|
||||
|
||||
//misc
|
||||
void setCodeFoldingManager(CodeFoldingHelper* CodeFoldingManager);
|
||||
|
|
|
|||
|
|
@ -1426,30 +1426,24 @@ void CPUDisassembly::copySelectionToFileSlot(bool copyBytes)
|
|||
|
||||
void CPUDisassembly::pushSelectionInto(bool copyBytes, QTextStream & stream)
|
||||
{
|
||||
QList<Instruction_t> instBuffer;
|
||||
prepareDataRange(getSelectionStart(), getSelectionEnd(), [&instBuffer](Instruction_t inst)
|
||||
{
|
||||
instBuffer.append(std::move(inst));
|
||||
});
|
||||
|
||||
const int addressLen = getColumnWidth(0) / getCharWidth() - 1;
|
||||
const int bytesLen = getColumnWidth(1) / getCharWidth() - 1;
|
||||
const int disassemblyLen = getColumnWidth(2) / getCharWidth() - 1;
|
||||
for(int i = 0; i < instBuffer.size(); i++)
|
||||
prepareDataRange(getSelectionStart(), getSelectionEnd(), [&](int i, const Instruction_t & inst)
|
||||
{
|
||||
if(i)
|
||||
stream << "\r\n";
|
||||
dsint cur_addr = rvaToVa(instBuffer.at(i).rva);
|
||||
QString address = getAddrText(cur_addr, 0);
|
||||
dsint cur_addr = rvaToVa(inst.rva);
|
||||
QString address = getAddrText(cur_addr, 0, addressLen > sizeof(duint) * 2 + 1);
|
||||
QString bytes;
|
||||
for(int j = 0; j < instBuffer.at(i).dump.size(); j++)
|
||||
for(int j = 0; j < inst.dump.size(); j++)
|
||||
{
|
||||
if(j)
|
||||
bytes += " ";
|
||||
bytes += ToByteString((unsigned char)(instBuffer.at(i).dump.at(j)));
|
||||
bytes += ToByteString((unsigned char)(inst.dump.at(j)));
|
||||
}
|
||||
QString disassembly;
|
||||
for(const auto & token : instBuffer.at(i).tokens.tokens)
|
||||
for(const auto & token : inst.tokens.tokens)
|
||||
disassembly += token.text;
|
||||
QString fullComment;
|
||||
QString comment;
|
||||
|
|
@ -1459,9 +1453,7 @@ void CPUDisassembly::pushSelectionInto(bool copyBytes, QTextStream & stream)
|
|||
if(copyBytes)
|
||||
stream << " | " + bytes.leftJustified(bytesLen, QChar(' '), true);
|
||||
stream << " | " + disassembly.leftJustified(disassemblyLen, QChar(' '), true) + " |" + fullComment;
|
||||
|
||||
stream.flush();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void CPUDisassembly::copySelectionSlot()
|
||||
|
|
@ -1505,19 +1497,14 @@ void CPUDisassembly::copyRvaSlot()
|
|||
|
||||
void CPUDisassembly::copyDisassemblySlot()
|
||||
{
|
||||
QList<Instruction_t> instBuffer;
|
||||
prepareDataRange(getSelectionStart(), getSelectionEnd(), [&instBuffer](Instruction_t inst)
|
||||
{
|
||||
instBuffer.append(std::move(inst));
|
||||
});
|
||||
QString clipboard = "";
|
||||
for(int i = 0; i < instBuffer.size(); i++)
|
||||
prepareDataRange(getSelectionStart(), getSelectionEnd(), [&](int i, const Instruction_t & inst)
|
||||
{
|
||||
if(i)
|
||||
clipboard += "\r\n";
|
||||
for(const auto & token : instBuffer.at(i).tokens.tokens)
|
||||
for(const auto & token : inst.tokens.tokens)
|
||||
clipboard += token.text;
|
||||
}
|
||||
});
|
||||
Bridge::CopyToClipboard(clipboard);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue