1
0
Fork 0

Improve disassembler configuration and lifecycle management

Co-authored-by: mr.exodia.tpodt <mr.exodia.tpodt@gmail.com>
This commit is contained in:
Cursor Agent 2025-07-11 18:25:18 +00:00
parent 98291b35b7
commit ad8cc1f4e8
2 changed files with 20 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#include "QZydis.h" #include "QZydis.h"
#include "main.h" #include "main.h"
#include "Exports.h" #include "Exports.h"
#include "Configuration.h"
#include "ReferenceManager.h" #include "ReferenceManager.h"
#include "SymbolView.h" #include "SymbolView.h"
@ -203,7 +204,11 @@ Bridge::Bridge(QObject* parent) : QObject(parent)
mResultEvents[i] = CreateEventW(nullptr, true, true, nullptr); mResultEvents[i] = CreateEventW(nullptr, true, true, nullptr);
mMainThreadId = GetCurrentThreadId(); mMainThreadId = GetCurrentThreadId();
// Initialize QZydis disassembler
mDisasm = new QZydis(int(ConfigUint("Disassembler", "MaxModuleSize")), Bridge::getArchitecture());
connect(this, &Bridge::throttleUpdate, this, &Bridge::throttleUpdateSlot); connect(this, &Bridge::throttleUpdate, this, &Bridge::throttleUpdateSlot);
connect(Config(), SIGNAL(tokenizerConfigUpdated()), this, SLOT(configUpdatedSlot()));
} }
Bridge::~Bridge() Bridge::~Bridge()
@ -211,6 +216,7 @@ Bridge::~Bridge()
EnterCriticalSection(&mCsBridge); EnterCriticalSection(&mCsBridge);
for(size_t i = 0; i < BridgeResult::Last; i++) for(size_t i = 0; i < BridgeResult::Last; i++)
CloseHandle(mResultEvents[i]); CloseHandle(mResultEvents[i]);
delete mDisasm;
DeleteCriticalSection(&mCsBridge); DeleteCriticalSection(&mCsBridge);
} }
@ -276,6 +282,15 @@ void Bridge::setDbgStopped()
mDbgStopped = true; mDbgStopped = true;
} }
void Bridge::configUpdatedSlot()
{
if(mDisasm)
{
mDisasm->UpdateConfig();
mDisasm->UpdateArchitecture();
}
}
/************************************************************************************ /************************************************************************************
Message processing Message processing
************************************************************************************/ ************************************************************************************/
@ -520,13 +535,12 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
{ {
duint parVA = (duint)param1; duint parVA = (duint)param1;
char* text = (char*)param2; char* text = (char*)param2;
if(!text || !parVA || !DbgIsDebugging()) if(!text || !parVA || !DbgIsDebugging() || !mDisasm)
return 0; return 0;
byte_t buffer[16]; byte_t buffer[16];
if(!DbgMemRead(parVA, buffer, 16)) if(!DbgMemRead(parVA, buffer, 16))
return 0; return 0;
QZydis disasm(int(ConfigUint("Disassembler", "MaxModuleSize")), Bridge::getArchitecture()); Instruction_t instr = mDisasm->DisassembleAt(buffer, 16, 0, parVA);
Instruction_t instr = disasm.DisassembleAt(buffer, 16, 0, parVA);
QString finalInstruction; QString finalInstruction;
for(const auto & curToken : instr.tokens.tokens) for(const auto & curToken : instr.tokens.tokens)
finalInstruction += curToken.text; finalInstruction += curToken.text;

View File

@ -18,6 +18,7 @@ namespace Qt
class ReferenceManager; class ReferenceManager;
class SymbolView; class SymbolView;
class QZydis;
class Bridge : public QObject class Bridge : public QObject
{ {
@ -29,6 +30,7 @@ class Bridge : public QObject
private slots: private slots:
void throttleUpdateSlot(GUIMSG msg); void throttleUpdateSlot(GUIMSG msg);
void configUpdatedSlot();
public: public:
explicit Bridge(QObject* parent = nullptr); explicit Bridge(QObject* parent = nullptr);
@ -202,4 +204,5 @@ private:
volatile bool mDbgStopped = false; volatile bool mDbgStopped = false;
QMap<GUIMSG, DWORD> mLastUpdates; QMap<GUIMSG, DWORD> mLastUpdates;
QMap<GUIMSG, QTimer*> mUpdateTimers; QMap<GUIMSG, QTimer*> mUpdateTimers;
QZydis* mDisasm = nullptr;
}; };