1
0
Fork 0

GUI: introduce setting for ASCII/Unicode in address dump mode

This commit is contained in:
Duncan Ogilvie 2018-02-08 01:14:30 +01:00
parent 8a1256b5fd
commit 804322aeb8
5 changed files with 94 additions and 11 deletions

View File

@ -26,10 +26,12 @@ CPUDump::CPUDump(CPUDisassembly* disas, CPUMultiDump* multiDump, QWidget* parent
if(BridgeSettingGetUint("Gui", "AsciiSeparator", &setting))
mAsciiSeparator = setting & 0xF;
asciiAddressDumpModeUpdatedSlot();
setView((ViewEnum_t)ConfigUint("HexDump", "DefaultView"));
connect(this, SIGNAL(selectionUpdated()), this, SLOT(selectionUpdatedSlot()));
connect(this, SIGNAL(headerButtonReleased(int)), this, SLOT(headerButtonReleasedSlot(int)));
connect(Config(), SIGNAL(asciiAddressDumpModeUpdated()), this, SLOT(asciiAddressDumpModeUpdatedSlot()));
mPluginMenu = multiDump->mDumpPluginMenu;
@ -740,6 +742,8 @@ void CPUDump::hexCodepageSlot()
void CPUDump::hexLastCodepageSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewHexCodepage);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -770,6 +774,8 @@ void CPUDump::hexLastCodepageSlot()
void CPUDump::textLastCodepageSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewTextCodepage);
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
duint lastCodepage;
@ -1215,6 +1221,12 @@ void CPUDump::floatLongDoubleSlot()
void CPUDump::addressSlot()
{
if(mAsciiAddressDumpMode)
{
addressAsciiSlot();
return;
}
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddress);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
@ -1232,6 +1244,42 @@ void CPUDump::addressSlot()
#endif
appendResetDescriptor(8 + charwidth * 2 * sizeof(duint), tr("Value"), false, wColDesc);
wColDesc.isData = false; //comments
wColDesc.itemCount = 1;
wColDesc.separator = 0;
dDesc.itemSize = Byte;
dDesc.byteMode = AsciiByte;
wColDesc.data = dDesc;
appendDescriptor(0, tr("Comments"), false, wColDesc);
reloadData();
}
void CPUDump::addressAsciiSlot()
{
if(!mAsciiAddressDumpMode)
{
addressSlot();
return;
}
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddressAscii);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
wColDesc.isData = true; //void*
wColDesc.itemCount = 1;
wColDesc.separator = 0;
#ifdef _WIN64
wColDesc.data.itemSize = Qword;
wColDesc.data.qwordMode = HexQword;
#else
wColDesc.data.itemSize = Dword;
wColDesc.data.dwordMode = HexDword;
#endif
appendResetDescriptor(8 + charwidth * 2 * sizeof(duint), tr("Value"), false, wColDesc);
wColDesc.isData = true;
wColDesc.separator = 0;
#ifdef _WIN64
@ -1247,7 +1295,6 @@ void CPUDump::addressSlot()
};
appendDescriptor(8 + charwidth * wColDesc.itemCount, tr("ASCII"), true, wColDesc);
wColDesc.isData = false; //comments
wColDesc.itemCount = 1;
wColDesc.separator = 0;
@ -1259,13 +1306,14 @@ void CPUDump::addressSlot()
reloadData();
}
void CPUDump::addressAsciiSlot()
{
addressSlot();
}
void CPUDump::addressUnicodeSlot()
{
if(!mAsciiAddressDumpMode)
{
addressSlot();
return;
}
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddressUnicode);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
@ -1298,7 +1346,6 @@ void CPUDump::addressUnicodeSlot()
};
appendDescriptor(8 + charwidth * wColDesc.itemCount, tr("UNICODE"), true, wColDesc);
wColDesc.isData = false; //comments
wColDesc.itemCount = 1;
wColDesc.separator = 0;
@ -1793,11 +1840,17 @@ void CPUDump::setView(ViewEnum_t view)
case ViewAddress:
addressSlot();
break;
case ViewAddressAscii:
addressAsciiSlot();
break;
case ViewAddressUnicode:
addressUnicodeSlot();
break;
case ViewAddressAscii:
addressAsciiSlot();
case ViewHexCodepage:
hexLastCodepageSlot();
break;
case ViewTextCodepage:
textLastCodepageSlot();
break;
default:
hexAsciiSlot();
@ -1816,3 +1869,19 @@ void CPUDump::headerButtonReleasedSlot(int colIndex)
if(callback)
callback();
}
void CPUDump::asciiAddressDumpModeUpdatedSlot()
{
duint setting = 0;
mAsciiAddressDumpMode = BridgeSettingGetUint("Gui", "AsciiAddressDumpMode", &setting) && setting;
auto defaultView = (ViewEnum_t)ConfigUint("HexDump", "DefaultView");
printf("defaultView: %d\n", defaultView);
switch(defaultView)
{
case ViewAddress:
case ViewAddressAscii:
case ViewAddressUnicode:
setView(defaultView);
break;
}
}

