Signed and Unsigned byte in dump (#1012)
* Translate some strings and export memiscodepage. * fixed memory leaks in watch view * warn the user if the breakpoint is not executable * use dbgfunctions * remove unused exports * fix * fix * guard translate function with critical section * DeleteCriticalSection * Highlight register from registers view * ALLOW MODIFY RIP REGISTER * Highlight menu in register view * Signed and unsigned byte in dump view
This commit is contained in:
parent
ab5f04f900
commit
546be7a9ea
|
|
@ -1935,3 +1935,15 @@ void Disassembly::ShowDisassemblyPopup(duint addr, int x, int y)
|
|||
else
|
||||
mDisassemblyPopup.hide();
|
||||
}
|
||||
|
||||
bool Disassembly::hightlightToken(const CapstoneTokenizer::SingleToken & token)
|
||||
{
|
||||
mHighlightToken = token;
|
||||
mHighlightingMode = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Disassembly::isHighlightMode()
|
||||
{
|
||||
return mHighlightingMode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ public:
|
|||
void setCodeFoldingManager(CodeFoldingHelper* CodeFoldingManager);
|
||||
void unfold(dsint rva);
|
||||
void ShowDisassemblyPopup(duint addr, int x, int y);
|
||||
bool hightlightToken(const CapstoneTokenizer::SingleToken & token);
|
||||
bool isHighlightMode();
|
||||
|
||||
signals:
|
||||
void selectionChanged(dsint parVA);
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@ void CapstoneTokenizer::addColorName(TokenType type, QString color, QString back
|
|||
void CapstoneTokenizer::addStringsToPool(const QString & strings)
|
||||
{
|
||||
QStringList stringList = strings.split(' ', QString::SkipEmptyParts);
|
||||
bool uppercase = ConfigBool("Disassembler", "Uppercase");
|
||||
for(const QString & string : stringList)
|
||||
stringPoolMap.insert(uppercase ? string.toUpper() : string.toLower(), poolId);
|
||||
stringPoolMap.insert(string, poolId);
|
||||
poolId++;
|
||||
}
|
||||
|
||||
|
|
@ -76,10 +75,11 @@ void CapstoneTokenizer::UpdateStringPool()
|
|||
{
|
||||
poolId = 0;
|
||||
stringPoolMap.clear();
|
||||
addStringsToPool("rax eax ax al");
|
||||
addStringsToPool("rbx ebx bx bl");
|
||||
addStringsToPool("rcx ecx cx cl");
|
||||
addStringsToPool("rdx edx dx dl");
|
||||
// These registers must be in lower case.
|
||||
addStringsToPool("rax eax ax al ah");
|
||||
addStringsToPool("rbx ebx bx bl bh");
|
||||
addStringsToPool("rcx ecx cx cl ch");
|
||||
addStringsToPool("rdx edx dx dl dh");
|
||||
addStringsToPool("rsi esi si sil");
|
||||
addStringsToPool("rdi edi di dil");
|
||||
addStringsToPool("rbp ebp bp bpl");
|
||||
|
|
@ -92,6 +92,22 @@ void CapstoneTokenizer::UpdateStringPool()
|
|||
addStringsToPool("r13 r13d r13w r13b");
|
||||
addStringsToPool("r14 r14d r14w r14b");
|
||||
addStringsToPool("r15 r15d r15w r15b");
|
||||
addStringsToPool("xmm0 ymm0");
|
||||
addStringsToPool("xmm1 ymm1");
|
||||
addStringsToPool("xmm2 ymm2");
|
||||
addStringsToPool("xmm3 ymm3");
|
||||
addStringsToPool("xmm4 ymm4");
|
||||
addStringsToPool("xmm5 ymm5");
|
||||
addStringsToPool("xmm6 ymm6");
|
||||
addStringsToPool("xmm7 ymm7");
|
||||
addStringsToPool("xmm8 ymm8");
|
||||
addStringsToPool("xmm9 ymm9");
|
||||
addStringsToPool("xmm10 ymm10");
|
||||
addStringsToPool("xmm11 ymm11");
|
||||
addStringsToPool("xmm12 ymm12");
|
||||
addStringsToPool("xmm13 ymm13");
|
||||
addStringsToPool("xmm14 ymm14");
|
||||
addStringsToPool("xmm15 ymm15");
|
||||
}
|
||||
|
||||
bool CapstoneTokenizer::Tokenize(duint addr, const unsigned char* data, int datasize, InstructionToken & instruction)
|
||||
|
|
@ -231,10 +247,10 @@ bool CapstoneTokenizer::IsHighlightableToken(const SingleToken & token)
|
|||
|
||||
bool CapstoneTokenizer::tokenTextPoolEquals(const QString & a, const QString & b)
|
||||
{
|
||||
if(a == b)
|
||||
if(a.compare(b, Qt::CaseInsensitive) == 0)
|
||||
return true;
|
||||
auto found1 = stringPoolMap.find(a);
|
||||
auto found2 = stringPoolMap.find(b);
|
||||
auto found1 = stringPoolMap.find(a.toLower());
|
||||
auto found2 = stringPoolMap.find(b.toLower());
|
||||
if(found1 == stringPoolMap.end() || found2 == stringPoolMap.end())
|
||||
return false;
|
||||
return found1.value() == found2.value();
|
||||
|
|
|
|||
|
|
@ -202,9 +202,11 @@ void CPUDump::setupContextMenu()
|
|||
mMenuBuilder->addMenu(makeMenu(DIcon("strings.png"), tr("&Text")), wTextMenu);
|
||||
|
||||
MenuBuilder* wIntegerMenu = new MenuBuilder(this);
|
||||
wIntegerMenu->addAction(makeAction(DIcon("byte.png"), tr("Signed byte (8-bit)"), SLOT(integerSignedByteSlot())));
|
||||
wIntegerMenu->addAction(makeAction(DIcon("word.png"), tr("Signed short (16-bit)"), SLOT(integerSignedShortSlot())));
|
||||
wIntegerMenu->addAction(makeAction(DIcon("dword.png"), tr("Signed long (32-bit)"), SLOT(integerSignedLongSlot())));
|
||||
wIntegerMenu->addAction(makeAction(DIcon("qword.png"), tr("Signed long long (64-bit)"), SLOT(integerSignedLongLongSlot())));
|
||||
wIntegerMenu->addAction(makeAction(DIcon("byte.png"), tr("Unsigned byte (8-bit)"), SLOT(integerUnsignedByteSlot())));
|
||||
wIntegerMenu->addAction(makeAction(DIcon("word.png"), tr("Unsigned short (16-bit)"), SLOT(integerUnsignedShortSlot())));
|
||||
wIntegerMenu->addAction(makeAction(DIcon("dword.png"), tr("Unsigned long (32-bit)"), SLOT(integerUnsignedLongSlot())));
|
||||
wIntegerMenu->addAction(makeAction(DIcon("qword.png"), tr("Unsigned long long (64-bit)"), SLOT(integerUnsignedLongLongSlot())));
|
||||
|
|
@ -647,6 +649,31 @@ void CPUDump::textCodepageSlot()
|
|||
reloadData();
|
||||
}
|
||||
|
||||
void CPUDump::integerSignedByteSlot()
|
||||
{
|
||||
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerSignedByte);
|
||||
int charwidth = getCharWidth();
|
||||
ColumnDescriptor_t wColDesc;
|
||||
DataDescriptor_t dDesc;
|
||||
|
||||
wColDesc.isData = true; //signed short
|
||||
wColDesc.itemCount = 8;
|
||||
wColDesc.separator = 0;
|
||||
wColDesc.data.itemSize = Byte;
|
||||
wColDesc.data.wordMode = SignedDecWord;
|
||||
appendResetDescriptor(8 + charwidth * 40, tr("Signed byte (8-bit)"), false, wColDesc);
|
||||
|
||||
wColDesc.isData = false; //empty column
|
||||
wColDesc.itemCount = 0;
|
||||
wColDesc.separator = 0;
|
||||
dDesc.itemSize = Byte;
|
||||
dDesc.byteMode = AsciiByte;
|
||||
wColDesc.data = dDesc;
|
||||
appendDescriptor(0, "", false, wColDesc);
|
||||
|
||||
reloadData();
|
||||
}
|
||||
|
||||
void CPUDump::integerSignedShortSlot()
|
||||
{
|
||||
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerSignedShort);
|
||||
|
|
@ -722,6 +749,31 @@ void CPUDump::integerSignedLongLongSlot()
|
|||
reloadData();
|
||||
}
|
||||
|
||||
void CPUDump::integerUnsignedByteSlot()
|
||||
{
|
||||
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerUnsignedByte);
|
||||
int charwidth = getCharWidth();
|
||||
ColumnDescriptor_t wColDesc;
|
||||
DataDescriptor_t dDesc;
|
||||
|
||||
wColDesc.isData = true; //unsigned short
|
||||
wColDesc.itemCount = 8;
|
||||
wColDesc.separator = 0;
|
||||
wColDesc.data.itemSize = Byte;
|
||||
wColDesc.data.wordMode = UnsignedDecWord;
|
||||
appendResetDescriptor(8 + charwidth * 32, tr("Unsigned byte (8-bit)"), false, wColDesc);
|
||||
|
||||
wColDesc.isData = false; //empty column
|
||||
wColDesc.itemCount = 0;
|
||||
wColDesc.separator = 0;
|
||||
dDesc.itemSize = Byte;
|
||||
dDesc.byteMode = AsciiByte;
|
||||
wColDesc.data = dDesc;
|
||||
appendDescriptor(0, "", false, wColDesc);
|
||||
|
||||
reloadData();
|
||||
}
|
||||
|
||||
void CPUDump::integerUnsignedShortSlot()
|
||||
{
|
||||
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerUnsignedShort);
|
||||
|
|
@ -1397,6 +1449,9 @@ void CPUDump::setView(ViewEnum_t view)
|
|||
case ViewTextUnicode:
|
||||
textUnicodeSlot();
|
||||
break;
|
||||
case ViewIntegerSignedByte:
|
||||
integerSignedByteSlot();
|
||||
break;
|
||||
case ViewIntegerSignedShort:
|
||||
integerSignedShortSlot();
|
||||
break;
|
||||
|
|
@ -1406,6 +1461,9 @@ void CPUDump::setView(ViewEnum_t view)
|
|||
case ViewIntegerSignedLongLong:
|
||||
integerSignedLongLongSlot();
|
||||
break;
|
||||
case ViewIntegerUnsignedByte:
|
||||
integerUnsignedByteSlot();
|
||||
break;
|
||||
case ViewIntegerUnsignedShort:
|
||||
integerUnsignedShortSlot();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -57,9 +57,11 @@ public slots:
|
|||
void textUnicodeSlot();
|
||||
void textCodepageSlot();
|
||||
|
||||
void integerSignedByteSlot();
|
||||
void integerSignedShortSlot();
|
||||
void integerSignedLongSlot();
|
||||
void integerSignedLongLongSlot();
|
||||
void integerUnsignedByteSlot();
|
||||
void integerUnsignedShortSlot();
|
||||
void integerUnsignedLongSlot();
|
||||
void integerUnsignedLongLongSlot();
|
||||
|
|
@ -133,7 +135,9 @@ private:
|
|||
ViewFloatFloat,
|
||||
ViewFloatDouble,
|
||||
ViewFloatLongDouble,
|
||||
ViewAddress
|
||||
ViewAddress,
|
||||
ViewIntegerSignedByte,
|
||||
ViewIntegerUnsignedByte
|
||||
};
|
||||
|
||||
void setView(ViewEnum_t view);
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ void CPUStack::updateColors()
|
|||
void CPUStack::updateFonts()
|
||||
{
|
||||
setFont(ConfigFont("Stack"));
|
||||
invalidateCachedFont();
|
||||
}
|
||||
|
||||
void CPUStack::setupContextMenu()
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
|
|||
|
||||
connect(mDisas, SIGNAL(selectionChanged(dsint)), mInfo, SLOT(disasmSelectionChanged(dsint)));
|
||||
|
||||
mGeneralRegs = new RegistersView(0);
|
||||
mGeneralRegs = new RegistersView(this);
|
||||
mGeneralRegs->setFixedWidth(1000);
|
||||
mGeneralRegs->ShowFPU(true);
|
||||
mGeneralRegs->setFixedHeight(mGeneralRegs->getEstimateHeight());
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#include <QListWidget>
|
||||
#include <stdint.h>
|
||||
#include "RegistersView.h"
|
||||
#include "CPUWidget.h"
|
||||
#include "CPUDisassembly.h"
|
||||
#include "Configuration.h"
|
||||
#include "WordEditDialog.h"
|
||||
#include "LineEditDialog.h"
|
||||
|
|
@ -413,7 +415,7 @@ void RegistersView::InitMappings()
|
|||
mRowsNeeded = offset + 1;
|
||||
}
|
||||
|
||||
RegistersView::RegistersView(QWidget* parent) : QScrollArea(parent), mVScrollOffset(0)
|
||||
RegistersView::RegistersView(CPUWidget* parent) : QScrollArea(parent), mVScrollOffset(0), mParent(parent)
|
||||
{
|
||||
mChangeViewButton = NULL;
|
||||
|
||||
|
|
@ -454,6 +456,7 @@ RegistersView::RegistersView(QWidget* parent) : QScrollArea(parent), mVScrollOff
|
|||
wCM_DecrementPtrSize = new QAction(ArchValue(tr("Decrease 4"), tr("Decrease 8")), this);
|
||||
wCM_Push = new QAction(tr("Push"), this);
|
||||
wCM_Pop = new QAction(tr("Pop"), this);
|
||||
wCM_Highlight = new QAction(tr("Highlight"), this);
|
||||
|
||||
// general purposes register (we allow the user to modify the value)
|
||||
mGPR.insert(CAX);
|
||||
|
|
@ -1112,6 +1115,7 @@ RegistersView::RegistersView(QWidget* parent) : QScrollArea(parent), mVScrollOff
|
|||
mLABELDISPLAY.insert(CIP);
|
||||
mONLYMODULEANDLABELDISPLAY.insert(CIP);
|
||||
mCANSTOREADDRESS.insert(CIP);
|
||||
mMODIFYDISPLAY.insert(CIP);
|
||||
|
||||
InitMappings();
|
||||
|
||||
|
|
@ -1154,6 +1158,7 @@ RegistersView::RegistersView(QWidget* parent) : QScrollArea(parent), mVScrollOff
|
|||
connect(wCM_DecrementPtrSize, SIGNAL(triggered()), this, SLOT(onDecrementPtrSize()));
|
||||
connect(wCM_Push, SIGNAL(triggered()), this, SLOT(onPushAction()));
|
||||
connect(wCM_Pop, SIGNAL(triggered()), this, SLOT(onPopAction()));
|
||||
connect(wCM_Highlight, SIGNAL(triggered()), this, SLOT(onHighlightSlot()));
|
||||
|
||||
refreshShortcutsSlot();
|
||||
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
|
||||
|
|
@ -1251,7 +1256,22 @@ void RegistersView::mousePressEvent(QMouseEvent* event)
|
|||
// do we find a corresponding register?
|
||||
if(identifyRegister(y, x, &r))
|
||||
{
|
||||
mSelected = r;
|
||||
Disassembly* CPUDisassemblyView = mParent->getDisasmWidget();
|
||||
if(CPUDisassemblyView->isHighlightMode())
|
||||
{
|
||||
if(mGPR.contains(r) && r != REGISTER_NAME::EFLAGS)
|
||||
CPUDisassemblyView->hightlightToken(CapstoneTokenizer::SingleToken(CapstoneTokenizer::TokenType::GeneralRegister, mRegisterMapping.constFind(r).value()));
|
||||
else if(mFPUMMX.contains(r))
|
||||
CPUDisassemblyView->hightlightToken(CapstoneTokenizer::SingleToken(CapstoneTokenizer::TokenType::MmxRegister, mRegisterMapping.constFind(r).value()));
|
||||
else if(mFPUXMM.contains(r))
|
||||
CPUDisassemblyView->hightlightToken(CapstoneTokenizer::SingleToken(CapstoneTokenizer::TokenType::XmmRegister, mRegisterMapping.constFind(r).value()));
|
||||
else if(mFPUYMM.contains(r))
|
||||
CPUDisassemblyView->hightlightToken(CapstoneTokenizer::SingleToken(CapstoneTokenizer::TokenType::YmmRegister, mRegisterMapping.constFind(r).value()));
|
||||
else
|
||||
mSelected = r;
|
||||
}
|
||||
else
|
||||
mSelected = r;
|
||||
emit refresh();
|
||||
}
|
||||
else
|
||||
|
|
@ -1271,15 +1291,13 @@ void RegistersView::mouseDoubleClickEvent(QMouseEvent* event)
|
|||
// do we find a corresponding register?
|
||||
if(!identifyRegister(y, x, 0))
|
||||
return;
|
||||
if(mSelected == CIP) //double clicked on CIP register
|
||||
DbgCmdExec("disasm cip");
|
||||
// is current register general purposes register or FPU register?
|
||||
if(mMODIFYDISPLAY.contains(mSelected))
|
||||
{
|
||||
else if(mMODIFYDISPLAY.contains(mSelected))
|
||||
wCM_Modify->trigger();
|
||||
}
|
||||
else if(mBOOLDISPLAY.contains(mSelected)) // is flag ?
|
||||
wCM_ToggleValue->trigger();
|
||||
else if(mSelected == CIP) //double clicked on CIP register
|
||||
DbgCmdExec("disasm cip");
|
||||
}
|
||||
|
||||
void RegistersView::paintEvent(QPaintEvent* event)
|
||||
|
|
@ -2119,6 +2137,19 @@ void RegistersView::onCopySymbolToClipboardAction()
|
|||
}
|
||||
}
|
||||
|
||||
void RegistersView::onHighlightSlot()
|
||||
{
|
||||
Disassembly* CPUDisassemblyView = mParent->getDisasmWidget();
|
||||
if(mGPR.contains(mSelected) && mSelected != REGISTER_NAME::EFLAGS)
|
||||
CPUDisassemblyView->hightlightToken(CapstoneTokenizer::SingleToken(CapstoneTokenizer::TokenType::GeneralRegister, mRegisterMapping.constFind(mSelected).value()));
|
||||
else if(mFPUMMX.contains(mSelected))
|
||||
CPUDisassemblyView->hightlightToken(CapstoneTokenizer::SingleToken(CapstoneTokenizer::TokenType::MmxRegister, mRegisterMapping.constFind(mSelected).value()));
|
||||
else if(mFPUXMM.contains(mSelected))
|
||||
CPUDisassemblyView->hightlightToken(CapstoneTokenizer::SingleToken(CapstoneTokenizer::TokenType::XmmRegister, mRegisterMapping.constFind(mSelected).value()));
|
||||
else if(mFPUYMM.contains(mSelected))
|
||||
CPUDisassemblyView->hightlightToken(CapstoneTokenizer::SingleToken(CapstoneTokenizer::TokenType::YmmRegister, mRegisterMapping.constFind(mSelected).value()));
|
||||
}
|
||||
|
||||
void RegistersView::appendRegister(QString & text, REGISTER_NAME reg, const char* name64, const char* name32)
|
||||
{
|
||||
QString symbol;
|
||||
|
|
@ -2361,7 +2392,7 @@ void RegistersView::displayCustomContextMenuSlot(QPoint pos)
|
|||
wMenu.addAction(wCM_DecrementPtrSize);
|
||||
}
|
||||
|
||||
if(mGPR.contains(mSelected) || mSEGMENTREGISTER.contains(mSelected))
|
||||
if(mGPR.contains(mSelected) || mSEGMENTREGISTER.contains(mSelected) || mSelected == CIP)
|
||||
{
|
||||
wMenu.addAction(wCM_Push);
|
||||
wMenu.addAction(wCM_Pop);
|
||||
|
|
@ -2393,6 +2424,11 @@ void RegistersView::displayCustomContextMenuSlot(QPoint pos)
|
|||
wMenu.addAction(wCM_CopySymbolToClipboard);
|
||||
}
|
||||
|
||||
if((mGPR.contains(mSelected) && mSelected != REGISTER_NAME::EFLAGS) || mFPUMMX.contains(mSelected) || mFPUXMM.contains(mSelected) || mFPUYMM.contains(mSelected))
|
||||
{
|
||||
wMenu.addAction(wCM_Highlight);
|
||||
}
|
||||
|
||||
wMenu.addAction(wCM_CopyToClipboard);
|
||||
wMenu.addAction(wCM_CopyAll);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#define IsCharacterRegister(x) ((x>=CAX && x<CIP))
|
||||
|
||||
class CPUWidget;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
QString string;
|
||||
|
|
@ -89,7 +91,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
explicit RegistersView(QWidget* parent = 0);
|
||||
explicit RegistersView(CPUWidget* parent);
|
||||
~RegistersView();
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
|
@ -146,6 +148,7 @@ protected slots:
|
|||
void onDecrementPtrSize();
|
||||
void onPushAction();
|
||||
void onPopAction();
|
||||
void onHighlightSlot();
|
||||
void InitMappings();
|
||||
QString getRegisterLabel(REGISTER_NAME);
|
||||
int CompareRegisters(const REGISTER_NAME reg_name, REGDUMP* regdump1, REGDUMP* regdump2);
|
||||
|
|
@ -165,6 +168,7 @@ protected slots:
|
|||
void appendRegister(QString & text, REGISTER_NAME reg, const char* name64, const char* name32);
|
||||
private:
|
||||
QPushButton* mChangeViewButton;
|
||||
CPUWidget* mParent;
|
||||
bool mShowFpu;
|
||||
int mVScrollOffset;
|
||||
int mRowsNeeded;
|
||||
|
|
@ -229,6 +233,7 @@ private:
|
|||
QAction* wCM_Incrementx87Stack;
|
||||
QAction* wCM_Decrementx87Stack;
|
||||
QAction* wCM_ChangeFPUView;
|
||||
QAction* wCM_Highlight;
|
||||
dsint mCip;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue