1
0
Fork 0

0x prefix for values, fixes #614 (#1557)

This commit is contained in:
kkthx 2017-04-20 20:45:23 +02:00 committed by Duncan Ogilvie
parent c9d7d15297
commit a905656230
6 changed files with 31 additions and 6 deletions

View File

@ -9,7 +9,7 @@ CapstoneTokenizer::CapstoneTokenizer(int maxModuleLength)
isNop(false), isNop(false),
_mnemonicType(TokenType::Uncategorized) _mnemonicType(TokenType::Uncategorized)
{ {
SetConfig(false, false, false, false, false, false); SetConfig(false, false, false, false, false, false, false);
} }
CapstoneTokenizer::TokenColor colorNamesMap[CapstoneTokenizer::TokenType::Last]; CapstoneTokenizer::TokenColor colorNamesMap[CapstoneTokenizer::TokenType::Last];
@ -173,12 +173,13 @@ void CapstoneTokenizer::UpdateConfig()
ConfigBool("Disassembler", "ArgumentSpaces"), ConfigBool("Disassembler", "ArgumentSpaces"),
ConfigBool("Disassembler", "MemorySpaces"), ConfigBool("Disassembler", "MemorySpaces"),
ConfigBool("Disassembler", "NoHighlightOperands"), ConfigBool("Disassembler", "NoHighlightOperands"),
ConfigBool("Disassembler", "NoCurrentModuleText")); ConfigBool("Disassembler", "NoCurrentModuleText"),
ConfigBool("Disassembler", "0xPrefixValues"));
_maxModuleLength = (int)ConfigUint("Disassembler", "MaxModuleSize"); _maxModuleLength = (int)ConfigUint("Disassembler", "MaxModuleSize");
UpdateStringPool(); UpdateStringPool();
} }
void CapstoneTokenizer::SetConfig(bool bUppercase, bool bTabbedMnemonic, bool bArgumentSpaces, bool bMemorySpaces, bool bNoHighlightOperands, bool bNoCurrentModuleText) void CapstoneTokenizer::SetConfig(bool bUppercase, bool bTabbedMnemonic, bool bArgumentSpaces, bool bMemorySpaces, bool bNoHighlightOperands, bool bNoCurrentModuleText, bool b0xPrefixValues)
{ {
_bUppercase = bUppercase; _bUppercase = bUppercase;
_bTabbedMnemonic = bTabbedMnemonic; _bTabbedMnemonic = bTabbedMnemonic;
@ -186,6 +187,7 @@ void CapstoneTokenizer::SetConfig(bool bUppercase, bool bTabbedMnemonic, bool bA
_bMemorySpaces = bMemorySpaces; _bMemorySpaces = bMemorySpaces;
_bNoHighlightOperands = bNoHighlightOperands; _bNoHighlightOperands = bNoHighlightOperands;
_bNoCurrentModuleText = bNoCurrentModuleText; _bNoCurrentModuleText = bNoCurrentModuleText;
_b0xPrefixValues = b0xPrefixValues;
} }
int CapstoneTokenizer::Size() const int CapstoneTokenizer::Size() const
@ -349,6 +351,8 @@ QString CapstoneTokenizer::printValue(const TokenValue & value, bool expandModul
finalText = QString("%1%2").arg(moduleText).arg(addrText); finalText = QString("%1%2").arg(moduleText).arg(addrText);
else if(bHasLabel) //<label> else if(bHasLabel) //<label>
finalText = QString("<%1>").arg(labelText); finalText = QString("<%1>").arg(labelText);
else if (_b0xPrefixValues)
finalText = QString("0x")+addrText;
else else
finalText = addrText; finalText = addrText;
return finalText; return finalText;

View File

@ -147,7 +147,7 @@ public:
bool Tokenize(duint addr, const unsigned char* data, int datasize, InstructionToken & instruction); bool Tokenize(duint addr, const unsigned char* data, int datasize, InstructionToken & instruction);
bool TokenizeData(const QString & datatype, const QString & data, InstructionToken & instruction); bool TokenizeData(const QString & datatype, const QString & data, InstructionToken & instruction);
void UpdateConfig(); void UpdateConfig();
void SetConfig(bool bUppercase, bool bTabbedMnemonic, bool bArgumentSpaces, bool bMemorySpaces, bool bNoHighlightOperands, bool bNoCurrentModuleText); void SetConfig(bool bUppercase, bool bTabbedMnemonic, bool bArgumentSpaces, bool bMemorySpaces, bool bNoHighlightOperands, bool bNoCurrentModuleText, bool b0xPrefixValues);
int Size() const; int Size() const;
const Capstone & GetCapstone() const; const Capstone & GetCapstone() const;
@ -173,6 +173,7 @@ private:
bool _bMemorySpaces; bool _bMemorySpaces;
bool _bNoHighlightOperands; bool _bNoHighlightOperands;
bool _bNoCurrentModuleText; bool _bNoCurrentModuleText;
bool _b0xPrefixValues;
TokenType _mnemonicType; TokenType _mnemonicType;
void addToken(TokenType type, QString text, const TokenValue & value); void addToken(TokenType type, QString text, const TokenValue & value);

View File

@ -70,6 +70,7 @@ void SettingsDialog::LoadSettings()
settings.disasmOnlyCipAutoComments = false; settings.disasmOnlyCipAutoComments = false;
settings.disasmTabBetweenMnemonicAndArguments = false; settings.disasmTabBetweenMnemonicAndArguments = false;
settings.disasmNoCurrentModuleText = false; settings.disasmNoCurrentModuleText = false;
settings.disasm0xPrefixValues = false;
settings.guiNoForegroundWindow = true; settings.guiNoForegroundWindow = true;
//Events tab //Events tab
@ -196,6 +197,7 @@ void SettingsDialog::LoadSettings()
GetSettingBool("Disassembler", "NoHighlightOperands", &settings.disasmNoHighlightOperands); GetSettingBool("Disassembler", "NoHighlightOperands", &settings.disasmNoHighlightOperands);
GetSettingBool("Disassembler", "PermanentHighlightingMode", &settings.disasmPermanentHighlightingMode); GetSettingBool("Disassembler", "PermanentHighlightingMode", &settings.disasmPermanentHighlightingMode);
GetSettingBool("Disassembler", "NoCurrentModuleText", &settings.disasmNoCurrentModuleText); GetSettingBool("Disassembler", "NoCurrentModuleText", &settings.disasmNoCurrentModuleText);
GetSettingBool("Disassembler", "0xPrefixValues", &settings.disasm0xPrefixValues);
ui->chkArgumentSpaces->setChecked(settings.disasmArgumentSpaces); ui->chkArgumentSpaces->setChecked(settings.disasmArgumentSpaces);
ui->chkMemorySpaces->setChecked(settings.disasmMemorySpaces); ui->chkMemorySpaces->setChecked(settings.disasmMemorySpaces);
ui->chkUppercase->setChecked(settings.disasmUppercase); ui->chkUppercase->setChecked(settings.disasmUppercase);
@ -204,6 +206,7 @@ void SettingsDialog::LoadSettings()
ui->chkNoHighlightOperands->setChecked(settings.disasmNoHighlightOperands); ui->chkNoHighlightOperands->setChecked(settings.disasmNoHighlightOperands);
ui->chkPermanentHighlightingMode->setChecked(settings.disasmPermanentHighlightingMode); ui->chkPermanentHighlightingMode->setChecked(settings.disasmPermanentHighlightingMode);
ui->chkNoCurrentModuleText->setChecked(settings.disasmNoCurrentModuleText); ui->chkNoCurrentModuleText->setChecked(settings.disasmNoCurrentModuleText);
ui->chk0xPrefixValues->setChecked(settings.disasm0xPrefixValues);
//Gui tab //Gui tab
GetSettingBool("Gui", "FpuRegistersLittleEndian", &settings.guiFpuRegistersLittleEndian); GetSettingBool("Gui", "FpuRegistersLittleEndian", &settings.guiFpuRegistersLittleEndian);
@ -336,6 +339,7 @@ void SettingsDialog::SaveSettings()
BridgeSettingSetUint("Disassembler", "NoHighlightOperands", settings.disasmNoHighlightOperands); BridgeSettingSetUint("Disassembler", "NoHighlightOperands", settings.disasmNoHighlightOperands);
BridgeSettingSetUint("Disassembler", "PermanentHighlightingMode", settings.disasmPermanentHighlightingMode); BridgeSettingSetUint("Disassembler", "PermanentHighlightingMode", settings.disasmPermanentHighlightingMode);
BridgeSettingSetUint("Disassembler", "NoCurrentModuleText", settings.disasmNoCurrentModuleText); BridgeSettingSetUint("Disassembler", "NoCurrentModuleText", settings.disasmNoCurrentModuleText);
BridgeSettingSetUint("Disassembler", "0xPrefixValues", settings.disasm0xPrefixValues);
//Gui tab //Gui tab
BridgeSettingSetUint("Gui", "FpuRegistersLittleEndian", settings.guiFpuRegistersLittleEndian); BridgeSettingSetUint("Gui", "FpuRegistersLittleEndian", settings.guiFpuRegistersLittleEndian);
@ -780,3 +784,9 @@ void SettingsDialog::on_chkNoCurrentModuleText_toggled(bool checked)
bTokenizerConfigUpdated = true; bTokenizerConfigUpdated = true;
settings.disasmNoCurrentModuleText = checked; settings.disasmNoCurrentModuleText = checked;
} }
void SettingsDialog::on_chk0xPrefixValues_toggled(bool checked)
{
bTokenizerConfigUpdated = true;
settings.disasm0xPrefixValues = checked;
}