View File

@ -114,6 +114,7 @@ public slots:
void followInMemoryMapSlot();
void headerButtonReleasedSlot(int colIndex);
void asciiAddressDumpModeUpdatedSlot();
private:
MenuBuilder* mMenuBuilder;
@ -127,6 +128,7 @@ private:
CPUDisassembly* mDisas;
CPUMultiDump* mMultiDump;
int mAsciiSeparator = 0;
bool mAsciiAddressDumpMode;
enum ViewEnum_t
{
@ -150,7 +152,9 @@ private:
ViewIntegerSignedByte,
ViewIntegerUnsignedByte,
ViewAddressAscii,
ViewAddressUnicode
ViewAddressUnicode,
ViewHexCodepage,
ViewTextCodepage
};
void setView(ViewEnum_t view);

View File

@ -23,7 +23,7 @@ CPUMultiDump::CPUMultiDump(CPUDisassembly* disas, int nbCpuDumpTabs, QWidget* pa
for(uint i = 0; i < mMaxCPUDumpTabs; i++)
{
CPUDump* cpuDump = new CPUDump(disas, this);
cpuDump->loadColumnFromConfig(QString("CPUDump%1").arg(i + 1)); //TODO: needs a workaround because the columns change
//cpuDump->loadColumnFromConfig(QString("CPUDump%1").arg(i + 1)); //TODO: needs a workaround because the columns change
connect(cpuDump, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidgetSlot()));
auto nativeTitle = QString("Dump ") + QString::number(i + 1);
this->addTabEx(cpuDump, DIcon("dump.png"), tr("Dump ") + QString::number(i + 1), nativeTitle);

View File

@ -85,6 +85,7 @@ private slots:
void on_chkNoForegroundWindow_toggled(bool checked);
void on_chkShowExitConfirmation_toggled(bool checked);
void on_chkDisableAutoComplete_toggled(bool checked);
void on_chkAsciiAddressDumpMode_toggled(bool checked);
//Misc tab
void on_chkSetJIT_stateChanged(int arg1);
void on_chkConfirmBeforeAtt_stateChanged(int arg1);
@ -183,6 +184,7 @@ private:
bool guiShowGraphRva;
bool guiShowExitConfirmation;
bool guiDisableAutoComplete;
bool guiAsciiAddressDumpMode;
//Misc Tab
bool miscSetJIT;
bool miscSetJITAuto;
@ -202,6 +204,7 @@ private:
bool bJitAutoOld;
bool bTokenizerConfigUpdated;
bool bDisableAutoCompleteUpdated;
bool bAsciiAddressDumpModeUpdated;
//functions
void GetSettingBool(const char* section, const char* name, bool* set);

View File

@ -706,6 +706,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkAsciiAddressDumpMode">
<property name="text">
<string>Show ASCII/Unicode in address dump mode</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">