GUI: max module size setting
This commit is contained in:
parent
2e77565151
commit
77cc02f8a2
|
@ -21,7 +21,10 @@ Disassembly::Disassembly(QWidget* parent) : AbstractTableView(parent)
|
|||
mHighlightToken.text = "";
|
||||
mHighlightingMode = false;
|
||||
|
||||
mDisasm = new QBeaEngine();
|
||||
int maxModuleSize = (int)ConfigUint("Disassembler", "MaxModuleSize");
|
||||
Config()->writeUints();
|
||||
|
||||
mDisasm = new QBeaEngine(maxModuleSize);
|
||||
|
||||
mIsLastInstDisplayed = false;
|
||||
|
||||
|
|
|
@ -265,9 +265,9 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
|
|||
byte_t wBuffer[16];
|
||||
if(!DbgMemRead(parVA, wBuffer, 16))
|
||||
return 0;
|
||||
QBeaEngine disasm;
|
||||
QBeaEngine disasm(-1);
|
||||
Instruction_t instr = disasm.DisassembleAt(wBuffer, 16, 0, 0, parVA);
|
||||
BeaTokenizer::TokenizeInstruction(&instr.tokens, &instr.disasm);
|
||||
BeaTokenizer::TokenizeInstruction(&instr.tokens, &instr.disasm, -1);
|
||||
QList<RichTextPainter::CustomRichText_t> richText;
|
||||
BeaTokenizer::TokenToRichText(&instr.tokens, &richText, 0);
|
||||
QString finalInstruction = "";
|
||||
|
|
|
@ -172,20 +172,26 @@ void BeaTokenizer::Mnemonic(BeaInstructionToken* instr, const DISASM* disasm)
|
|||
}
|
||||
}
|
||||
|
||||
QString BeaTokenizer::PrintValue(const BeaTokenValue* value, bool module)
|
||||
QString BeaTokenizer::PrintValue(const BeaTokenValue* value, bool module, int maxModuleSize)
|
||||
{
|
||||
char labelText[MAX_LABEL_SIZE] = "";
|
||||
char moduleText[MAX_MODULE_SIZE] = "";
|
||||
char module_[MAX_MODULE_SIZE] = "";
|
||||
QString moduleText;
|
||||
int_t addr = value->value;
|
||||
bool bHasLabel = DbgGetLabelAt(addr, SEG_DEFAULT, labelText);
|
||||
bool bHasModule = (module && DbgGetModuleAt(addr, moduleText) && !QString(labelText).startsWith("JMP.&"));
|
||||
bool bHasModule = (module && DbgGetModuleAt(addr, module_) && !QString(labelText).startsWith("JMP.&"));
|
||||
moduleText = QString(module_);
|
||||
if(maxModuleSize != -1)
|
||||
moduleText.truncate(maxModuleSize);
|
||||
if(moduleText.length())
|
||||
moduleText += ".";
|
||||
QString addrText;
|
||||
addrText = QString("%1").arg(addr & (uint_t) - 1, 0, 16, QChar('0')).toUpper();
|
||||
QString finalText;
|
||||
if(bHasLabel && bHasModule) //<module.label>
|
||||
finalText = QString("<%1.%2>").arg(moduleText).arg(labelText);
|
||||
finalText = QString("<%1%2>").arg(moduleText).arg(labelText);
|
||||
else if(bHasModule) //module.addr
|
||||
finalText = QString("%1.%2").arg(moduleText).arg(addrText);
|
||||
finalText = QString("%1%2").arg(moduleText).arg(addrText);
|
||||
else if(bHasLabel) //<label>
|
||||
finalText = QString("<%1>").arg(labelText);
|
||||
else
|
||||
|
@ -204,7 +210,7 @@ QString BeaTokenizer::RegisterToString(int size, int reg)
|
|||
return currentMap->find(regValue).value();
|
||||
}
|
||||
|
||||
void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, const ARGTYPE* arg, bool* hadarg)
|
||||
void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, const ARGTYPE* arg, bool* hadarg, int maxModuleSize)
|
||||
{
|
||||
if(arg->ArgType == NO_ARGUMENT || !arg->ArgMnemonic[0]) //empty/implicit argument
|
||||
return;
|
||||
|
@ -287,7 +293,7 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
|
|||
BeaTokenType type = TokenValue;
|
||||
if(DbgMemIsValidReadPtr(displacement.value)) //pointer
|
||||
type = TokenAddress;
|
||||
AddToken(instr, type, PrintValue(&printDisplacement, false), &displacement);
|
||||
AddToken(instr, type, PrintValue(&printDisplacement, false, maxModuleSize), &displacement);
|
||||
}
|
||||
AddToken(instr, bracketsType, "]", 0);
|
||||
}
|
||||
|
@ -296,7 +302,7 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
|
|||
BeaTokenValue value;
|
||||
value.size = arg->ArgSize / 8;
|
||||
value.value = disasm->Instruction.AddrValue;
|
||||
AddToken(instr, TokenAddress, PrintValue(&value, true), &value);
|
||||
AddToken(instr, TokenAddress, PrintValue(&value, true, maxModuleSize), &value);
|
||||
}
|
||||
else if((arg->ArgType & CONSTANT_TYPE) == CONSTANT_TYPE) //immediat
|
||||
{
|
||||
|
@ -326,7 +332,7 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
|
|||
BeaTokenType type = TokenValue;
|
||||
if(DbgMemIsValidReadPtr(value.value)) //pointer
|
||||
type = TokenAddress;
|
||||
AddToken(instr, type, PrintValue(&value, true), &value);
|
||||
AddToken(instr, type, PrintValue(&value, true, maxModuleSize), &value);
|
||||
}
|
||||
else if((arg->ArgType & REGISTER_TYPE) == REGISTER_TYPE) //registers
|
||||
{
|
||||
|
@ -527,7 +533,7 @@ unsigned long BeaTokenizer::HashInstruction(const DISASM* disasm)
|
|||
return hash;
|
||||
}
|
||||
|
||||
void BeaTokenizer::TokenizeInstruction(BeaInstructionToken* instr, const DISASM* disasm)
|
||||
void BeaTokenizer::TokenizeInstruction(BeaInstructionToken* instr, const DISASM* disasm, int maxModuleSize)
|
||||
{
|
||||
//initialization
|
||||
instr->hash = HashInstruction(disasm); //hash instruction
|
||||
|
@ -548,18 +554,18 @@ void BeaTokenizer::TokenizeInstruction(BeaInstructionToken* instr, const DISASM*
|
|||
BeaTokenValue val;
|
||||
val.size = 2;
|
||||
val.value = segment;
|
||||
AddToken(instr, TokenValue, PrintValue(&val, true), &val);
|
||||
AddToken(instr, TokenValue, PrintValue(&val, true, maxModuleSize), &val);
|
||||
AddToken(instr, TokenUncategorized, ":", 0);
|
||||
val.size = 4;
|
||||
val.value = address;
|
||||
AddToken(instr, TokenAddress, PrintValue(&val, true), &val);
|
||||
AddToken(instr, TokenAddress, PrintValue(&val, true, maxModuleSize), &val);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool hadarg = false;
|
||||
Argument(instr, disasm, &disasm->Argument1, &hadarg);
|
||||
Argument(instr, disasm, &disasm->Argument2, &hadarg);
|
||||
Argument(instr, disasm, &disasm->Argument3, &hadarg);
|
||||
Argument(instr, disasm, &disasm->Argument1, &hadarg, maxModuleSize);
|
||||
Argument(instr, disasm, &disasm->Argument2, &hadarg, maxModuleSize);
|
||||
Argument(instr, disasm, &disasm->Argument3, &hadarg, maxModuleSize);
|
||||
}
|
||||
|
||||
//remove spaces when needed
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
static void Init();
|
||||
static unsigned long HashInstruction(const DISASM* disasm);
|
||||
static void TokenizeInstruction(BeaInstructionToken* instr, const DISASM* disasm);
|
||||
static void TokenizeInstruction(BeaInstructionToken* instr, const DISASM* disasm, int maxModuleSize);
|
||||
static void TokenToRichText(const BeaInstructionToken* instr, QList<RichTextPainter::CustomRichText_t>* richTextList, const BeaSingleToken* highlightToken);
|
||||
static bool TokenFromX(const BeaInstructionToken* instr, BeaSingleToken* token, int x, int charwidth);
|
||||
static bool IsHighlightableToken(const BeaSingleToken* token);
|
||||
|
@ -99,9 +99,9 @@ private:
|
|||
static void StringInstructionMemory(BeaInstructionToken* instr, int size, QString segment, ARGUMENTS_TYPE reg);
|
||||
static void StringInstruction(QString mnemonic, BeaInstructionToken* instr, const DISASM* disasm);
|
||||
static void Mnemonic(BeaInstructionToken* instr, const DISASM* disasm);
|
||||
static QString PrintValue(const BeaTokenValue* value, bool module);
|
||||
static QString PrintValue(const BeaTokenValue* value, bool module, int maxModuleSize);
|
||||
static QString RegisterToString(int size, int reg);
|
||||
static void Argument(BeaInstructionToken* instr, const DISASM* disasm, const ARGTYPE* arg, bool* hadarg);
|
||||
static void Argument(BeaInstructionToken* instr, const DISASM* disasm, const ARGTYPE* arg, bool* hadarg, int maxModuleSize);
|
||||
static void AddColorName(BeaTokenType type, QString color, QString backgroundColor);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "QBeaEngine.h"
|
||||
|
||||
QBeaEngine::QBeaEngine()
|
||||
QBeaEngine::QBeaEngine(int maxModuleSize)
|
||||
{
|
||||
mMaxModuleSize = maxModuleSize;
|
||||
// Reset the Disasm structure
|
||||
memset(&mDisasmStruct, 0, sizeof(DISASM));
|
||||
BeaTokenizer::Init();
|
||||
|
@ -182,7 +183,7 @@ Instruction_t QBeaEngine::DisassembleAt(byte_t* data, uint_t size, uint_t instIn
|
|||
wInst.disasm = mDisasmStruct;
|
||||
|
||||
//tokenize
|
||||
BeaTokenizer::TokenizeInstruction(&wInst.tokens, &mDisasmStruct);
|
||||
BeaTokenizer::TokenizeInstruction(&wInst.tokens, &mDisasmStruct, mMaxModuleSize);
|
||||
|
||||
return wInst;
|
||||
}
|
||||
|
|
|
@ -18,13 +18,14 @@ typedef struct _Instruction_t
|
|||
class QBeaEngine
|
||||
{
|
||||
public:
|
||||
explicit QBeaEngine();
|
||||
explicit QBeaEngine(int maxModuleSize);
|
||||
ulong DisassembleBack(byte_t* data, uint_t base, uint_t size, uint_t ip, int n);
|
||||
ulong DisassembleNext(byte_t* data, uint_t base, uint_t size, uint_t ip, int n);
|
||||
Instruction_t DisassembleAt(byte_t* data, uint_t size, uint_t instIndex, uint_t origBase, uint_t origInstRVA);
|
||||
|
||||
private:
|
||||
DISASM mDisasmStruct;
|
||||
int mMaxModuleSize;
|
||||
};
|
||||
|
||||
#endif // QBEAENGINE_H
|
||||
|
|
|
@ -917,7 +917,7 @@ void CPUDisassembly::assembleAt()
|
|||
|
||||
mMemPage->read(reinterpret_cast<byte_t*>(wBuffer.data()), wRVA, wMaxByteCountToRead);
|
||||
|
||||
QBeaEngine disasm;
|
||||
QBeaEngine disasm(-1);
|
||||
Instruction_t instr = disasm.DisassembleAt(reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead, 0, 0, wVA);
|
||||
|
||||
QString actual_inst = instr.instStr;
|
||||
|
|
|
@ -170,6 +170,9 @@ Configuration::Configuration() : QObject()
|
|||
QMap<QString, uint_t> hexdumpUint;
|
||||
hexdumpUint.insert("DefaultView", 0);
|
||||
defaultUints.insert("HexDump", hexdumpUint);
|
||||
QMap<QString, uint_t> disasmUint;
|
||||
disasmUint.insert("MaxModuleSize", -1);
|
||||
defaultUints.insert("Disassembler", disasmUint);
|
||||
|
||||
//font settings
|
||||
QFont font("Lucida Console", 8, QFont::Normal, false);
|
||||
|
@ -295,7 +298,6 @@ Configuration* Config()
|
|||
return mPtr;
|
||||
}
|
||||
|
||||
|
||||
void Configuration::load()
|
||||
{
|
||||
readColors();
|
||||
|
|
Loading…
Reference in New Issue