View File

@ -70,6 +70,7 @@ private slots:
void on_chkNoHighlightOperands_toggled(bool checked); void on_chkNoHighlightOperands_toggled(bool checked);
void on_chkNoCurrentModuleText_toggled(bool checked); void on_chkNoCurrentModuleText_toggled(bool checked);
void on_chkPermanentHighlightingMode_toggled(bool checked); void on_chkPermanentHighlightingMode_toggled(bool checked);
void on_chk0xPrefixValues_toggled(bool checked);
//Gui Tab //Gui Tab
void on_chkFpuRegistersLittleEndian_stateChanged(int arg1); void on_chkFpuRegistersLittleEndian_stateChanged(int arg1);
void on_chkSaveColumnOrder_stateChanged(int arg1); void on_chkSaveColumnOrder_stateChanged(int arg1);
@ -156,6 +157,7 @@ private:
bool disasmNoHighlightOperands; bool disasmNoHighlightOperands;
bool disasmNoCurrentModuleText; bool disasmNoCurrentModuleText;
bool disasmPermanentHighlightingMode; bool disasmPermanentHighlightingMode;
bool disasm0xPrefixValues;
//Gui Tab //Gui Tab
bool guiFpuRegistersLittleEndian; bool guiFpuRegistersLittleEndian;
bool guiSaveColumnOrder; bool guiSaveColumnOrder;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>381</width> <width>381</width>
<height>508</height> <height>514</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -33,7 +33,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="tabEvents"> <widget class="QWidget" name="tabEvents">
<attribute name="title"> <attribute name="title">
@ -531,6 +531,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="chk0xPrefixValues">
<property name="text">
<string>0x prefix for values</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">

View File

@ -237,6 +237,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
disassemblyBool.insert("LongDataInstruction", false); disassemblyBool.insert("LongDataInstruction", false);
disassemblyBool.insert("NoHighlightOperands", false); disassemblyBool.insert("NoHighlightOperands", false);
disassemblyBool.insert("PermanentHighlightingMode", false); disassemblyBool.insert("PermanentHighlightingMode", false);
disassemblyBool.insert("0xPrefixValues", false);
disassemblyBool.insert("NoCurrentModuleText", false); disassemblyBool.insert("NoCurrentModuleText", false);
defaultBools.insert("Disassembler", disassemblyBool); defaultBools.insert("Disassembler", disassemblyBool);