1
0
Fork 0

WIP: new symbol gui mostly working

This commit is contained in:
Duncan Ogilvie 2018-03-20 23:33:59 +01:00
parent 0bb2efcb2c
commit 70b3149599
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
55 changed files with 1545 additions and 1563 deletions

View File

@ -1075,9 +1075,9 @@ BRIDGE_IMPEXP void DbgMenuPrepare(int hMenu)
_dbg_sendmessage(DBG_MENU_PREPARE, (void*)hMenu, nullptr);
}
BRIDGE_IMPEXP void DbgGetSymbolInfo(void* symbol, SYMBOLINFO* info)
BRIDGE_IMPEXP void DbgGetSymbolInfo(const SYMBOLPTR* symbolptr, SYMBOLINFO* info)
{
_dbg_sendmessage(DBG_GET_SYMBOL_INFO, symbol, info);
_dbg_sendmessage(DBG_GET_SYMBOL_INFO, (void*)symbolptr, info);
}
BRIDGE_IMPEXP const char* GuiTranslateText(const char* Source)
@ -1695,9 +1695,9 @@ BRIDGE_IMPEXP void GuiOpenTraceFile(const char* fileName)
_gui_sendmessage(GUI_OPEN_TRACE_FILE, (void*)fileName, nullptr);
}
BRIDGE_IMPEXP void GuiSetModuleSymbols(duint base, ListOf(void*) symbols)
BRIDGE_IMPEXP void GuiInvalidateSymbolSource(duint base)
{
_gui_sendmessage(GUI_SET_MODULE_SYMBOLS, (void*)base, symbols);
_gui_sendmessage(GUI_INVALIDATE_SYMBOL_SOURCE, (void*)base, nullptr);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)

View File

@ -495,12 +495,19 @@ typedef enum
hw_qword
} BPHWSIZE;
typedef enum
{
sym_import,
sym_export,
sym_symbol
} SYMBOLTYPE;
//Debugger typedefs
typedef MEMORY_SIZE VALUE_SIZE;
typedef struct SYMBOLINFO_ SYMBOLINFO;
typedef struct DBGFUNCTIONS_ DBGFUNCTIONS;
typedef void (*CBSYMBOLENUM)(SYMBOLINFO* symbol, void* user);
typedef bool (*CBSYMBOLENUM)(const struct SYMBOLPTR_* symbol, void* user);
//Debugger structs
typedef struct
@ -583,13 +590,15 @@ typedef struct
FUNCTION args;
} BRIDGE_ADDRINFO;
struct SYMBOLINFO_
typedef struct SYMBOLINFO_
{
duint addr;
char* decoratedSymbol;
char* undecoratedSymbol;
bool isImported;
};
SYMBOLTYPE type;
bool freeDecorated;
bool freeUndecorated;
} SYMBOLINFO;
typedef struct
{
@ -889,6 +898,12 @@ typedef struct
XREF_RECORD* references;
} XREF_INFO;
typedef struct SYMBOLPTR_
{
duint modbase;
const void* symbol;
} SYMBOLPTR;
//Debugger functions
BRIDGE_IMPEXP const char* DbgInit();
BRIDGE_IMPEXP void DbgExit();
@ -1013,7 +1028,7 @@ BRIDGE_IMPEXP duint DbgGetTebAddress(DWORD ThreadId);
BRIDGE_IMPEXP bool DbgAnalyzeFunction(duint entry, BridgeCFGraphList* graph);
BRIDGE_IMPEXP duint DbgEval(const char* expression, bool* success = 0);
BRIDGE_IMPEXP void DbgMenuPrepare(int hMenu);
BRIDGE_IMPEXP void DbgGetSymbolInfo(void* symbol, SYMBOLINFO* info);
BRIDGE_IMPEXP void DbgGetSymbolInfo(const SYMBOLPTR* symbolptr, SYMBOLINFO* info);
//Gui defines
#define GUI_PLUGIN_MENU 0
@ -1142,7 +1157,7 @@ typedef enum
GUI_REF_ADDCOMMAND, // param1=const char* title, param2=const char* command
GUI_OPEN_TRACE_FILE, // param1=const char* file name,param2=unused
GUI_UPDATE_TRACE_BROWSER, // param1=unused, param2=unused
GUI_SET_MODULE_SYMBOLS, // param1=duint base, param2=ListOf(void*) symbols
GUI_INVALIDATE_SYMBOL_SOURCE, // param1=duint base, param2=unused
} GUIMSG;
//GUI Typedefs
@ -1319,7 +1334,7 @@ BRIDGE_IMPEXP void GuiFlushLog();
BRIDGE_IMPEXP void GuiReferenceAddCommand(const char* title, const char* command);
BRIDGE_IMPEXP void GuiUpdateTraceBrowser();
BRIDGE_IMPEXP void GuiOpenTraceFile(const char* fileName);
BRIDGE_IMPEXP void GuiSetModuleSymbols(duint base, ListOf(void*) symbols);
BRIDGE_IMPEXP void GuiInvalidateSymbolSource(duint base);
#ifdef __cplusplus
}

View File

@ -403,6 +403,11 @@ static int SymAutoComplete(const char* Search, char** Buffer, int MaxSymbols)
return count;
}
static void _refreshmodulelist()
{
SymRefreshModuleList(fdProcessInfo->hProcess);
}
void dbgfunctionsinit()
{
_dbgfunctions.AssembleAtEx = _assembleatex;
@ -475,4 +480,5 @@ void dbgfunctionsinit()
_dbgfunctions.ModRelocationsInRange = _modrelocationsinrange;
_dbgfunctions.DbGetHash = DbGetHash;
_dbgfunctions.SymAutoComplete = SymAutoComplete;
_dbgfunctions.RefreshModuleList = _refreshmodulelist;
}

View File

@ -197,6 +197,7 @@ typedef bool(*MODRELOCATIONATADDR)(duint addr, DBGRELOCATIONINFO* relocation);
typedef bool(*MODRELOCATIONSINRANGE)(duint addr, duint size, ListOf(DBGRELOCATIONINFO) relocations);
typedef duint(*DBGETHASH)();
typedef int(*SYMAUTOCOMPLETE)(const char* Search, char** Buffer, int MaxSymbols);
typedef void(*REFRESHMODULELIST)();
//The list of all the DbgFunctions() return value.
//WARNING: This list is append only. Do not insert things in the middle or plugins would break.
@ -272,6 +273,7 @@ typedef struct DBGFUNCTIONS_
MODRELOCATIONSINRANGE ModRelocationsInRange;
DBGETHASH DbGetHash;
SYMAUTOCOMPLETE SymAutoComplete;
REFRESHMODULELIST RefreshModuleList;
} DBGFUNCTIONS;
#ifdef BUILD_DBG

View File

@ -96,6 +96,9 @@ extern "C" DLL_EXPORT bool _dbg_isdebugging()
extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
{
if(!hActiveThread)
return false;
unsigned char data[16];
if(MemRead(addr, data, sizeof(data), nullptr, true))
{
@ -200,10 +203,10 @@ static bool getLabel(duint addr, char* label, bool noFuncOffset)
displacement = (DWORD64)symInfo.disp;
//auto name = demanglePE32ExternCFunc(symInfo.decoratedName.c_str());
if(!bUndecorateSymbolNames || !SafeUnDecorateSymbolName(symInfo.decoratedName.c_str(), label, MAX_LABEL_SIZE, UNDNAME_NAME_ONLY))
{
if(bUndecorateSymbolNames && !symInfo.undecoratedName.empty())
strncpy_s(label, MAX_LABEL_SIZE, symInfo.undecoratedName.c_str(), _TRUNCATE);
else
strncpy_s(label, MAX_LABEL_SIZE, symInfo.decoratedName.c_str(), _TRUNCATE);
}
retval = !shouldFilterSymbol(label);
if(retval && displacement)
{
@ -232,10 +235,10 @@ static bool getLabel(duint addr, char* label, bool noFuncOffset)
//pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0';
//auto name = demanglePE32ExternCFunc(pSymbol->Name);
if(!bUndecorateSymbolNames || !SafeUnDecorateSymbolName(symInfo.undecoratedName.c_str(), label, MAX_LABEL_SIZE, UNDNAME_NAME_ONLY))
{
sprintf_s(label, MAX_LABEL_SIZE, "JMP.&%s", symInfo.undecoratedName.c_str());
}
if(bUndecorateSymbolNames && !symInfo.undecoratedName.empty())
_snprintf_s(label, MAX_LABEL_SIZE, _TRUNCATE, "JMP.&%s", symInfo.undecoratedName.c_str());
else
_snprintf_s(label, MAX_LABEL_SIZE, _TRUNCATE, "JMP.&%s", symInfo.decoratedName.c_str());
retval = !shouldFilterSymbol(label);
if(retval && displacement)
{
@ -1475,13 +1478,8 @@ extern "C" DLL_EXPORT duint _dbg_sendmessage(DBGMSG type, void* param1, void* pa
case DBG_GET_SYMBOL_INFO:
{
//TODO: hack^2
auto real = (SymbolInfo*)param1;
auto fake = (SYMBOLINFO*)param2;
fake->addr = real->va;
fake->decoratedSymbol = (char*)real->decoratedName.c_str();
fake->undecoratedSymbol = (char*)real->undecoratedName.c_str();
fake->isImported = strncmp(fake->decoratedSymbol, "__imp_", 6) == 0; //TODO: properly handle this
auto symbolptr = (const SYMBOLPTR*)param1;
((const SymbolInfoGui*)symbolptr->symbol)->convertToGuiSymbol(symbolptr->modbase, (SYMBOLINFO*)param2);
}
break;
}

View File

@ -10,17 +10,34 @@ struct cbSymbolEnumCtx
std::vector<SymbolInfo>* symbols;
};
static void cbSymbolEnum(SYMBOLINFO* info, void* user)
static bool cbSymbolEnum(const SYMBOLPTR* ptr, void* user)
{
auto ctx = (cbSymbolEnumCtx*)user;
SYMBOLINFO info;
DbgGetSymbolInfo(ptr, &info);
SymbolInfo symbol = {};
strncpy_s(symbol.mod, sizeof(symbol.mod), ctx->module->name, sizeof(symbol.mod) - 1);
symbol.rva = info->addr - ctx->module->base;
strncpy_s(symbol.name, sizeof(symbol.name), info->undecoratedSymbol ? info->undecoratedSymbol : info->decoratedSymbol, sizeof(symbol.name) - 1);
symbol.rva = info.addr - ctx->module->base;
strncpy_s(symbol.name, sizeof(symbol.name), info.undecoratedSymbol ? info.undecoratedSymbol : info.decoratedSymbol, sizeof(symbol.name) - 1);
symbol.manual = false;
symbol.type = info->isImported ? Import : Export;
switch(info.type)
{
case sym_import:
symbol.type = Import;
break;
case sym_export:
symbol.type = Export;
break;
case sym_symbol:
symbol.type = Function;
break;
default:
__debugbreak();
}
ctx->symbols->push_back(symbol);
return true;
}
SCRIPT_EXPORT bool Script::Symbol::GetList(ListOf(SymbolInfo) list)
@ -53,7 +70,6 @@ SCRIPT_EXPORT bool Script::Symbol::GetList(ListOf(SymbolInfo) list)
DbgSymbolEnumFromCache(mod.base, cbSymbolEnum, &ctx);
}
//TODO: enumerate actual symbols + virtual symbols (sub_XXXXXX) + imports + exports in addition to user-defined labels.
return BridgeList<SymbolInfo>::CopyData(list, symbols);
}

View File

@ -10,13 +10,13 @@
void SafeDbghelpInitialize();
void SafeDbghelpDeinitialize();
DWORD
/*DWORD
SafeUnDecorateSymbolName(
__in PCSTR name,
__out_ecount(maxStringLength) PSTR outputString,
__in DWORD maxStringLength,
__in DWORD flags
);
);*/
BOOL
SafeSymUnloadModule64(
__in HANDLE hProcess,

View File

@ -115,11 +115,7 @@ public:
if(hFile == INVALID_HANDLE_VALUE)
return HRESULT_FROM_WIN32(GetLastError());
DiaFileStream* out = new DiaFileStream(hFile);
*ppStream = out;
if(*ppStream == NULL)
CloseHandle(hFile);
*ppStream = new DiaFileStream(hFile);
return S_OK;
}
@ -392,25 +388,21 @@ bool PDBDiaFile::open(const wchar_t* file, uint64_t loadAddress, DiaValidationDa
bool PDBDiaFile::isOpen() const
{
return m_session != nullptr && m_dataSource != nullptr;
return m_session != nullptr || m_dataSource != nullptr;
}
bool PDBDiaFile::close()
{
if(m_dataSource == nullptr)
return false;
if(m_session == nullptr)
return false;
m_session->Release();
m_dataSource->Release();
m_session = nullptr;
m_dataSource = nullptr;
if(m_stream != nullptr)
if(m_session)
{
delete(DiaFileStream*)m_stream;
m_stream = nullptr;
m_session->Release();
m_session = nullptr;
}
if(m_dataSource)
{
m_dataSource->Release();
m_dataSource = nullptr;
}
return true;

View File

@ -21,7 +21,7 @@ struct SYMBOLCBDATA
std::vector<char> undecoratedSymbol;
};
static void SymEnumImports(duint Base, CBSYMBOLENUM EnumCallback, SYMBOLCBDATA & cbData)
/*static void SymEnumImports(duint Base, CBSYMBOLENUM EnumCallback, SYMBOLCBDATA & cbData)
{
SYMBOLINFO symbol;
memset(&symbol, 0, sizeof(SYMBOLINFO));
@ -44,7 +44,7 @@ static void SymEnumImports(duint Base, CBSYMBOLENUM EnumCallback, SYMBOLCBDATA &
EnumCallback(&symbol, cbData.user);
});
}
}*/
void SymEnum(duint Base, CBSYMBOLENUM EnumCallback, void* UserData)
{
@ -57,54 +57,44 @@ void SymEnum(duint Base, CBSYMBOLENUM EnumCallback, void* UserData)
{
SHARED_ACQUIRE(LockModules);
MODINFO* modInfo = ModInfoFromAddr(Base);
if(modInfo && modInfo->symbols->isOpen())
if(modInfo)
{
modInfo->symbols->enumSymbols([&cbData, Base](const SymbolInfo & info)
for(size_t i = 0; i < modInfo->exports.size(); i++)
{
cbData.decoratedSymbol[0] = '\0';
cbData.undecoratedSymbol[0] = '\0';
SYMBOLINFO curSymbol;
memset(&curSymbol, 0, sizeof(SYMBOLINFO));
curSymbol.addr = info.va;
curSymbol.decoratedSymbol = cbData.decoratedSymbol.data();
curSymbol.undecoratedSymbol = cbData.undecoratedSymbol.data();
strncpy_s(curSymbol.decoratedSymbol, MAX_SYM_NAME, info.decoratedName.c_str(), _TRUNCATE);
strncpy_s(curSymbol.undecoratedSymbol, MAX_SYM_NAME, info.undecoratedName.c_str(), _TRUNCATE);
// Skip bad ordinals
if(strstr(curSymbol.decoratedSymbol, "Ordinal"))
SYMBOLPTR symbolptr;
symbolptr.modbase = Base;
symbolptr.symbol = &modInfo->exports.at(i);
cbData.cbSymbolEnum(&symbolptr, cbData.user);
}
for(size_t i = 0; i < modInfo->imports.size(); i++)
{
SYMBOLPTR symbolptr;
symbolptr.modbase = Base;
symbolptr.symbol = &modInfo->imports.at(i);
cbData.cbSymbolEnum(&symbolptr, cbData.user);
}
if(modInfo->symbols->isOpen())
{
modInfo->symbols->enumSymbols([&cbData, Base](const SymbolInfo & info)
{
// Does the symbol point to the module base?
if(curSymbol.addr == Base)
return true;
}
// Don't show duplicated decorated/undecorated names
if(info.undecoratedName.empty() || info.decoratedName == info.undecoratedName)
{
curSymbol.undecoratedSymbol = nullptr;
}
// Mark IAT entries as Imports
curSymbol.isImported = strncmp(curSymbol.decoratedSymbol, "__imp_", 6) == 0;
cbData.cbSymbolEnum(&curSymbol, cbData.user);
return true;
});
SYMBOLPTR symbolptr;
symbolptr.modbase = Base;
symbolptr.symbol = &info;
return cbData.cbSymbolEnum(&symbolptr, cbData.user);
});
}
}
}
// Emit pseudo entry point symbol
SYMBOLINFO symbol;
/*SYMBOLINFO symbol;
memset(&symbol, 0, sizeof(SYMBOLINFO));
symbol.decoratedSymbol = "OptionalHeader.AddressOfEntryPoint";
symbol.addr = ModEntryFromAddr(Base);
if(symbol.addr)
EnumCallback(&symbol, UserData);
SymEnumImports(Base, EnumCallback, cbData);
SymEnumImports(Base, EnumCallback, cbData);*/
}
void SymEnumFromCache(duint Base, CBSYMBOLENUM EnumCallback, void* UserData)
@ -319,7 +309,7 @@ bool SymAddrFromName(const char* Name, duint* Address)
SymbolInfo symInfo;
if(modInfo->symbols->findSymbolByName(name, symInfo, true))
{
*Address = symInfo.va;
*Address = base + symInfo.rva;
return true;
}
}

View File

@ -7,19 +7,33 @@
#include <vector>
#include <functional>
struct SymbolInfo
struct SymbolInfoGui
{
duint va;
virtual void convertToGuiSymbol(duint base, SYMBOLINFO* info) const = 0;
};
struct SymbolInfo : SymbolInfoGui
{
duint rva;
duint size;
int32 disp;
String decoratedName;
String undecoratedName;
bool publicSymbol;
void convertToGuiSymbol(duint modbase, SYMBOLINFO* info) const override
{
info->addr = modbase + this->rva;
info->decoratedSymbol = (char*)this->decoratedName.c_str();
info->undecoratedSymbol = (char*)this->undecoratedName.c_str();
info->type = sym_symbol;
info->freeDecorated = info->freeUndecorated = false;
}
};
struct LineInfo
{
duint addr;
duint rva;
duint size;
duint disp;
int lineNumber;
@ -89,6 +103,7 @@ public:
return false; // Stub
}
// only call if isOpen && !isLoading
virtual void enumSymbols(const CbEnumSymbol & cbEnum)
{
// Stub

View File

@ -15,6 +15,8 @@ SymbolSourceDIA::SymbolSourceDIA()
SymbolSourceDIA::~SymbolSourceDIA()
{
SymbolSourceDIA::cancelLoading();
if(_imageBase)
GuiInvalidateSymbolSource(_imageBase);
}
static void SetWin10ThreadDescription(HANDLE threadHandle, const WString & name)
@ -51,6 +53,7 @@ bool SymbolSourceDIA::loadPDB(const std::string & path, duint imageBase, duint i
_imageSize = imageSize;
_imageBase = imageBase;
_requiresShutdown = false;
_symbolsLoaded = false;
_loadCounter.store(2);
_symbolsThread = CreateThread(nullptr, 0, SymbolsThread, this, CREATE_SUSPENDED, nullptr);
SetWin10ThreadDescription(_symbolsThread, L"SymbolsThread");
@ -80,11 +83,13 @@ bool SymbolSourceDIA::cancelLoading()
{
WaitForSingleObject(_symbolsThread, INFINITE);
CloseHandle(_symbolsThread);
_symbolsThread = nullptr;
}
if(_sourceLinesThread)
{
WaitForSingleObject(_sourceLinesThread, INFINITE);
CloseHandle(_sourceLinesThread);
_sourceLinesThread = nullptr;
}
return true;
}
@ -93,6 +98,12 @@ void SymbolSourceDIA::loadPDBAsync()
{
}
template<size_t Count>
static bool startsWith(const char* str, const char(&prefix)[Count])
{
return strncmp(str, prefix, Count - 1) == 0;
}
bool SymbolSourceDIA::loadSymbolsAsync()
{
ScopedDecrement ref(_loadCounter);
@ -115,6 +126,17 @@ bool SymbolSourceDIA::loadSymbolsAsync()
if(_requiresShutdown)
return false;
if(sym.name.c_str()[0] == 0x7F)
return true;
#define filter(prefix) if(startsWith(sym.name.c_str(), prefix)) return true
filter("__imp__");
filter("__imp_?");
filter("_imp___");
filter("__NULL_IMPORT_DESCRIPTOR");
filter("__IMPORT_DESCRIPTOR_");
#undef filter
if(sym.type == DiaSymbolType::PUBLIC ||
sym.type == DiaSymbolType::FUNCTION ||
sym.type == DiaSymbolType::LABEL ||
@ -125,7 +147,7 @@ bool SymbolSourceDIA::loadSymbolsAsync()
symInfo.undecoratedName = sym.undecoratedName;
symInfo.size = sym.size;
symInfo.disp = sym.disp;
symInfo.va = _imageBase + sym.virtualAddress;
symInfo.rva = sym.virtualAddress;
symInfo.publicSymbol = sym.publicSymbol;
// Check if we already have it inside, private symbols have priority over public symbols.
@ -193,6 +215,7 @@ bool SymbolSourceDIA::loadSymbolsAsync()
_symNameMap[i] = nameIndex;
}
std::sort(_symNameMap.begin(), _symNameMap.end());
_symbolsLoaded = true;
}
DWORD ms = GetTickCount() - loadStart;
@ -200,17 +223,7 @@ bool SymbolSourceDIA::loadSymbolsAsync()
GuiSymbolLogAdd(StringUtils::sprintf("[%p] Loaded %d symbols in %.03fs\n", _imageBase, _symAddrs.size(), secs).c_str());
//TODO: make beautiful
ListInfo blub;
blub.count = _symAddrs.size();
blub.size = blub.count * sizeof(void*);
std::vector<SymbolInfo*> fuck;
fuck.resize(_symAddrs.size());
size_t i = 0;
for(auto it = _symAddrs.begin(); it != _symAddrs.end(); ++it)
fuck[i++] = &_symData[it->second];
blub.data = fuck.data();
GuiSetModuleSymbols(_imageBase, &blub);
GuiInvalidateSymbolSource(_imageBase);
GuiUpdateAllViews();
@ -345,7 +358,7 @@ bool SymbolSourceDIA::findSymbolExactOrLower(duint rva, SymbolInfo & symInfo)
if(it != _symAddrs.end())
{
symInfo = _symData[it->second];
symInfo.disp = (int32_t)(rva - (symInfo.va - _imageBase));
symInfo.disp = (int32_t)(rva - symInfo.rva);
return true;
}
@ -355,6 +368,8 @@ bool SymbolSourceDIA::findSymbolExactOrLower(duint rva, SymbolInfo & symInfo)
void SymbolSourceDIA::enumSymbols(const CbEnumSymbol & cbEnum)
{
ScopedSpinLock lock(_lockSymbols);
if(!_symbolsLoaded)
return;
for(auto & it : _symAddrs)
{
@ -399,6 +414,8 @@ ForwardIt binary_find(ForwardIt first, ForwardIt last, const T & value, Compare
bool SymbolSourceDIA::findSymbolByName(const std::string & name, SymbolInfo & symInfo, bool caseSensitive)
{
ScopedSpinLock lock(_lockSymbols);
if(!_symbolsLoaded)
return false;
NameIndex find;
find.name = name.c_str();
@ -440,6 +457,8 @@ bool SymbolSourceDIA::findSymbolsByPrefix(const std::string & prefix, const std:
} prefixCmp(prefix.size());
ScopedSpinLock lock(_lockSymbols);
if(!_symbolsLoaded)
return false;
NameIndex find;
find.name = prefix.c_str();

View File

@ -102,6 +102,7 @@ private:
duint _imageBase;
duint _imageSize;
SpinLock _lockSymbols;
bool _symbolsLoaded = false;
SpinLock _lockLines;
private:

View File

@ -39,7 +39,7 @@ bool SymbolFromAddressExact(duint address, SymbolInfo & symInfo)
if(found != modInfo->exportsByRva.end())
{
auto & modExport = modInfo->exports.at(*found);
symInfo.va = modExport.rva + modInfo->base;
symInfo.rva = modExport.rva;
symInfo.size = 0;
symInfo.disp = 0;
symInfo.decoratedName = modExport.name;

View File

@ -0,0 +1,61 @@
#ifndef ABSTRACTSEARCHLIST_H
#define ABSTRACTSEARCHLIST_H
#include "AbstractStdTable.h"
class AbstractSearchList
{
public:
enum FilterType
{
FilterStartsWithTextCaseSensitive, //unused
FilterStartsWithTextCaseInsensitive, //unused
FilterContainsTextCaseSensitive, //unused
FilterContainsTextCaseInsensitive,
FilterRegexCaseSensitive,
FilterRegexCaseInsensitive
};
virtual void lock() = 0;
virtual void unlock() = 0;
virtual AbstractStdTable* list() const = 0;
virtual AbstractStdTable* searchList() const = 0;
virtual void filter(const QString & filter, FilterType type, int startColumn) = 0;
bool rowMatchesFilter(const QString & filter, FilterType type, int row, int startColumn) const
{
int count = list()->getColumnCount();
if(startColumn + 1 > count)
return false;
auto cs = Qt::CaseInsensitive;
switch(type)
{
case FilterStartsWithTextCaseSensitive:
cs = Qt::CaseSensitive;
case FilterStartsWithTextCaseInsensitive:
for(int i = startColumn; i < count; i++)
if(list()->getCellContent(row, i).startsWith(filter, cs))
return true;
break;
case FilterContainsTextCaseSensitive:
cs = Qt::CaseSensitive;
case FilterContainsTextCaseInsensitive:
for(int i = startColumn; i < count; i++)
if(list()->getCellContent(row, i).contains(filter, cs))
return true;
break;
case FilterRegexCaseSensitive:
cs = Qt::CaseSensitive;
case FilterRegexCaseInsensitive:
for(int i = startColumn; i < count; i++)
if(list()->getCellContent(row, i).contains(QRegExp(filter, cs)))
return true;
break;
default:
__debugbreak();
}
return false;
}
};
#endif // ABSTRACTSEARCHLIST_H

View File

@ -1,5 +1,6 @@
#include "AbstractStdTable.h"
#include "Bridge.h"
#include "RichTextPainter.h"
AbstractStdTable::AbstractStdTable(QWidget* parent) : AbstractTableView(parent)
{
@ -12,9 +13,291 @@ AbstractStdTable::AbstractStdTable(QWidget* parent) : AbstractTableView(parent)
QString AbstractStdTable::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h)
{
if(isSelected(rowBase, rowOffset))
painter->fillRect(QRect(x, y, w, h), QBrush(selectionColor));
return getCellContent(rowBase + rowOffset, col);
bool isaddr = DbgIsDebugging() && getRowCount() > 0 && col == mAddressColumn;
bool wIsSelected = isSelected(rowBase, rowOffset);
QString text = getCellContent(rowBase + rowOffset, col);
duint wVA = isaddr ? duint(text.toULongLong(&isaddr, 16)) : 0;
auto wIsTraced = isaddr && DbgFunctions()->GetTraceRecordHitCount(wVA) != 0;
QColor lineBackgroundColor;
bool isBackgroundColorSet;
if(wIsSelected && wIsTraced)
{
lineBackgroundColor = mTracedSelectedAddressBackgroundColor;
isBackgroundColorSet = true;
}
else if(wIsSelected)
{
lineBackgroundColor = mSelectionColor;
isBackgroundColorSet = true;
}
else if(wIsTraced)
{
lineBackgroundColor = mTracedBackgroundColor;
isBackgroundColorSet = true;
}
else
{
isBackgroundColorSet = false;
}
if(isBackgroundColorSet)
painter->fillRect(QRect(x, y, w, h), QBrush(lineBackgroundColor));
if(col == mAddressColumn && isaddr)
{
char label[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(wVA, SEG_DEFAULT, label)) //has label
{
char module[MAX_MODULE_SIZE] = "";
if(DbgGetModuleAt(wVA, module) && !QString(label).startsWith("JMP.&"))
text += " <" + QString(module) + "." + QString(label) + ">";
else
text += " <" + QString(label) + ">";
}
BPXTYPE bpxtype = DbgGetBpxTypeAt(wVA);
bool isbookmark = DbgGetBookmarkAt(wVA);
duint cip = Bridge::getBridge()->mLastCip;
if(bCipBase)
{
duint base = DbgFunctions()->ModBaseFromAddr(cip);
if(base)
cip = base;
}
if(DbgIsDebugging() && wVA == cip) //cip + not running
{
painter->fillRect(QRect(x, y, w, h), QBrush(mCipBackgroundColor));
if(!isbookmark) //no bookmark
{
if(bpxtype & bp_normal) //normal breakpoint
{
QColor & bpColor = mBreakpointBackgroundColor;
if(!bpColor.alpha()) //we don't want transparent text
bpColor = mBreakpointColor;
if(bpColor == mCipBackgroundColor)
bpColor = mCipColor;
painter->setPen(bpColor);
}
else if(bpxtype & bp_hardware) //hardware breakpoint only
{
QColor hwbpColor = mHardwareBreakpointBackgroundColor;
if(!hwbpColor.alpha()) //we don't want transparent text
hwbpColor = mHardwareBreakpointColor;
if(hwbpColor == mCipBackgroundColor)
hwbpColor = mCipColor;
painter->setPen(hwbpColor);
}
else //no breakpoint
{
painter->setPen(mCipColor);
}
}
else //bookmark
{
QColor bookmarkColor = mBookmarkBackgroundColor;
if(!bookmarkColor.alpha()) //we don't want transparent text
bookmarkColor = mBookmarkColor;
if(bookmarkColor == mCipBackgroundColor)
bookmarkColor = mCipColor;
painter->setPen(bookmarkColor);
}
}
else //non-cip address
{
if(!isbookmark) //no bookmark
{
if(*label) //label
{
if(bpxtype == bp_none) //label only : fill label background
{
painter->setPen(mLabelColor); //red -> address + label text
painter->fillRect(QRect(x, y, w, h), QBrush(mLabelBackgroundColor)); //fill label background
}
else //label + breakpoint
{
if(bpxtype & bp_normal) //label + normal breakpoint
{
painter->setPen(mBreakpointColor);
painter->fillRect(QRect(x, y, w, h), QBrush(mBreakpointBackgroundColor)); //fill red
}
else if(bpxtype & bp_hardware) //label + hardware breakpoint only
{
painter->setPen(mHardwareBreakpointColor);
painter->fillRect(QRect(x, y, w, h), QBrush(mHardwareBreakpointBackgroundColor)); //fill ?
}
else //other cases -> do as normal
{
painter->setPen(mLabelColor); //red -> address + label text
painter->fillRect(QRect(x, y, w, h), QBrush(mLabelBackgroundColor)); //fill label background
}
}
}
else //no label
{
if(bpxtype == bp_none) //no label, no breakpoint
{
QColor background;
if(wIsSelected)
{
background = mSelectedAddressBackgroundColor;
painter->setPen(mSelectedAddressColor); //black address (DisassemblySelectedAddressColor)
}
else
{
background = mAddressBackgroundColor;
painter->setPen(mAddressColor); //DisassemblyAddressColor
}
if(background.alpha())
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background
}
else //breakpoint only
{
if(bpxtype & bp_normal) //normal breakpoint
{
painter->setPen(mBreakpointColor);
painter->fillRect(QRect(x, y, w, h), QBrush(mBreakpointBackgroundColor)); //fill red
}
else if(bpxtype & bp_hardware) //hardware breakpoint only
{
painter->setPen(mHardwareBreakpointColor);
painter->fillRect(QRect(x, y, w, h), QBrush(mHardwareBreakpointBackgroundColor)); //fill red
}
else //other cases (memory breakpoint in disassembly) -> do as normal
{
QColor background;
if(wIsSelected)
{
background = mSelectedAddressBackgroundColor;
painter->setPen(mSelectedAddressColor); //black address (DisassemblySelectedAddressColor)
}
else
{
background = mAddressBackgroundColor;
painter->setPen(mAddressColor);
}
if(background.alpha())
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background
}
}
}
}
else //bookmark
{
if(*label) //label + bookmark
{
if(bpxtype == bp_none) //label + bookmark
{
painter->setPen(mLabelColor); //red -> address + label text
painter->fillRect(QRect(x, y, w, h), QBrush(mBookmarkBackgroundColor)); //fill label background
}
else //label + breakpoint + bookmark
{
QColor color = mBookmarkBackgroundColor;
if(!color.alpha()) //we don't want transparent text
color = mAddressColor;
painter->setPen(color);
if(bpxtype & bp_normal) //label + bookmark + normal breakpoint
{
painter->fillRect(QRect(x, y, w, h), QBrush(mBreakpointBackgroundColor)); //fill red
}
else if(bpxtype & bp_hardware) //label + bookmark + hardware breakpoint only
{
painter->fillRect(QRect(x, y, w, h), QBrush(mHardwareBreakpointBackgroundColor)); //fill ?
}
}
}
else //bookmark, no label
{
if(bpxtype == bp_none) //bookmark only
{
painter->setPen(mBookmarkColor); //black address
painter->fillRect(QRect(x, y, w, h), QBrush(mBookmarkBackgroundColor)); //fill bookmark color
}
else //bookmark + breakpoint
{
QColor color = mBookmarkBackgroundColor;
if(!color.alpha()) //we don't want transparent text
color = mAddressColor;
painter->setPen(color);
if(bpxtype & bp_normal) //bookmark + normal breakpoint
{
painter->fillRect(QRect(x, y, w, h), QBrush(mBreakpointBackgroundColor)); //fill red
}
else if(bpxtype & bp_hardware) //bookmark + hardware breakpoint only
{
painter->fillRect(QRect(x, y, w, h), QBrush(mHardwareBreakpointBackgroundColor)); //fill red
}
else //other cases (bookmark + memory breakpoint in disassembly) -> do as normal
{
painter->setPen(mBookmarkColor); //black address
painter->fillRect(QRect(x, y, w, h), QBrush(mBookmarkBackgroundColor)); //fill bookmark color
}
}
}
}
}
painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, text);
text = "";
}
else if(mHighlightText.length() && text.contains(mHighlightText, Qt::CaseInsensitive)) // TODO: case sensitive + regex highlighting
{
//super smart way of splitting while keeping the delimiters (thanks to cypher for guidance)
int index = -2;
do
{
index = text.indexOf(mHighlightText, index + 2, Qt::CaseInsensitive);
if(index != -1)
{
text = text.insert(index + mHighlightText.length(), QChar('\1'));
text = text.insert(index, QChar('\1'));
}
}
while(index != -1);
QStringList split = text.split(QChar('\1'), QString::SkipEmptyParts, Qt::CaseInsensitive);
//create rich text list
RichTextPainter::CustomRichText_t curRichText;
curRichText.flags = RichTextPainter::FlagColor;
curRichText.textColor = mTextColor;
curRichText.highlightColor = ConfigColor("SearchListViewHighlightColor");
RichTextPainter::List richText;
foreach(QString str, split)
{
curRichText.text = str;
curRichText.highlight = !str.compare(mHighlightText, Qt::CaseInsensitive);
richText.push_back(curRichText);
}
//paint the rich text
RichTextPainter::paintRichText(painter, x + 1, y, w, h, 4, richText, mFontMetrics);
text = "";
}
return text;
}
void AbstractStdTable::updateColors()
{
AbstractTableView::updateColors();
mCipBackgroundColor = ConfigColor("DisassemblyCipBackgroundColor");
mCipColor = ConfigColor("DisassemblyCipColor");
mBreakpointBackgroundColor = ConfigColor("DisassemblyBreakpointBackgroundColor");
mBreakpointColor = ConfigColor("DisassemblyBreakpointColor");
mHardwareBreakpointBackgroundColor = ConfigColor("DisassemblyHardwareBreakpointBackgroundColor");
mHardwareBreakpointColor = ConfigColor("DisassemblyHardwareBreakpointColor");
mBookmarkBackgroundColor = ConfigColor("DisassemblyBookmarkBackgroundColor");
mBookmarkColor = ConfigColor("DisassemblyBookmarkColor");
mLabelColor = ConfigColor("DisassemblyLabelColor");
mLabelBackgroundColor = ConfigColor("DisassemblyLabelBackgroundColor");
mSelectedAddressBackgroundColor = ConfigColor("DisassemblySelectedAddressBackgroundColor");
mSelectedAddressColor = ConfigColor("DisassemblySelectedAddressColor");
mAddressBackgroundColor = ConfigColor("DisassemblyAddressBackgroundColor");
mAddressColor = ConfigColor("DisassemblyAddressColor");
mTracedBackgroundColor = ConfigColor("DisassemblyTracedBackgroundColor");
auto a = mSelectionColor, b = mTracedBackgroundColor;
mTracedSelectedAddressBackgroundColor = QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2, (a.blue() + b.blue()) / 2);
}
void AbstractStdTable::mouseMoveEvent(QMouseEvent* event)

View File

@ -7,8 +7,9 @@ class AbstractStdTable : public AbstractTableView
Q_OBJECT
public:
explicit AbstractStdTable(QWidget* parent = 0);
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
void reloadData();
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) override;
void updateColors() override;
void reloadData() override;
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
@ -49,6 +50,18 @@ public:
void setupCopyMenu(MenuBuilder* copyMenu);
void setCopyMenuOnly(bool bSet, bool bDebugOnly = true);
//draw helpers
void setHighlightText(QString highlightText)
{
mHighlightText = highlightText;
}
void setAddressColumn(int col, bool cipBase = false)
{
mAddressColumn = col;
bCipBase = cipBase;
}
signals:
void selectionChangedSignal(int index);
void keyPressedSignal(QKeyEvent* event);
@ -69,12 +82,14 @@ public slots:
protected:
QString copyTable(const std::vector<int> & colWidths);
struct
struct SelectionData
{
int firstSelectedIndex = 0;
int fromIndex = 0;
int toIndex = 0;
} mSelection;
};
SelectionData mSelection;
enum
{
@ -94,4 +109,24 @@ protected:
int column = -1;
bool ascending = true;
} mSort;
QColor mCipBackgroundColor;
QColor mCipColor;
QColor mBreakpointBackgroundColor;
QColor mBreakpointColor;
QColor mHardwareBreakpointBackgroundColor;
QColor mHardwareBreakpointColor;
QColor mBookmarkBackgroundColor;
QColor mBookmarkColor;
QColor mLabelColor;
QColor mLabelBackgroundColor;
QColor mSelectedAddressBackgroundColor;
QColor mSelectedAddressColor;
QColor mAddressBackgroundColor;
QColor mAddressColor;
QColor mTracedBackgroundColor;
QColor mTracedSelectedAddressBackgroundColor;
bool bCipBase;
QString mHighlightText;
int mAddressColumn = -1;
};

View File

@ -33,7 +33,7 @@ AbstractTableView::AbstractTableView(QWidget* parent)
// Class variable initialization
mTableOffset = 0;
mPrevTableOffset = mTableOffset + 1;
Header_t data;
Header data;
data.isVisible = true;
data.height = 20;
data.activeButtonIndex = -1;
@ -89,9 +89,9 @@ AbstractTableView::AbstractTableView(QWidget* parent)
// Slots
connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(vertSliderActionSlot(int)));
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(slot_updateColors()));
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(slot_updateFonts()));
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(slot_updateShortcuts()));
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateColorsSlot()));
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateFontsSlot()));
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(updateShortcutsSlot()));
// todo: try Qt::QueuedConnection to init
Initialize();
@ -101,7 +101,7 @@ AbstractTableView::~AbstractTableView()
{
}
void AbstractTableView::slot_close()
void AbstractTableView::closeSlot()
{
if(ConfigBool("Gui", "SaveColumnOrder"))
saveColumnToConfig();
@ -124,11 +124,11 @@ void AbstractTableView::Initialize()
void AbstractTableView::updateColors()
{
backgroundColor = ConfigColor("AbstractTableViewBackgroundColor");
textColor = ConfigColor("AbstractTableViewTextColor");
separatorColor = ConfigColor("AbstractTableViewSeparatorColor");
headerTextColor = ConfigColor("AbstractTableViewHeaderTextColor");
selectionColor = ConfigColor("AbstractTableViewSelectionColor");
mBackgroundColor = ConfigColor("AbstractTableViewBackgroundColor");
mTextColor = ConfigColor("AbstractTableViewTextColor");
mSeparatorColor = ConfigColor("AbstractTableViewSeparatorColor");
mHeaderTextColor = ConfigColor("AbstractTableViewHeaderTextColor");
mSelectionColor = ConfigColor("AbstractTableViewSelectionColor");
}
void AbstractTableView::updateFonts()
@ -144,17 +144,17 @@ void AbstractTableView::invalidateCachedFont()
mFontMetrics = new CachedFontMetrics(this, font());
}
void AbstractTableView::slot_updateColors()
void AbstractTableView::updateColorsSlot()
{
updateColors();
}
void AbstractTableView::slot_updateFonts()
void AbstractTableView::updateFontsSlot()
{
updateFonts();
}
void AbstractTableView::slot_updateShortcuts()
void AbstractTableView::updateShortcutsSlot()
{
updateShortcuts();
}
@ -175,7 +175,7 @@ void AbstractTableView::loadColumnFromConfig(const QString & viewName)
mColumnOrder[i] = order - 1;
}
mViewName = viewName;
connect(Bridge::getBridge(), SIGNAL(close()), this, SLOT(slot_close()));
connect(Bridge::getBridge(), SIGNAL(close()), this, SLOT(closeSlot()));
}
void AbstractTableView::saveColumnToConfig()
@ -257,7 +257,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
}
// Paints background
wPainter.fillRect(wPainter.viewport(), QBrush(backgroundColor));
wPainter.fillRect(wPainter.viewport(), QBrush(mBackgroundColor));
// Paints header
if(mHeader.isVisible == true)
@ -279,7 +279,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
mHeaderButtonSytle.style()->drawControl(QStyle::CE_PushButton, &wOpt, &wPainter, &mHeaderButtonSytle);
wPainter.setPen(headerTextColor);
wPainter.setPen(mHeaderTextColor);
wPainter.drawText(QRect(x + 4, y, width - 8, getHeaderHeight()), Qt::AlignVCenter | Qt::AlignLeft, mColumnList[i].title);
x += width;
@ -308,7 +308,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
if(wStr.length())
{
wPainter.setPen(textColor);
wPainter.setPen(mTextColor);
wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
}
}
@ -317,7 +317,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
if(getColumnCount() > 1)
{
// Paints cell right borders
wPainter.setPen(separatorColor);
wPainter.setPen(mSeparatorColor);
wPainter.drawLine(x + getColumnWidth(j) - 1, y, x + getColumnWidth(j) - 1, y + getRowHeight() - 1);
}
@ -810,7 +810,8 @@ dsint AbstractTableView::scaleFromScrollBarRangeToUint64(int value)
*/
void AbstractTableView::updateScrollBarRange(dsint range)
{
dsint wMax = range - getViewableRowsCount() + 1;
int viewableRowsCount = getViewableRowsCount();
dsint wMax = range - viewableRowsCount + 1;
if(wMax > 0)
{
@ -850,7 +851,9 @@ void AbstractTableView::updateScrollBarRange(dsint range)
else
verticalScrollBar()->setRange(0, 0);
verticalScrollBar()->setSingleStep(getRowHeight());
verticalScrollBar()->setPageStep(getViewableRowsCount() * getRowHeight());
verticalScrollBar()->setPageStep(viewableRowsCount * getRowHeight());
emit viewableRowsChanged(viewableRowsCount);
}
/************************************************************************************
@ -863,7 +866,7 @@ void AbstractTableView::updateScrollBarRange(dsint range)
*
* @return row index offset.
*/
int AbstractTableView::getIndexOffsetFromY(int y)
int AbstractTableView::getIndexOffsetFromY(int y) const
{
return (y / getRowHeight());
}
@ -875,7 +878,7 @@ int AbstractTableView::getIndexOffsetFromY(int y)
*
* @return Column index.
*/
int AbstractTableView::getColumnIndexFromX(int x)
int AbstractTableView::getColumnIndexFromX(int x) const
{
int wX = -horizontalScrollBar()->value();
int wColIndex = 0;
@ -943,7 +946,7 @@ int AbstractTableView::getColumnDisplayIndexFromX(int x)
*
* @return X coordinate of the column index.
*/
int AbstractTableView::getColumnPosition(int index)
int AbstractTableView::getColumnPosition(int index) const
{
int posX = -horizontalScrollBar()->value();
@ -967,7 +970,7 @@ int AbstractTableView::getColumnPosition(int index)
*
* @return y - getHeaderHeight().
*/
int AbstractTableView::transY(int y)
int AbstractTableView::transY(int y) const
{
return y - getHeaderHeight();
}
@ -977,14 +980,13 @@ int AbstractTableView::transY(int y)
*
* @return Number of viewable rows.
*/
int AbstractTableView::getViewableRowsCount()
int AbstractTableView::getViewableRowsCount() const
{
int wTableHeight = this->viewport()->height() - getHeaderHeight();
int wCount = wTableHeight / getRowHeight();
wCount += (wTableHeight % getRowHeight()) > 0 ? 1 : 0;
emit viewableRows(wCount);
return wCount;
}
@ -993,7 +995,7 @@ int AbstractTableView::getViewableRowsCount()
*
* @return Number of remaining lines to print.
*/
int AbstractTableView::getLineToPrintcount()
int AbstractTableView::getLineToPrintcount() const
{
int wViewableRowsCount = getViewableRowsCount();
dsint wRemainingRowsCount = getRowCount() - mTableOffset;
@ -1013,8 +1015,8 @@ int AbstractTableView::getLineToPrintcount()
*/
void AbstractTableView::addColumnAt(int width, const QString & title, bool isClickable)
{
HeaderButton_t wHeaderButton;
Column_t wColumn;
HeaderButton wHeaderButton;
Column wColumn;
int wCurrentCount;
// Fix invisible columns near the edge of the screen
@ -1052,13 +1054,13 @@ void AbstractTableView::setColTitle(int index, const QString & title)
{
if(mColumnList.size() > 0 && index >= 0 && index < mColumnList.size())
{
Column_t wColum = mColumnList.takeAt(index);
wColum.title = title;
mColumnList.insert(index - 1, wColum);
Column wColumn = mColumnList.takeAt(index);
wColumn.title = title;
mColumnList.insert(index - 1, wColumn);
}
}
QString AbstractTableView::getColTitle(int index)
QString AbstractTableView::getColTitle(int index) const
{
if(mColumnList.size() > 0 && index >= 0 && index < mColumnList.size())
return mColumnList[index].title;
@ -1078,12 +1080,12 @@ int AbstractTableView::getColumnCount() const
return mColumnList.size();
}
int AbstractTableView::getRowHeight()
int AbstractTableView::getRowHeight() const
{
return mFontMetrics->height() | 1;
}
int AbstractTableView::getColumnWidth(int index)
int AbstractTableView::getColumnWidth(int index) const
{
if(index < 0)
return -1;
@ -1092,7 +1094,7 @@ int AbstractTableView::getColumnWidth(int index)
return 0;
}
bool AbstractTableView::getColumnHidden(int col)
bool AbstractTableView::getColumnHidden(int col) const
{
if(col < 0)
return true;
@ -1128,12 +1130,12 @@ void AbstractTableView::setColumnOrder(int pos, int index)
mColumnOrder[pos] = index - 1;
}
int AbstractTableView::getColumnOrder(int index)
int AbstractTableView::getColumnOrder(int index) const
{
return mColumnOrder[index] + 1;
}
int AbstractTableView::getHeaderHeight()
int AbstractTableView::getHeaderHeight() const
{
if(mHeader.isVisible == true)
return mHeader.height;
@ -1141,17 +1143,17 @@ int AbstractTableView::getHeaderHeight()
return 0;
}
int AbstractTableView::getTableHeight()
int AbstractTableView::getTableHeight() const
{
return this->viewport()->height() - getHeaderHeight();
}
int AbstractTableView::getGuiState()
int AbstractTableView::getGuiState() const
{
return mGuiState;
}
int AbstractTableView::getNbrOfLineToPrint()
int AbstractTableView::getNbrOfLineToPrint() const
{
return mNbrOfLineToPrint;
}
@ -1166,7 +1168,7 @@ void AbstractTableView::setShowHeader(bool show)
mHeader.isVisible = show;
}
int AbstractTableView::getCharWidth()
int AbstractTableView::getCharWidth() const
{
return QFontMetrics(this->font()).width(QChar(' '));
}
@ -1175,7 +1177,7 @@ int AbstractTableView::getCharWidth()
Content drawing control
************************************************************************************/
bool AbstractTableView::getDrawDebugOnly()
bool AbstractTableView::getDrawDebugOnly() const
{
return mDrawDebugOnly;
}
@ -1185,10 +1187,20 @@ void AbstractTableView::setDrawDebugOnly(bool value)
mDrawDebugOnly = value;
}
void AbstractTableView::setAllowPainting(bool allow)
{
mAllowPainting = allow;
}
bool AbstractTableView::getAllowPainting() const
{
return mAllowPainting;
}
/************************************************************************************
Table offset management
************************************************************************************/
dsint AbstractTableView::getTableOffset()
dsint AbstractTableView::getTableOffset() const
{
return mTableOffset;
}

View File

@ -21,9 +21,9 @@ class AbstractTableScrollBar : public QScrollBar
{
Q_OBJECT
public:
AbstractTableScrollBar(QScrollBar* scrollbar);
void enterEvent(QEvent* event);
void leaveEvent(QEvent* event);
explicit AbstractTableScrollBar(QScrollBar* scrollbar);
void enterEvent(QEvent* event) override;
void leaveEvent(QEvent* event) override;
};
class AbstractTableView;
@ -32,11 +32,18 @@ class AbstractTableView : public QAbstractScrollArea, public ActionHelper<Abstra
Q_OBJECT
public:
enum GuiState_t {NoState, ReadyToResize, ResizeColumnState, HeaderButtonPressed, HeaderButtonReordering};
enum GuiState
{
NoState,
ReadyToResize,
ResizeColumnState,
HeaderButtonPressed,
HeaderButtonReordering
};
// Constructor
explicit AbstractTableView(QWidget* parent = 0);
~AbstractTableView();
virtual ~AbstractTableView();
// Configuration
virtual void Initialize();
@ -47,16 +54,16 @@ public:
virtual QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) = 0;
// Painting Stuff
void paintEvent(QPaintEvent* event);
void paintEvent(QPaintEvent* event) override;
// Mouse Management
void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent* event);
void resizeEvent(QResizeEvent* event);
void keyPressEvent(QKeyEvent* event);
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void mouseDoubleClickEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
// ScrollBar Management
virtual dsint sliderMovedHook(int type, dsint value, dsint delta);
@ -64,51 +71,50 @@ public:
dsint scaleFromScrollBarRangeToUint64(int value);
void updateScrollBarRange(dsint range);
// Coordinates Utils
int getIndexOffsetFromY(int y);
int getColumnIndexFromX(int x);
int getColumnPosition(int index);
int transY(int y);
int getViewableRowsCount();
virtual int getLineToPrintcount();
int getIndexOffsetFromY(int y) const;
int getColumnIndexFromX(int x) const;
int getColumnPosition(int index) const;
int transY(int y) const;
int getViewableRowsCount() const;
virtual int getLineToPrintcount() const;
// New Columns/New Size
virtual void addColumnAt(int width, const QString & title, bool isClickable);
virtual void setRowCount(dsint count);
virtual void deleteAllColumns();
void setColTitle(int index, const QString & title);
QString getColTitle(int index);
QString getColTitle(int index) const;
// Getter & Setter
dsint getRowCount() const;
int getColumnCount() const;
int getRowHeight();
int getColumnWidth(int index);
int getRowHeight() const;
int getColumnWidth(int index) const;
void setColumnWidth(int index, int width);
void setColumnOrder(int pos, int index);
int getColumnOrder(int index);
int getHeaderHeight();
int getTableHeight();
int getGuiState();
int getNbrOfLineToPrint();
int getColumnOrder(int index) const;
int getHeaderHeight() const;
int getTableHeight() const;
int getGuiState() const;
int getNbrOfLineToPrint() const;
void setNbrOfLineToPrint(int parNbrOfLineToPrint);
void setShowHeader(bool show);
int getCharWidth();
bool getColumnHidden(int col);
int getCharWidth() const;
bool getColumnHidden(int col) const;
void setColumnHidden(int col, bool hidden);
bool getDrawDebugOnly() const;
void setDrawDebugOnly(bool value);
bool getAllowPainting() const;
void setAllowPainting(bool allow);
// UI customization
void loadColumnFromConfig(const QString & viewName);
void saveColumnToConfig();
static void setupColumnConfigDefaultValue(QMap<QString, duint> & map, const QString & viewName, int columnCount);
// Content drawing control
bool getDrawDebugOnly();
void setDrawDebugOnly(bool value);
// Table offset management
dsint getTableOffset();
dsint getTableOffset() const;
void setTableOffset(dsint val);
// Update/Reload/Refresh/Repaint
@ -119,16 +125,10 @@ signals:
void headerButtonPressed(int col);
void headerButtonReleased(int col);
void tableOffsetChanged(dsint i);
void viewableRows(int rows);
void viewableRowsChanged(int rows);
void repainted();
public slots:
// Configuration
void slot_updateColors();
void slot_updateFonts();
void slot_updateShortcuts();
void slot_close();
// Update/Reload/Refresh/Repaint
virtual void reloadData();
void updateViewport();
@ -136,81 +136,83 @@ public slots:
// ScrollBar Management
void vertSliderActionSlot(int action);
private slots:
// Configuration
void updateColorsSlot();
void updateFontsSlot();
void updateShortcutsSlot();
void closeSlot();
private:
typedef struct _ColumnResizingData_t
struct ColumnResizingData
{
bool splitHandle;
int index;
int lastPosX;
} ColumnResizingData_t;
};
typedef struct _HeaderButton_t
struct HeaderButton
{
bool isClickable;
bool isPressed;
bool isMouseOver;
} HeaderButton_t;
};
typedef struct _Column_t
struct Column
{
int width;
bool hidden;
HeaderButton_t header;
HeaderButton header;
QString title;
} Column_t;
};
typedef struct _Header_t
struct Header
{
bool isVisible;
int height;
int activeButtonIndex;
} Header_t;
};
typedef struct _ScrollBar64_t
struct ScrollBar64
{
bool is64;
int rightShiftCount;
} ScrollBar64_t;
};
GuiState_t mGuiState;
ColumnResizingData_t mColResizeData;
GuiState mGuiState;
Header mHeader;
QPushButton mHeaderButtonSytle;
QList<Column_t> mColumnList;
QList<Column> mColumnList;
ColumnResizingData mColResizeData;
QList<int> mColumnOrder;
int mReorderStartX;
int mHoveredColumnDisplayIndex;
dsint mRowCount;
static int mMouseWheelScrollDelta;
dsint mTableOffset;
Header_t mHeader;
dsint mPrevTableOffset;
int mNbrOfLineToPrint;
dsint mPrevTableOffset;
bool mShouldReload;
bool mDrawDebugOnly;
bool mAllowPainting;
ScrollBar64_t mScrollBarAttributes;
static int mMouseWheelScrollDelta;
ScrollBar64 mScrollBarAttributes;
int getColumnDisplayIndexFromX(int x);
friend class ColumnReorderDialog;
protected:
bool mAllowPainting;
bool mDrawDebugOnly;
protected:
// Configuration
QColor backgroundColor;
QColor textColor;
QColor separatorColor;
QColor headerTextColor;
QColor selectionColor;
QColor mBackgroundColor;
QColor mTextColor;
QColor mSeparatorColor;
QColor mHeaderTextColor;
QColor mSelectionColor;
QString mViewName;
// Font metrics

View File

@ -17,9 +17,7 @@ Disassembly::Disassembly(QWidget* parent) : AbstractTableView(parent), mDisassem
historyClear();
SelectionData_t data;
memset(&data, 0, sizeof(SelectionData_t));
mSelection = data;
memset(&mSelection, 0, sizeof(SelectionData));
mCipRva = 0;
@ -56,7 +54,7 @@ Disassembly::Disassembly(QWidget* parent) : AbstractTableView(parent), mDisassem
setShowHeader(false); //hide header
backgroundColor = ConfigColor("DisassemblyBackgroundColor");
mBackgroundColor = ConfigColor("DisassemblyBackgroundColor");
mXrefInfo.refcount = 0;
@ -80,7 +78,7 @@ Disassembly::~Disassembly()
void Disassembly::updateColors()
{
AbstractTableView::updateColors();
backgroundColor = ConfigColor("DisassemblyBackgroundColor");
mBackgroundColor = ConfigColor("DisassemblyBackgroundColor");
mInstructionHighlightColor = ConfigColor("InstructionHighlightColor");
mDisassemblyRelocationUnderlineColor = ConfigColor("DisassemblyRelocationUnderlineColor");
@ -970,7 +968,7 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, dsint addr,
bool showXref = false;
GraphicDump_t wPict = GD_Nothing;
GraphicDump wPict = GD_Nothing;
if(branchType != Instruction_t::None && branchType != Instruction_t::Call)
{
@ -1049,7 +1047,7 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, dsint addr,
}
}
GraphicJumpDirection_t curInstDir = GJD_Nothing;
GraphicJumpDirection curInstDir = GJD_Nothing;
if(isjmp)
{
@ -1848,7 +1846,7 @@ void Disassembly::disassembleAt(dsint parVA, dsint parCIP, bool history, dsint n
dsint wRVA = parVA - wBase;
dsint wCipRva = parCIP - wBase;
HistoryData_t newHistory;
HistoryData newHistory;
//VA history
if(history)

View File

@ -13,26 +13,26 @@ class Disassembly : public AbstractTableView
Q_OBJECT
public:
explicit Disassembly(QWidget* parent = 0);
virtual ~Disassembly();
~Disassembly() override;
// Configuration
virtual void updateColors();
virtual void updateFonts();
void updateColors() override;
void updateFonts() override;
// Reimplemented Functions
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) override;
// Mouse Management
void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void leaveEvent(QEvent* event) override;
// Keyboard Management
void keyPressEvent(QKeyEvent* event);
void keyPressEvent(QKeyEvent* event) override;
// ScrollBar Management
dsint sliderMovedHook(int type, dsint value, dsint delta);
dsint sliderMovedHook(int type, dsint value, dsint delta) override;
// Jumps Graphic
int paintJumpsGraphic(QPainter* painter, int x, int y, dsint addr, bool isjmp);
@ -72,8 +72,8 @@ public:
duint getSelectedVa();
// Update/Reload/Refresh/Repaint
void prepareData();
void reloadData();
void prepareData() override;
void reloadData() override;
// Public Methods
duint rvaToVa(dsint rva) const;
@ -121,35 +121,56 @@ public slots:
void tokenizerConfigUpdatedSlot();
private:
enum GuiState_t {NoState, MultiRowsSelectionState};
enum GraphicDump_t {GD_Nothing, GD_FootToTop, GD_FootToBottom, GD_HeadFromTop, GD_HeadFromBottom, GD_HeadFromBoth, GD_Vert, GD_VertHori}; // GD_FootToTop = '- , GD_FootToBottom = ,- , GD_HeadFromTop = '-> , GD_HeadFromBottom = ,-> , GD_HeadFromBoth = |-> , GD_Vert = | , GD_VertHori = |-
enum GraphicJumpDirection_t {GJD_Nothing, GJD_Up, GJD_Down };
enum GuiState
{
NoState,
MultiRowsSelectionState
};
typedef struct _SelectionData_t
enum GraphicDump
{
GD_Nothing,
GD_FootToTop, //GD_FootToTop = '-
GD_FootToBottom, //GD_FootToBottom = ,-
GD_HeadFromTop, //GD_HeadFromTop = '->
GD_HeadFromBottom, //GD_HeadFromBottom = ,->
GD_HeadFromBoth, //GD_HeadFromBoth = |->
GD_Vert, //GD_Vert = |
GD_VertHori //GD_VertHori = |-
};
enum GraphicJumpDirection
{
GJD_Nothing,
GJD_Up,
GJD_Down
};
struct SelectionData
{
dsint firstSelectedIndex;
dsint fromIndex;
dsint toIndex;
} SelectionData_t;
};
SelectionData_t mSelection;
SelectionData mSelection;
bool mIsLastInstDisplayed;
GuiState_t mGuiState;
GuiState mGuiState;
dsint mCipRva;
QList<Instruction_t> mInstBuffer;
typedef struct _HistoryData_t
struct HistoryData
{
dsint va;
dsint tableOffset;
QString windowTitle;
} HistoryData_t;
};
QList<HistoryData_t> mVaHistory;
QList<HistoryData> mVaHistory;
int mCurrentVa;
protected:

View File

@ -7,9 +7,7 @@
HexDump::HexDump(QWidget* parent)
: AbstractTableView(parent)
{
SelectionData_t data;
memset(&data, 0, sizeof(SelectionData_t));
mSelection = data;
memset(&mSelection, 0, sizeof(SelectionData));
setDrawDebugOnly(true);
@ -22,9 +20,9 @@ HexDump::HexDump(QWidget* parent)
clearDescriptors();
backgroundColor = ConfigColor("HexDumpBackgroundColor");
textColor = ConfigColor("HexDumpTextColor");
selectionColor = ConfigColor("HexDumpSelectionColor");
mBackgroundColor = ConfigColor("HexDumpBackgroundColor");
mTextColor = ConfigColor("HexDumpTextColor");
mSelectionColor = ConfigColor("HexDumpSelectionColor");
mRvaDisplayEnabled = false;
mSyncAddrExpression = "";
@ -48,9 +46,9 @@ void HexDump::updateColors()
{
AbstractTableView::updateColors();
backgroundColor = ConfigColor("HexDumpBackgroundColor");
textColor = ConfigColor("HexDumpTextColor");
selectionColor = ConfigColor("HexDumpSelectionColor");
mBackgroundColor = ConfigColor("HexDumpBackgroundColor");
mTextColor = ConfigColor("HexDumpTextColor");
mSelectionColor = ConfigColor("HexDumpSelectionColor");
mModifiedBytesColor = ConfigColor("HexDumpModifiedBytesColor");
mModifiedBytesBackgroundColor = ConfigColor("HexDumpModifiedBytesBackgroundColor");
@ -550,7 +548,7 @@ void HexDump::printSelected(QPainter* painter, dsint rowBase, int rowOffset, int
{
if((col > 0) && ((col - 1) < mDescriptor.size()))
{
ColumnDescriptor_t curDescriptor = mDescriptor.at(col - 1);
ColumnDescriptor curDescriptor = mDescriptor.at(col - 1);
int wBytePerRowCount = getBytePerRowCount();
dsint wRva = (rowBase + rowOffset) * wBytePerRowCount - mByteOffset;
int wItemPixWidth = getItemPixelWidth(curDescriptor);
@ -565,13 +563,13 @@ void HexDump::printSelected(QPainter* painter, dsint rowBase, int rowOffset, int
{
int wSelectionWidth = wItemPixWidth > w - (wSelectionX - x) ? w - (wSelectionX - x) : wItemPixWidth;
wSelectionWidth = wSelectionWidth < 0 ? 0 : wSelectionWidth;
painter->setPen(textColor);
painter->fillRect(QRect(wSelectionX, y, wSelectionWidth, h), QBrush(selectionColor));
painter->setPen(mTextColor);
painter->fillRect(QRect(wSelectionX, y, wSelectionWidth, h), QBrush(mSelectionColor));
}
int separator = curDescriptor.separator;
if(i && separator && !(i % separator))
{
painter->setPen(separatorColor);
painter->setPen(mSeparatorColor);
painter->drawLine(wSelectionX, y, wSelectionX, y + h);
}
}
@ -637,7 +635,7 @@ void HexDump::getColumnRichText(int col, dsint rva, RichTextPainter::List & rich
RichTextPainter::CustomRichText_t curData;
curData.highlight = false;
curData.flags = RichTextPainter::FlagAll;
curData.textColor = textColor;
curData.textColor = mTextColor;
curData.textBackground = Qt::transparent;
curData.highlightColor = Qt::transparent;
@ -653,7 +651,7 @@ void HexDump::getColumnRichText(int col, dsint rva, RichTextPainter::List & rich
}
else if(mDescriptor.at(col - 1).isData == true)
{
const ColumnDescriptor_t & desc = mDescriptor.at(col - 1);
const ColumnDescriptor & desc = mDescriptor.at(col - 1);
int wI;
int wByteCount = getSizeOf(desc.data.itemSize);
@ -680,7 +678,7 @@ void HexDump::getColumnRichText(int col, dsint rva, RichTextPainter::List & rich
for(wI = 0; wI < desc.itemCount && (rva + wI) < (dsint)mMemPage->getSize(); wI++)
{
curData.text.clear();
curData.textColor = textColor;
curData.textColor = mTextColor;
curData.textBackground = Qt::transparent;
curData.flags = RichTextPainter::FlagAll;
@ -734,7 +732,7 @@ void HexDump::getColumnRichText(int col, dsint rva, RichTextPainter::List & rich
}
}
void HexDump::toString(DataDescriptor_t desc, duint rva, byte_t* data, RichTextPainter::CustomRichText_t & richText) //convert data to string
void HexDump::toString(DataDescriptor desc, duint rva, byte_t* data, RichTextPainter::CustomRichText_t & richText) //convert data to string
{
switch(desc.itemSize)
{
@ -784,7 +782,7 @@ void HexDump::toString(DataDescriptor_t desc, duint rva, byte_t* data, RichTextP
richText.textColor = ConfigColor("HexDumpModifiedBytesColor");
}
void HexDump::byteToString(duint rva, byte_t byte, ByteViewMode_e mode, RichTextPainter::CustomRichText_t & richText)
void HexDump::byteToString(duint rva, byte_t byte, ByteViewMode mode, RichTextPainter::CustomRichText_t & richText)
{
QString wStr = "";
@ -871,7 +869,7 @@ void HexDump::byteToString(duint rva, byte_t byte, ByteViewMode_e mode, RichText
}
}
void HexDump::wordToString(duint rva, uint16 word, WordViewMode_e mode, RichTextPainter::CustomRichText_t & richText)
void HexDump::wordToString(duint rva, uint16 word, WordViewMode mode, RichTextPainter::CustomRichText_t & richText)
{
Q_UNUSED(rva);
QString wStr;
@ -918,7 +916,7 @@ void HexDump::wordToString(duint rva, uint16 word, WordViewMode_e mode, RichText
richText.text = wStr;
}
void HexDump::dwordToString(duint rva, uint32 dword, DwordViewMode_e mode, RichTextPainter::CustomRichText_t & richText)
void HexDump::dwordToString(duint rva, uint32 dword, DwordViewMode mode, RichTextPainter::CustomRichText_t & richText)
{
Q_UNUSED(rva);
QString wStr;
@ -959,7 +957,7 @@ void HexDump::dwordToString(duint rva, uint32 dword, DwordViewMode_e mode, RichT
richText.text = wStr;
}
void HexDump::qwordToString(duint rva, uint64 qword, QwordViewMode_e mode, RichTextPainter::CustomRichText_t & richText)
void HexDump::qwordToString(duint rva, uint64 qword, QwordViewMode mode, RichTextPainter::CustomRichText_t & richText)
{
Q_UNUSED(rva);
QString wStr;
@ -1000,7 +998,7 @@ void HexDump::qwordToString(duint rva, uint64 qword, QwordViewMode_e mode, RichT
richText.text = wStr;
}
void HexDump::twordToString(duint rva, void* tword, TwordViewMode_e mode, RichTextPainter::CustomRichText_t & richText)
void HexDump::twordToString(duint rva, void* tword, TwordViewMode mode, RichTextPainter::CustomRichText_t & richText)
{
Q_UNUSED(rva);
QString wStr;
@ -1023,12 +1021,12 @@ void HexDump::twordToString(duint rva, void* tword, TwordViewMode_e mode, RichTe
richText.text = wStr;
}
int HexDump::getSizeOf(DataSize_e size)
int HexDump::getSizeOf(DataSize size)
{
return int(size);
}
int HexDump::getStringMaxLength(DataDescriptor_t desc)
int HexDump::getStringMaxLength(DataDescriptor desc)
{
int wLength = 0;
@ -1074,7 +1072,7 @@ int HexDump::getStringMaxLength(DataDescriptor_t desc)
return wLength;
}
int HexDump::byteStringMaxLength(ByteViewMode_e mode)
int HexDump::byteStringMaxLength(ByteViewMode mode)
{
int wLength = 0;
@ -1114,7 +1112,7 @@ int HexDump::byteStringMaxLength(ByteViewMode_e mode)
return wLength;
}
int HexDump::wordStringMaxLength(WordViewMode_e mode)
int HexDump::wordStringMaxLength(WordViewMode mode)
{
int wLength = 0;
@ -1154,7 +1152,7 @@ int HexDump::wordStringMaxLength(WordViewMode_e mode)
return wLength;
}
int HexDump::dwordStringMaxLength(DwordViewMode_e mode)
int HexDump::dwordStringMaxLength(DwordViewMode mode)
{
int wLength = 0;
@ -1194,7 +1192,7 @@ int HexDump::dwordStringMaxLength(DwordViewMode_e mode)
return wLength;
}
int HexDump::qwordStringMaxLength(QwordViewMode_e mode)
int HexDump::qwordStringMaxLength(QwordViewMode mode)
{
int wLength = 0;
@ -1234,7 +1232,7 @@ int HexDump::qwordStringMaxLength(QwordViewMode_e mode)
return wLength;
}
int HexDump::twordStringMaxLength(TwordViewMode_e mode)
int HexDump::twordStringMaxLength(TwordViewMode mode)
{
int wLength = 0;
@ -1304,7 +1302,7 @@ int HexDump::getBytePerRowCount()
return mDescriptor.at(0).itemCount * getSizeOf(mDescriptor.at(0).data.itemSize);
}
int HexDump::getItemPixelWidth(ColumnDescriptor_t desc)
int HexDump::getItemPixelWidth(ColumnDescriptor desc)
{
int wCharWidth = getCharWidth();
int wItemPixWidth = getStringMaxLength(desc.data) * wCharWidth + wCharWidth;
@ -1312,16 +1310,16 @@ int HexDump::getItemPixelWidth(ColumnDescriptor_t desc)
return wItemPixWidth;
}
void HexDump::appendDescriptor(int width, QString title, bool clickable, ColumnDescriptor_t descriptor)
void HexDump::appendDescriptor(int width, QString title, bool clickable, ColumnDescriptor descriptor)
{
addColumnAt(width, title, clickable);
mDescriptor.append(descriptor);
}
//Clears the descriptors, append a new descriptor and fix the tableOffset (use this instead of clearDescriptors()
void HexDump::appendResetDescriptor(int width, QString title, bool clickable, ColumnDescriptor_t descriptor)
void HexDump::appendResetDescriptor(int width, QString title, bool clickable, ColumnDescriptor descriptor)
{
mAllowPainting = false;
setAllowPainting(false);
if(mDescriptor.size())
{
dsint wRVA = getTableOffset() * getBytePerRowCount() - mByteOffset;
@ -1331,7 +1329,7 @@ void HexDump::appendResetDescriptor(int width, QString title, bool clickable, Co
}
else
appendDescriptor(width, title, clickable, descriptor);
mAllowPainting = true;
setAllowPainting(true);
}
void HexDump::clearDescriptors()

View File

@ -11,7 +11,7 @@ class HexDump : public AbstractTableView
{
Q_OBJECT
public:
enum DataSize_e
enum DataSize
{
Byte = 1,
Word = 2,
@ -20,7 +20,7 @@ public:
Tword = 10
};
enum ByteViewMode_e
enum ByteViewMode
{
HexByte,
AsciiByte,
@ -28,7 +28,7 @@ public:
UnsignedDecByte
};
enum WordViewMode_e
enum WordViewMode
{
HexWord,
UnicodeWord,
@ -36,7 +36,7 @@ public:
UnsignedDecWord
};
enum DwordViewMode_e
enum DwordViewMode
{
HexDword,
SignedDecDword,
@ -44,7 +44,7 @@ public:
FloatDword //sizeof(float)=4
};
enum QwordViewMode_e
enum QwordViewMode
{
HexQword,
SignedDecQword,
@ -52,56 +52,50 @@ public:
DoubleQword //sizeof(double)=8
};
enum TwordViewMode_e
enum TwordViewMode
{
FloatTword
};
typedef struct _DataDescriptor_t
struct DataDescriptor
{
DataSize_e itemSize; // Items size
DataSize itemSize; // Items size
union // View mode
{
ByteViewMode_e byteMode;
WordViewMode_e wordMode;
DwordViewMode_e dwordMode;
QwordViewMode_e qwordMode;
TwordViewMode_e twordMode;
ByteViewMode byteMode;
WordViewMode wordMode;
DwordViewMode dwordMode;
QwordViewMode qwordMode;
TwordViewMode twordMode;
};
} DataDescriptor_t;
};
struct ColumnDescriptor_t
struct ColumnDescriptor
{
bool isData = true;
int itemCount = 16;
int separator = 0;
QTextCodec* textCodec; //name of the text codec (leave empty if you want to keep your sanity)
DataDescriptor_t data;
QTextCodec* textCodec = nullptr; //name of the text codec (leave empty if you want to keep your sanity)
DataDescriptor data;
std::function<void()> columnSwitch;
explicit ColumnDescriptor_t()
: textCodec(nullptr)
{
}
};
explicit HexDump(QWidget* parent = 0);
virtual ~HexDump();
~HexDump() override;
// Configuration
virtual void updateColors();
virtual void updateFonts();
virtual void updateShortcuts();
void updateColors() override;
void updateFonts() override;
void updateShortcuts() override;
//QString getStringToPrint(int rowBase, int rowOffset, int col);
void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) override;
void paintGraphicDump(QPainter* painter, int x, int y, int addr);
void printSelected(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
// Selection Management
@ -113,33 +107,33 @@ public:
bool isSelected(dsint rva);
virtual void getColumnRichText(int col, dsint rva, RichTextPainter::List & richText);
int getSizeOf(DataSize_e size);
int getSizeOf(DataSize size);
void toString(DataDescriptor_t desc, duint rva, byte_t* data, RichTextPainter::CustomRichText_t & richText);
void toString(DataDescriptor desc, duint rva, byte_t* data, RichTextPainter::CustomRichText_t & richText);
void byteToString(duint rva, byte_t byte, ByteViewMode_e mode, RichTextPainter::CustomRichText_t & richText);
void wordToString(duint rva, uint16 word, WordViewMode_e mode, RichTextPainter::CustomRichText_t & richText);
void dwordToString(duint rva, uint32 dword, DwordViewMode_e mode, RichTextPainter::CustomRichText_t & richText);
void qwordToString(duint rva, uint64 qword, QwordViewMode_e mode, RichTextPainter::CustomRichText_t & richText);
void twordToString(duint rva, void* tword, TwordViewMode_e mode, RichTextPainter::CustomRichText_t & richText);
void byteToString(duint rva, byte_t byte, ByteViewMode mode, RichTextPainter::CustomRichText_t & richText);
void wordToString(duint rva, uint16 word, WordViewMode mode, RichTextPainter::CustomRichText_t & richText);
void dwordToString(duint rva, uint32 dword, DwordViewMode mode, RichTextPainter::CustomRichText_t & richText);
void qwordToString(duint rva, uint64 qword, QwordViewMode mode, RichTextPainter::CustomRichText_t & richText);
void twordToString(duint rva, void* tword, TwordViewMode mode, RichTextPainter::CustomRichText_t & richText);
int getStringMaxLength(DataDescriptor_t desc);
int getStringMaxLength(DataDescriptor desc);
int byteStringMaxLength(ByteViewMode_e mode);
int wordStringMaxLength(WordViewMode_e mode);
int dwordStringMaxLength(DwordViewMode_e mode);
int qwordStringMaxLength(QwordViewMode_e mode);
int twordStringMaxLength(TwordViewMode_e mode);
int byteStringMaxLength(ByteViewMode mode);
int wordStringMaxLength(WordViewMode mode);
int dwordStringMaxLength(DwordViewMode mode);
int qwordStringMaxLength(QwordViewMode mode);
int twordStringMaxLength(TwordViewMode mode);
int getItemIndexFromX(int x);
dsint getItemStartingAddress(int x, int y);
int getBytePerRowCount();
int getItemPixelWidth(ColumnDescriptor_t desc);
int getItemPixelWidth(ColumnDescriptor desc);
//descriptor management
void appendDescriptor(int width, QString title, bool clickable, ColumnDescriptor_t descriptor);
void appendResetDescriptor(int width, QString title, bool clickable, ColumnDescriptor_t descriptor);
void appendDescriptor(int width, QString title, bool clickable, ColumnDescriptor descriptor);
void appendResetDescriptor(int width, QString title, bool clickable, ColumnDescriptor descriptor);
void clearDescriptors();
void printDumpAt(dsint parVA, bool select, bool repaint = true, bool updateTableOffset = true);
@ -166,18 +160,22 @@ public slots:
void gotoNextSlot();
private:
enum GuiState_t {NoState, MultiRowsSelectionState};
enum GuiState
{
NoState,
MultiRowsSelectionState
};
typedef struct _RowDescriptor_t
struct SelectionData
{
dsint firstSelectedIndex;
dsint fromIndex;
dsint toIndex;
} SelectionData_t;
};
SelectionData_t mSelection;
SelectionData mSelection;
GuiState_t mGuiState;
GuiState mGuiState;
QChar mNonprintReplace;
QChar mNullReplace;
@ -204,7 +202,7 @@ private:
protected:
MemoryPage* mMemPage;
int mByteOffset;
QList<ColumnDescriptor_t> mDescriptor;
QList<ColumnDescriptor> mDescriptor;
int mForceColumn;
bool mRvaDisplayEnabled;
duint mRvaDisplayBase;

View File

@ -7,7 +7,7 @@
#include "Bridge.h"
#include "MiscUtil.h"
ReferenceView::ReferenceView(bool sourceView, QWidget* parent) : SearchListView(true, parent), mParent(dynamic_cast<QTabWidget*>(parent))
ReferenceView::ReferenceView(bool sourceView, QWidget* parent) : StdSearchListView(parent, true, false), mParent(dynamic_cast<QTabWidget*>(parent))
{
// Setup SearchListView settings
mSearchStartCol = 1;
@ -69,15 +69,13 @@ void ReferenceView::setupContextMenu()
mToggleBreakpoint = new QAction(DIcon("breakpoint_toggle.png"), tr("Toggle Breakpoint"), this);
mToggleBreakpoint->setShortcutContext(Qt::WidgetWithChildrenShortcut);
addAction(mToggleBreakpoint);
mList->addAction(mToggleBreakpoint);
mSearchList->addAction(mToggleBreakpoint);
StdSearchListView::addAction(mToggleBreakpoint);
connect(mToggleBreakpoint, SIGNAL(triggered()), this, SLOT(toggleBreakpoint()));
mToggleBookmark = new QAction(DIcon("bookmark_toggle.png"), tr("Toggle Bookmark"), this);
mToggleBookmark->setShortcutContext(Qt::WidgetWithChildrenShortcut);
addAction(mToggleBookmark);
mList->addAction(mToggleBookmark);
mSearchList->addAction(mToggleBookmark);
StdSearchListView::addAction(mToggleBookmark);
connect(mToggleBookmark, SIGNAL(triggered()), this, SLOT(toggleBookmark()));
mSetBreakpointOnAllCommands = new QAction(DIcon("breakpoint_seton_all_commands.png"), tr("Set breakpoint on all commands"), this);
@ -98,7 +96,7 @@ void ReferenceView::setupContextMenu()
void ReferenceView::connectBridge()
{
connect(Bridge::getBridge(), SIGNAL(referenceAddColumnAt(int, QString)), this, SLOT(addColumnAt(int, QString)));
connect(Bridge::getBridge(), SIGNAL(referenceAddColumnAt(int, QString)), this, SLOT(addColumnAtRef(int, QString)));
connect(Bridge::getBridge(), SIGNAL(referenceSetRowCount(dsint)), this, SLOT(setRowCount(dsint)));
connect(Bridge::getBridge(), SIGNAL(referenceSetCellContent(int, int, QString)), this, SLOT(setCellContent(int, int, QString)));
connect(Bridge::getBridge(), SIGNAL(referenceReloadData()), this, SLOT(reloadData()));
@ -107,13 +105,13 @@ void ReferenceView::connectBridge()
connect(Bridge::getBridge(), SIGNAL(referenceSetCurrentTaskProgress(int, QString)), this, SLOT(referenceSetCurrentTaskProgressSlot(int, QString)));
connect(Bridge::getBridge(), SIGNAL(referenceSetSearchStartCol(int)), this, SLOT(setSearchStartCol(int)));
connect(Bridge::getBridge(), SIGNAL(referenceAddCommand(QString, QString)), this, SLOT(addCommand(QString, QString)));
connect(this->mSearchList, SIGNAL(selectionChangedSignal(int)), this, SLOT(searchSelectionChanged(int)));
connect(this->mList, SIGNAL(selectionChangedSignal(int)), this, SLOT(searchSelectionChanged(int)));
connect(stdSearchList(), SIGNAL(selectionChangedSignal(int)), this, SLOT(searchSelectionChanged(int)));
connect(stdList(), SIGNAL(selectionChangedSignal(int)), this, SLOT(searchSelectionChanged(int)));
}
void ReferenceView::disconnectBridge()
{
disconnect(Bridge::getBridge(), SIGNAL(referenceAddColumnAt(int, QString)), this, SLOT(addColumnAt(int, QString)));
disconnect(Bridge::getBridge(), SIGNAL(referenceAddColumnAt(int, QString)), this, SLOT(addColumnAtRef(int, QString)));
disconnect(Bridge::getBridge(), SIGNAL(referenceSetRowCount(dsint)), this, SLOT(setRowCount(dsint)));
disconnect(Bridge::getBridge(), SIGNAL(referenceSetCellContent(int, int, QString)), this, SLOT(setCellContent(int, int, QString)));
disconnect(Bridge::getBridge(), SIGNAL(referenceReloadData()), this, SLOT(reloadData()));
@ -122,8 +120,8 @@ void ReferenceView::disconnectBridge()
disconnect(Bridge::getBridge(), SIGNAL(referenceSetCurrentTaskProgress(int, QString)), this, SLOT(referenceSetCurrentTaskProgressSlot(int, QString)));
disconnect(Bridge::getBridge(), SIGNAL(referenceSetSearchStartCol(int)), this, SLOT(setSearchStartCol(int)));
disconnect(Bridge::getBridge(), SIGNAL(referenceAddCommand(QString, QString)), this, SLOT(addCommand(QString, QString)));
disconnect(this->mSearchList, SIGNAL(selectionChangedSignal(int)), this, SLOT(searchSelectionChanged(int)));
disconnect(this->mList, SIGNAL(selectionChangedSignal(int)), this, SLOT(searchSelectionChanged(int)));
disconnect(stdSearchList(), SIGNAL(selectionChangedSignal(int)), this, SLOT(searchSelectionChanged(int)));
disconnect(stdList(), SIGNAL(selectionChangedSignal(int)), this, SLOT(searchSelectionChanged(int)));
}
void ReferenceView::refreshShortcutsSlot()
@ -152,9 +150,9 @@ void ReferenceView::searchSelectionChanged(int index)
DbgValToString("$__dump_refindex", index);
}
void ReferenceView::addColumnAt(int width, QString title)
void ReferenceView::addColumnAtRef(int width, QString title)
{
int charwidth = mList->getCharWidth();
int charwidth = getCharWidth();
if(width)
width = charwidth * width + 8;
else
@ -162,50 +160,29 @@ void ReferenceView::addColumnAt(int width, QString title)
mSearchBox->setText("");
if(title.toLower() == "&data&")
title = "Data";
mList->addColumnAt(width, title, true);
mSearchList->addColumnAt(width, title, true);
StdSearchListView::addColumnAt(width, title, true);
}
void ReferenceView::setRowCount(dsint count)
{
if(!mList->getRowCount() && count) //from zero to N rows
if(!stdList()->getRowCount() && count) //from zero to N rows
searchSelectionChanged(0);
emit mCountTotalLabel->setText(QString("%1").arg(count));
mSearchBox->setText("");
mList->setRowCount(count);
}
void ReferenceView::setCellContent(int r, int c, QString s)
{
mSearchBox->setText("");
mList->setCellContent(r, c, s);
}
void ReferenceView::addCommand(QString title, QString command)
{
mCommnadTitles.append(title);
mCommands.append(command);
}
void ReferenceView::reloadData()
{
mSearchBox->setText("");
mList->reloadData();
mList->setFocus();
StdSearchListView::setRowCount(count);
}
void ReferenceView::setSingleSelection(int index, bool scroll)
{
mSearchBox->setText("");
mList->setSingleSelection(index);
stdList()->setSingleSelection(index);
if(scroll) //TODO: better scrolling
mList->setTableOffset(index);
stdList()->setTableOffset(index);
}
void ReferenceView::setSearchStartCol(int col)
void ReferenceView::addCommand(QString title, QString command)
{
if(col < mList->getColumnCount())
mSearchStartCol = col;
mCommandTitles.append(title);
mCommands.append(command);
}
void ReferenceView::referenceContextMenu(QMenu* wMenu)
@ -245,9 +222,9 @@ void ReferenceView::referenceContextMenu(QMenu* wMenu)
if(this->mCommands.size() > 0)
{
wMenu->addSeparator();
for(auto i = 0; i < this->mCommnadTitles.size(); i++)
for(auto i = 0; i < this->mCommandTitles.size(); i++)
{
QAction* newCommandAction = new QAction(this->mCommnadTitles.at(i), wMenu);
QAction* newCommandAction = new QAction(this->mCommandTitles.at(i), wMenu);
newCommandAction->setData(QVariant(mCommands.at(i)));
connect(newCommandAction, SIGNAL(triggered()), this, SLOT(referenceExecCommand()));
wMenu->addAction(newCommandAction);

View File

@ -3,11 +3,11 @@
#include <QProgressBar>
#include <QLabel>
#include "SearchListView.h"
#include "StdSearchListView.h"
class QTabWidget;
class ReferenceView : public SearchListView
class ReferenceView : public StdSearchListView
{
Q_OBJECT
@ -18,13 +18,12 @@ public:
void disconnectBridge();
public slots:
void addColumnAt(int width, QString title);
void setRowCount(dsint count);
void setCellContent(int r, int c, QString s);
void addCommand(QString title, QString command);
void reloadData();
void addColumnAtRef(int width, QString title);
void setRowCount(dsint count) override;
void setSingleSelection(int index, bool scroll);
void setSearchStartCol(int col);
void addCommand(QString title, QString command);
void referenceContextMenu(QMenu* wMenu);
void followAddress();
void followDumpAddress();
@ -60,7 +59,7 @@ private:
QAction* mSetBreakpointOnAllApiCalls;
QAction* mRemoveBreakpointOnAllApiCalls;
QLabel* mCountTotalLabel;
QVector<QString> mCommnadTitles;
QVector<QString> mCommandTitles;
QVector<QString> mCommands;
QTabWidget* mParent;

View File

@ -5,7 +5,8 @@
#include "SearchListView.h"
#include "FlickerThread.h"
SearchListView::SearchListView(bool EnableRegex, QWidget* parent, bool EnableLock) : QWidget(parent)
SearchListView::SearchListView(QWidget* parent, AbstractSearchList* abstractSearchList, bool enableRegex, bool enableLock)
: QWidget(parent), mAbstractSearchList(abstractSearchList)
{
setContextMenuPolicy(Qt::CustomContextMenu);
@ -19,17 +20,15 @@ SearchListView::SearchListView(bool EnableRegex, QWidget* parent, bool EnableLoc
{
// Create list layout (contains both ListViews)
{
// Create reference & search list
mList = new SearchListViewTable();
mSearchList = new SearchListViewTable();
mSearchList->hide();
// Initially hide the search list
abstractSearchList->searchList()->hide();
// Vertical layout
QVBoxLayout* listLayout = new QVBoxLayout();
listLayout->setContentsMargins(0, 0, 0, 0);
listLayout->setSpacing(0);
listLayout->addWidget(mList);
listLayout->addWidget(mSearchList);
listLayout->addWidget(abstractSearchList->list());
listLayout->addWidget(abstractSearchList->searchList());
// Add list placeholder
QWidget* listPlaceholder = new QWidget();
@ -51,15 +50,15 @@ SearchListView::SearchListView(bool EnableRegex, QWidget* parent, bool EnableLoc
// Lock checkbox
mLockCheckbox = new QCheckBox(tr("Lock"));
if(!EnableRegex)
if(!enableRegex)
mRegexCheckbox->hide();
if(!EnableLock)
if(!enableLock)
mLockCheckbox->hide();
// Horizontal layout
QHBoxLayout* horzLayout = new QHBoxLayout();
horzLayout->setContentsMargins(4, 0, (EnableRegex || EnableLock) ? 0 : 4, 0);
horzLayout->setContentsMargins(4, 0, (enableRegex || enableLock) ? 0 : 4, 0);
horzLayout->setSpacing(2);
horzLayout->addWidget(new QLabel(tr("Search: ")));
horzLayout->addWidget(mSearchBox);
@ -89,7 +88,7 @@ SearchListView::SearchListView(bool EnableRegex, QWidget* parent, bool EnableLoc
setLayout(mainLayout);
// Set global variables
mCurList = mList;
mCurList = abstractSearchList->list();
mSearchStartCol = 0;
// Install input event filter
@ -102,24 +101,20 @@ SearchListView::SearchListView(bool EnableRegex, QWidget* parent, bool EnableLoc
connect(mSearchAction, SIGNAL(triggered()), this, SLOT(searchSlot()));
// Slots
connect(mList, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(listContextMenu(QPoint)));
connect(mList, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot()));
connect(mSearchList, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(listContextMenu(QPoint)));
connect(mSearchList, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot()));
connect(abstractSearchList->list(), SIGNAL(contextMenuSignal(QPoint)), this, SLOT(listContextMenu(QPoint)));
connect(abstractSearchList->list(), SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot()));
connect(abstractSearchList->searchList(), SIGNAL(contextMenuSignal(QPoint)), this, SLOT(listContextMenu(QPoint)));
connect(abstractSearchList->searchList(), SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot()));
connect(mSearchBox, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
connect(mRegexCheckbox, SIGNAL(stateChanged(int)), this, SLOT(on_checkBoxRegex_stateChanged(int)));
connect(mLockCheckbox, SIGNAL(toggled(bool)), mSearchBox, SLOT(setDisabled(bool)));
// List input should always be forwarded to the filter edit
mSearchList->setFocusProxy(mSearchBox);
mList->setFocusProxy(mSearchBox);
abstractSearchList->searchList()->setFocusProxy(mSearchBox);
abstractSearchList->list()->setFocusProxy(mSearchBox);
}
SearchListView::~SearchListView()
{
}
bool SearchListView::findTextInList(SearchListViewTable* list, QString text, int row, int startcol, bool startswith)
bool SearchListView::findTextInList(AbstractStdTable* list, QString text, int row, int startcol, bool startswith)
{
int count = list->getColumnCount();
if(startcol + 1 > count)
@ -150,62 +145,50 @@ bool SearchListView::findTextInList(SearchListViewTable* list, QString text, int
return false;
}
void SearchListView::searchTextChanged(const QString & arg1)
void SearchListView::searchTextChanged(const QString & text)
{
SearchListViewTable* mPrevList = NULL;
mAbstractSearchList->lock();
if(mSearchList->isHidden())
{
auto selList = mList->getSelection();
if(!selList.empty() && mList->isValidIndex(selList[0], 0))
mLastFirstColValue = mList->getCellContent(selList[0], 0);
}
else
{
auto selList = mSearchList->getSelection();
if(!selList.empty() && mSearchList->isValidIndex(selList[0], 0))
mLastFirstColValue = mSearchList->getCellContent(selList[0], 0);
}
// store the first selection value
QString mLastFirstColValue;
auto selList = mCurList->getSelection();
if(!selList.empty() && mCurList->isValidIndex(selList[0], 0))
mLastFirstColValue = mCurList->getCellContent(selList[0], 0);
// get the correct previous list instance
if(mList->isVisible())
mPrevList = mList;
else
mPrevList = mSearchList;
auto mPrevList = mAbstractSearchList->list()->isVisible() ? mAbstractSearchList->list() : mAbstractSearchList->searchList();
if(arg1.length())
if(text.length())
{
mList->hide();
mSearchList->show();
mCurList = mSearchList;
mAbstractSearchList->list()->hide();
mAbstractSearchList->searchList()->show();
mCurList = mAbstractSearchList->searchList();
}
else
{
mSearchList->hide();
mList->show();
mCurList = mList;
mAbstractSearchList->searchList()->hide();
mAbstractSearchList->list()->show();
mCurList = mAbstractSearchList->list();
}
mSearchList->setRowCount(0);
int rows = mList->getRowCount();
int columns = mList->getColumnCount();
for(int i = 0, j = 0; i < rows; i++)
// filter the list
auto filterType = AbstractSearchList::FilterContainsTextCaseInsensitive;
switch(mRegexCheckbox->checkState())
{
if(findTextInList(mList, arg1, i, mSearchStartCol, false))
{
mSearchList->setRowCount(j + 1);
for(int k = 0; k < columns; k++)
mSearchList->setCellContent(j, k, mList->getCellContent(i, k));
j++;
}
case Qt::PartiallyChecked:
filterType = AbstractSearchList::FilterRegexCaseInsensitive;
break;
case Qt::Checked:
filterType = AbstractSearchList::FilterRegexCaseSensitive;
break;
}
mAbstractSearchList->filter(text, filterType, mSearchStartCol); // TODO: do not filter if text is empty
mSearchList->reloadData();
// attempt to restore previous selection
bool hasSetSingleSelection = false;
if(!mLastFirstColValue.isEmpty())
{
rows = mCurList->getRowCount();
int rows = mCurList->getRowCount();
mCurList->setTableOffset(0);
for(int i = 0; i < rows; i++)
{
@ -227,17 +210,32 @@ void SearchListView::searchTextChanged(const QString & arg1)
if(!hasSetSingleSelection)
mCurList->setSingleSelection(0);
if(rows == 0)
if(!mCurList->getRowCount())
emit emptySearchResult();
// Do not highlight with regex
// TODO: fully respect highlighting mode
if(mRegexCheckbox->checkState() == Qt::Unchecked)
mSearchList->highlightText = arg1;
mAbstractSearchList->searchList()->setHighlightText(text);
else
mSearchList->highlightText = "";
mAbstractSearchList->searchList()->setHighlightText(QString());
// setup the same layout of the prev list control
LoadPrevListLayout(mPrevList);
// Reload the search list data
mAbstractSearchList->searchList()->reloadData();
// setup the same layout of the previous list control
if(mPrevList != mCurList)
{
int cols = mPrevList->getColumnCount();
for(int i = 0; i < cols; i++)
{
mCurList->setColumnOrder(i, mPrevList->getColumnOrder(i));
mCurList->setColumnHidden(i, mPrevList->getColumnHidden(i));
mCurList->setColumnWidth(i, mPrevList->getColumnWidth(i));
}
}
mAbstractSearchList->unlock();
}
void SearchListView::refreshSearchList()
@ -347,17 +345,3 @@ void SearchListView::searchSlot()
connect(thread, SIGNAL(setStyleSheet(QString)), mSearchBox, SLOT(setStyleSheet(QString)));
thread->start();
}
void SearchListView::LoadPrevListLayout(SearchListViewTable* mPrevList)
{
if(mPrevList == NULL || mPrevList == mCurList)
return;
int cols = mPrevList->getColumnCount();
for(int i = 0; i < cols; i++)
{
mCurList->setColumnOrder(i, mPrevList->getColumnOrder(i));
mCurList->setColumnHidden(i, mPrevList->getColumnHidden(i));
mCurList->setColumnWidth(i, mPrevList->getColumnWidth(i));
}
}

View File

@ -4,37 +4,28 @@
#include <QWidget>
#include <QLineEdit>
#include <QCheckBox>
#include "SearchListViewTable.h"
#include "MenuBuilder.h"
#include "ActionHelpers.h"
namespace Ui
{
class SearchListView;
}
#include "AbstractSearchList.h"
class SearchListView : public QWidget, public ActionHelper<SearchListView>
{
Q_OBJECT
public:
explicit SearchListView(bool EnableRegex = true, QWidget* parent = 0, bool EnableLock = false);
~SearchListView();
explicit SearchListView(QWidget* parent, AbstractSearchList* abstractSearchList, bool enableRegex, bool enableLock);
SearchListViewTable* mList;
SearchListViewTable* mSearchList;
SearchListViewTable* mCurList;
AbstractStdTable* mCurList;
QLineEdit* mSearchBox;
int mSearchStartCol;
QString mLastFirstColValue;
bool findTextInList(SearchListViewTable* list, QString text, int row, int startcol, bool startswith);
bool findTextInList(AbstractStdTable* list, QString text, int row, int startcol, bool startswith);
void refreshSearchList();
bool isSearchBoxLocked();
private slots:
void searchTextChanged(const QString & arg1);
void searchTextChanged(const QString & text);
void listContextMenu(const QPoint & pos);
void doubleClickedSlot();
void searchSlot();
@ -53,7 +44,7 @@ private:
QCheckBox* mLockCheckbox;
QAction* mSearchAction;
void LoadPrevListLayout(SearchListViewTable* mPrevList);
AbstractSearchList* mAbstractSearchList;
};
#endif // SEARCHLISTVIEW_H

View File

@ -1,305 +0,0 @@
#include "SearchListViewTable.h"
#include "Configuration.h"
#include "RichTextPainter.h"
#include "Bridge.h"
SearchListViewTable::SearchListViewTable(StdTable* parent)
: StdTable(parent),
bCipBase(false)
{
highlightText = "";
updateColors();
}
void SearchListViewTable::updateColors()
{
StdTable::updateColors();
mCipBackgroundColor = ConfigColor("DisassemblyCipBackgroundColor");
mCipColor = ConfigColor("DisassemblyCipColor");
mBreakpointBackgroundColor = ConfigColor("DisassemblyBreakpointBackgroundColor");
mBreakpointColor = ConfigColor("DisassemblyBreakpointColor");
mHardwareBreakpointBackgroundColor = ConfigColor("DisassemblyHardwareBreakpointBackgroundColor");
mHardwareBreakpointColor = ConfigColor("DisassemblyHardwareBreakpointColor");
mBookmarkBackgroundColor = ConfigColor("DisassemblyBookmarkBackgroundColor");
mBookmarkColor = ConfigColor("DisassemblyBookmarkColor");
mLabelColor = ConfigColor("DisassemblyLabelColor");
mLabelBackgroundColor = ConfigColor("DisassemblyLabelBackgroundColor");
mSelectedAddressBackgroundColor = ConfigColor("DisassemblySelectedAddressBackgroundColor");
mSelectedAddressColor = ConfigColor("DisassemblySelectedAddressColor");
mAddressBackgroundColor = ConfigColor("DisassemblyAddressBackgroundColor");
mAddressColor = ConfigColor("DisassemblyAddressColor");
mTracedBackgroundColor = ConfigColor("DisassemblyTracedBackgroundColor");
auto a = selectionColor, b = mTracedBackgroundColor;
mTracedSelectedAddressBackgroundColor = QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2, (a.blue() + b.blue()) / 2);
}
QString SearchListViewTable::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h)
{
bool isaddr = true;
bool wIsSelected = isSelected(rowBase, rowOffset);
QString text = getCellContent(rowBase + rowOffset, col);
if(!DbgIsDebugging())
isaddr = false;
if(!getRowCount())
isaddr = false;
duint wVA = duint(text.toULongLong(&isaddr, 16));
auto wIsTraced = isaddr && DbgFunctions()->GetTraceRecordHitCount(wVA) != 0;
QColor lineBackgroundColor;
bool isBackgroundColorSet;
if(wIsSelected && wIsTraced)
{
lineBackgroundColor = mTracedSelectedAddressBackgroundColor;
isBackgroundColorSet = true;
}
else if(wIsSelected)
{
lineBackgroundColor = selectionColor;
isBackgroundColorSet = true;
}
else if(wIsTraced)
{
lineBackgroundColor = mTracedBackgroundColor;
isBackgroundColorSet = true;
}
else
{
isBackgroundColorSet = false;
}
if(isBackgroundColorSet)
painter->fillRect(QRect(x, y, w, h), QBrush(lineBackgroundColor));
if(col == 0 && isaddr)
{
char label[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(wVA, SEG_DEFAULT, label)) //has label
{
char module[MAX_MODULE_SIZE] = "";
if(DbgGetModuleAt(wVA, module) && !QString(label).startsWith("JMP.&"))
text += " <" + QString(module) + "." + QString(label) + ">";
else
text += " <" + QString(label) + ">";
}
BPXTYPE bpxtype = DbgGetBpxTypeAt(wVA);
bool isbookmark = DbgGetBookmarkAt(wVA);
duint cip = Bridge::getBridge()->mLastCip;
if(bCipBase)
{
duint base = DbgFunctions()->ModBaseFromAddr(cip);
if(base)
cip = base;
}
if(DbgIsDebugging() && wVA == cip) //cip + not running
{
painter->fillRect(QRect(x, y, w, h), QBrush(mCipBackgroundColor));
if(!isbookmark) //no bookmark
{
if(bpxtype & bp_normal) //normal breakpoint
{
QColor & bpColor = mBreakpointBackgroundColor;
if(!bpColor.alpha()) //we don't want transparent text
bpColor = mBreakpointColor;
if(bpColor == mCipBackgroundColor)
bpColor = mCipColor;
painter->setPen(bpColor);
}
else if(bpxtype & bp_hardware) //hardware breakpoint only
{
QColor hwbpColor = mHardwareBreakpointBackgroundColor;
if(!hwbpColor.alpha()) //we don't want transparent text
hwbpColor = mHardwareBreakpointColor;
if(hwbpColor == mCipBackgroundColor)
hwbpColor = mCipColor;
painter->setPen(hwbpColor);
}
else //no breakpoint
{
painter->setPen(mCipColor);
}
}
else //bookmark
{
QColor bookmarkColor = mBookmarkBackgroundColor;
if(!bookmarkColor.alpha()) //we don't want transparent text
bookmarkColor = mBookmarkColor;
if(bookmarkColor == mCipBackgroundColor)
bookmarkColor = mCipColor;
painter->setPen(bookmarkColor);
}
}
else //non-cip address
{
if(!isbookmark) //no bookmark
{
if(*label) //label
{
if(bpxtype == bp_none) //label only : fill label background
{
painter->setPen(mLabelColor); //red -> address + label text
painter->fillRect(QRect(x, y, w, h), QBrush(mLabelBackgroundColor)); //fill label background
}
else //label + breakpoint
{
if(bpxtype & bp_normal) //label + normal breakpoint
{
painter->setPen(mBreakpointColor);
painter->fillRect(QRect(x, y, w, h), QBrush(mBreakpointBackgroundColor)); //fill red
}
else if(bpxtype & bp_hardware) //label + hardware breakpoint only
{
painter->setPen(mHardwareBreakpointColor);
painter->fillRect(QRect(x, y, w, h), QBrush(mHardwareBreakpointBackgroundColor)); //fill ?
}
else //other cases -> do as normal
{
painter->setPen(mLabelColor); //red -> address + label text
painter->fillRect(QRect(x, y, w, h), QBrush(mLabelBackgroundColor)); //fill label background
}
}
}
else //no label
{
if(bpxtype == bp_none) //no label, no breakpoint
{
QColor background;
if(wIsSelected)
{
background = mSelectedAddressBackgroundColor;
painter->setPen(mSelectedAddressColor); //black address (DisassemblySelectedAddressColor)
}
else
{
background = mAddressBackgroundColor;
painter->setPen(mAddressColor); //DisassemblyAddressColor
}
if(background.alpha())
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background
}
else //breakpoint only
{
if(bpxtype & bp_normal) //normal breakpoint
{
painter->setPen(mBreakpointColor);
painter->fillRect(QRect(x, y, w, h), QBrush(mBreakpointBackgroundColor)); //fill red
}
else if(bpxtype & bp_hardware) //hardware breakpoint only
{
painter->setPen(mHardwareBreakpointColor);
painter->fillRect(QRect(x, y, w, h), QBrush(mHardwareBreakpointBackgroundColor)); //fill red
}
else //other cases (memory breakpoint in disassembly) -> do as normal
{
QColor background;
if(wIsSelected)
{
background = mSelectedAddressBackgroundColor;
painter->setPen(mSelectedAddressColor); //black address (DisassemblySelectedAddressColor)
}
else
{
background = mAddressBackgroundColor;
painter->setPen(mAddressColor);
}
if(background.alpha())
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background
}
}
}
}
else //bookmark
{
if(*label) //label + bookmark
{
if(bpxtype == bp_none) //label + bookmark
{
painter->setPen(mLabelColor); //red -> address + label text
painter->fillRect(QRect(x, y, w, h), QBrush(mBookmarkBackgroundColor)); //fill label background
}
else //label + breakpoint + bookmark
{
QColor color = mBookmarkBackgroundColor;
if(!color.alpha()) //we don't want transparent text
color = mAddressColor;
painter->setPen(color);
if(bpxtype & bp_normal) //label + bookmark + normal breakpoint
{
painter->fillRect(QRect(x, y, w, h), QBrush(mBreakpointBackgroundColor)); //fill red
}
else if(bpxtype & bp_hardware) //label + bookmark + hardware breakpoint only
{
painter->fillRect(QRect(x, y, w, h), QBrush(mHardwareBreakpointBackgroundColor)); //fill ?
}
}
}
else //bookmark, no label
{
if(bpxtype == bp_none) //bookmark only
{
painter->setPen(mBookmarkColor); //black address
painter->fillRect(QRect(x, y, w, h), QBrush(mBookmarkBackgroundColor)); //fill bookmark color
}
else //bookmark + breakpoint
{
QColor color = mBookmarkBackgroundColor;
if(!color.alpha()) //we don't want transparent text
color = mAddressColor;
painter->setPen(color);
if(bpxtype & bp_normal) //bookmark + normal breakpoint
{
painter->fillRect(QRect(x, y, w, h), QBrush(mBreakpointBackgroundColor)); //fill red
}
else if(bpxtype & bp_hardware) //bookmark + hardware breakpoint only
{
painter->fillRect(QRect(x, y, w, h), QBrush(mHardwareBreakpointBackgroundColor)); //fill red
}
else //other cases (bookmark + memory breakpoint in disassembly) -> do as normal
{
painter->setPen(mBookmarkColor); //black address
painter->fillRect(QRect(x, y, w, h), QBrush(mBookmarkBackgroundColor)); //fill bookmark color
}
}
}
}
}
painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, text);
text = "";
}
else if(highlightText.length() && text.contains(highlightText, Qt::CaseInsensitive))
{
//super smart way of splitting while keeping the delimiters (thanks to cypher for guidance)
int index = -2;
do
{
index = text.indexOf(highlightText, index + 2, Qt::CaseInsensitive);
if(index != -1)
{
text = text.insert(index + highlightText.length(), QChar('\1'));
text = text.insert(index, QChar('\1'));
}
}
while(index != -1);
QStringList split = text.split(QChar('\1'), QString::SkipEmptyParts, Qt::CaseInsensitive);
//create rich text list
RichTextPainter::CustomRichText_t curRichText;
curRichText.flags = RichTextPainter::FlagColor;
curRichText.textColor = textColor;
curRichText.highlightColor = ConfigColor("SearchListViewHighlightColor");
RichTextPainter::List richText;
foreach(QString str, split)
{
curRichText.text = str;
curRichText.highlight = !str.compare(highlightText, Qt::CaseInsensitive);
richText.push_back(curRichText);
}
//paint the rich text
RichTextPainter::paintRichText(painter, x + 1, y, w, h, 4, richText, mFontMetrics);
text = "";
}
return text;
}

View File

@ -1,42 +0,0 @@
#ifndef SEARCHLISTVIEWTABLE_H
#define SEARCHLISTVIEWTABLE_H
#include "StdTable.h"
class SearchListViewTable : public StdTable
{
Q_OBJECT
public:
explicit SearchListViewTable(StdTable* parent = 0);
QString highlightText;
void updateColors() override;
void setCipBase(bool cipBase)
{
bCipBase = cipBase;
}
protected:
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
private:
QColor mCipBackgroundColor;
QColor mCipColor;
QColor mBreakpointBackgroundColor;
QColor mBreakpointColor;
QColor mHardwareBreakpointBackgroundColor;
QColor mHardwareBreakpointColor;
QColor mBookmarkBackgroundColor;
QColor mBookmarkColor;
QColor mLabelColor;
QColor mLabelBackgroundColor;
QColor mSelectedAddressBackgroundColor;
QColor mSelectedAddressColor;
QColor mAddressBackgroundColor;
QColor mAddressColor;
QColor mTracedBackgroundColor;
QColor mTracedSelectedAddressBackgroundColor;
bool bCipBase;
};
#endif // SEARCHLISTVIEWTABLE_H

View File

@ -0,0 +1,128 @@
#include "StdSearchListView.h"
#include "StdTable.h"
class StdTableSearchList : public AbstractSearchList
{
public:
friend class StdSearchListView;
StdTableSearchList()
{
mList = new StdTable();
mSearchList = new StdTable();
}
void lock() override { }
void unlock() override { }
AbstractStdTable* list() const override { return mList; }
AbstractStdTable* searchList() const override { return mSearchList; }
void filter(const QString & filter, FilterType type, int startColumn) override
{
mSearchList->setRowCount(0);
int rows = mList->getRowCount();
int columns = mList->getColumnCount();
for(int i = 0, j = 0; i < rows; i++)
{
if(rowMatchesFilter(filter, type, i, startColumn))
{
mSearchList->setRowCount(j + 1);
for(int k = 0; k < columns; k++)
{
mSearchList->setCellContent(j, k, mList->getCellContent(i, k));
mSearchList->setCellUserdata(j, k, mList->getCellUserdata(i, k));
}
j++;
}
}
}
private:
StdTable* mList;
StdTable* mSearchList;
};
StdSearchListView::StdSearchListView(QWidget* parent, bool enableRegex, bool enableLock)
: SearchListView(parent, mSearchListData = new StdTableSearchList(), enableRegex, enableLock)
{
}
StdSearchListView::~StdSearchListView()
{
delete mSearchListData;
}
void StdSearchListView::setInternalTitle(const QString & title)
{
stdList()->setWindowTitle(title);
}
int StdSearchListView::getCharWidth()
{
return stdList()->getCharWidth();
}
void StdSearchListView::addColumnAt(int width, QString title, bool isClickable)
{
stdList()->addColumnAt(width, title, isClickable);
stdSearchList()->addColumnAt(width, title, isClickable);
}
void StdSearchListView::setDrawDebugOnly(bool value)
{
stdList()->setDrawDebugOnly(value);
stdSearchList()->setDrawDebugOnly(value);
}
void StdSearchListView::enableMultiSelection(bool enabled)
{
stdList()->enableMultiSelection(enabled);
stdSearchList()->enableMultiSelection(enabled);
}
void StdSearchListView::setAddressColumn(int col, bool cipBase)
{
stdList()->setAddressColumn(col, cipBase);
stdSearchList()->setAddressColumn(col, cipBase);
}
void StdSearchListView::loadColumnFromConfig(const QString & viewName)
{
stdList()->loadColumnFromConfig(viewName);
stdSearchList()->loadColumnFromConfig(viewName);
}
void StdSearchListView::setRowCount(dsint count)
{
mSearchBox->setText("");
stdList()->setRowCount(count);
}
void StdSearchListView::setCellContent(int r, int c, QString s)
{
mSearchBox->setText("");
stdList()->setCellContent(r, c, s);
}
void StdSearchListView::reloadData()
{
mSearchBox->setText("");
stdList()->reloadData();
stdList()->setFocus();
}
void StdSearchListView::setSearchStartCol(int col)
{
if(col < stdList()->getColumnCount())
mSearchStartCol = col;
}
StdTable* StdSearchListView::stdList()
{
return mSearchListData->mList;
}
StdTable* StdSearchListView::stdSearchList()
{
return mSearchListData->mSearchList;
}

View File

@ -0,0 +1,39 @@
#ifndef STDSEARCHLISTVIEW_H
#define STDSEARCHLISTVIEW_H
#include "SearchListView.h"
#include "StdTable.h"
class StdTableSearchList;
class StdSearchListView : public SearchListView
{
public:
StdSearchListView(QWidget* parent, bool enableRegex, bool enableLock);
~StdSearchListView() override;
void setInternalTitle(const QString & title);
int getCharWidth();
void addColumnAt(int width, QString title, bool isClickable);
void setDrawDebugOnly(bool value);
void enableMultiSelection(bool enabled);
void setAddressColumn(int col, bool cipBase = false);
void loadColumnFromConfig(const QString & viewName);
public slots:
virtual void setRowCount(dsint count);
void setCellContent(int r, int c, QString s);
void reloadData();
void setSearchStartCol(int col);
private:
StdTableSearchList* mSearchListData;
protected:
friend class SymbolView;
friend class Bridge;
StdTable* stdList();
StdTable* stdSearchList();
};
#endif // STDSEARCHLISTVIEW_H

View File

@ -208,7 +208,7 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
case GUI_REF_ADDCOLUMN:
if(referenceManager->currentReferenceView())
referenceManager->currentReferenceView()->addColumnAt((int)param1, QString((const char*)param2));
referenceManager->currentReferenceView()->addColumnAtRef((int)param1, QString((const char*)param2));
break;
case GUI_REF_SETROWCOUNT:
@ -217,7 +217,7 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
case GUI_REF_GETROWCOUNT:
if(referenceManager->currentReferenceView())
return (void*)referenceManager->currentReferenceView()->mList->getRowCount();
return (void*)referenceManager->currentReferenceView()->stdList()->getRowCount();
return 0;
case GUI_REF_SEARCH_GETROWCOUNT:
@ -240,7 +240,7 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
{
QString content;
if(referenceManager->currentReferenceView())
content = referenceManager->currentReferenceView()->mList->getCellContent((int)param1, (int)param2);
content = referenceManager->currentReferenceView()->stdList()->getCellContent((int)param1, (int)param2);
auto bytes = content.toUtf8();
auto data = BridgeAlloc(bytes.size() + 1);
memcpy(data, bytes.constData(), bytes.size());
@ -840,10 +840,8 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
emit updateTraceBrowser();
break;
case GUI_SET_MODULE_SYMBOLS:
std::vector<void*> moduleSymbols;
BridgeList<void*>::ToVector((const ListInfo*)param2, moduleSymbols, false);
symbolView->setModuleSymbols(duint(param1), moduleSymbols);
case GUI_INVALIDATE_SYMBOL_SOURCE:
symbolView->invalidateSymbolSource(duint(param1));
break;
}

View File

@ -1,6 +1,7 @@
#include "AttachDialog.h"
#include "ui_AttachDialog.h"
#include "SearchListView.h"
#include "StdSearchListView.h"
#include "StdTable.h"
#include <QMenu>
#include <QMessageBox>
#include <QFileInfo>
@ -26,26 +27,18 @@ AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Attach
connect(ui->btnRefresh, SIGNAL(clicked()), this, SLOT(refresh()));
// Create search view (regex disabled)
mSearchListView = new SearchListView(false, this);
mSearchListView = new StdSearchListView(this, false, false);
mSearchListView->mSearchStartCol = 1;
ui->verticalLayout->insertWidget(0, mSearchListView);
//setup process list
int charwidth = mSearchListView->mList->getCharWidth();
mSearchListView->mList->addColumnAt(charwidth * sizeof(int) * 2 + 8, tr("PID"), true);
mSearchListView->mList->addColumnAt(150, tr("Name"), true);
mSearchListView->mList->addColumnAt(300, tr("Title"), true);
mSearchListView->mList->addColumnAt(500, tr("Path"), true);
mSearchListView->mList->addColumnAt(800, tr("Command Line Arguments"), true);
mSearchListView->mList->setDrawDebugOnly(false);
charwidth = mSearchListView->mSearchList->getCharWidth();
mSearchListView->mSearchList->addColumnAt(charwidth * sizeof(int) * 2 + 8, tr("PID"), true);
mSearchListView->mSearchList->addColumnAt(150, tr("Name"), true);
mSearchListView->mSearchList->addColumnAt(300, tr("Title"), true);
mSearchListView->mSearchList->addColumnAt(500, tr("Path"), true);
mSearchListView->mSearchList->addColumnAt(800, tr("Command Line Arguments"), true);
mSearchListView->mSearchList->setDrawDebugOnly(false);
int charwidth = mSearchListView->getCharWidth();
mSearchListView->addColumnAt(charwidth * sizeof(int) * 2 + 8, tr("PID"), true);
mSearchListView->addColumnAt(150, tr("Name"), true);
mSearchListView->addColumnAt(300, tr("Title"), true);
mSearchListView->addColumnAt(500, tr("Path"), true);
mSearchListView->addColumnAt(800, tr("Command Line Arguments"), true);
mSearchListView->setDrawDebugOnly(false);
connect(mSearchListView, SIGNAL(enterPressedSignal()), this, SLOT(on_btnAttach_clicked()));
connect(mSearchListView, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(processListContextMenu(QMenu*)));
@ -67,24 +60,22 @@ AttachDialog::~AttachDialog()
void AttachDialog::refresh()
{
mSearchListView->mList->setRowCount(0);
mSearchListView->mList->setTableOffset(0);
mSearchListView->setRowCount(0);
DBGPROCESSINFO* entries;
int count;
if(!DbgFunctions()->GetProcessList(&entries, &count))
return;
mSearchListView->mList->setRowCount(count);
mSearchListView->setRowCount(count);
for(int i = 0; i < count; i++)
{
QFileInfo fi(entries[i].szExeFile);
mSearchListView->mList->setCellContent(i, 0, QString().sprintf(ConfigBool("Gui", "PidInHex") ? "%.8X" : "%u", entries[i].dwProcessId));
mSearchListView->mList->setCellContent(i, 1, fi.baseName());
mSearchListView->mList->setCellContent(i, 2, QString(entries[i].szExeMainWindowTitle));
mSearchListView->mList->setCellContent(i, 3, QString(entries[i].szExeFile));
mSearchListView->mList->setCellContent(i, 4, QString(entries[i].szExeArgs));
mSearchListView->setCellContent(i, 0, QString().sprintf(ConfigBool("Gui", "PidInHex") ? "%.8X" : "%u", entries[i].dwProcessId));
mSearchListView->setCellContent(i, 1, fi.baseName());
mSearchListView->setCellContent(i, 2, QString(entries[i].szExeMainWindowTitle));
mSearchListView->setCellContent(i, 3, QString(entries[i].szExeFile));
mSearchListView->setCellContent(i, 4, QString(entries[i].szExeArgs));
}
mSearchListView->mList->setSingleSelection(0);
mSearchListView->mList->reloadData();
mSearchListView->reloadData();
mSearchListView->refreshSearchList();
}
@ -121,11 +112,11 @@ retryFindWindow:
refresh();
QString pidText = QString().sprintf(ConfigBool("Gui", "PidInHex") ? "%.8X" : "%u", pid);
bool found = false;
for(int i = 0; i < mSearchListView->mList->getRowCount(); i++)
for(int i = 0; i < mSearchListView->mCurList->getRowCount(); i++)
{
if(mSearchListView->mList->getCellContent(i, 0) == pidText)
if(mSearchListView->mCurList->getCellContent(i, 0) == pidText)
{
mSearchListView->mList->setSingleSelection(i);
mSearchListView->mCurList->setSingleSelection(i);
found = true;
break;
}

View File

@ -3,7 +3,7 @@
#include <QDialog>
class SearchListView;
class StdSearchListView;
class QMenu;
class QAction;
@ -28,9 +28,7 @@ private slots:
private:
Ui::AttachDialog* ui;
SearchListView* mSearchListView;
StdSearchListView* mSearchListView;
QAction* mAttachAction;
QAction* mRefreshAction;
};

View File

@ -149,7 +149,7 @@ void BreakpointsView::sortRows(int column, bool ascending)
QString BreakpointsView::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h)
{
if(isSelected(rowBase, rowOffset))
painter->fillRect(QRect(x, y, w, h), QBrush(col == ColDisasm ? mDisasmSelectionColor : selectionColor));
painter->fillRect(QRect(x, y, w, h), QBrush(col == ColDisasm ? mDisasmSelectionColor : mSelectionColor));
else if(col == ColDisasm)
painter->fillRect(QRect(x, y, w, h), QBrush(mDisasmBackgroundColor));
auto index = bpIndex(rowBase + rowOffset);
@ -304,7 +304,7 @@ void BreakpointsView::updateBreakpointsSlot()
RichTextPainter::CustomRichText_t token;
token.highlight = false;
token.flags = RichTextPainter::FlagColor;
token.textColor = this->textColor;
token.textColor = this->mTextColor;
token.text = text;
richSummary.push_back(token);
};

View File

@ -116,7 +116,7 @@ public slots:
void downloadCurrentSymbolsSlot();
protected:
void paintEvent(QPaintEvent* event);
void paintEvent(QPaintEvent* event) override;
private:
bool getLabelsFromInstruction(duint addr, QSet<QString> & labels);

View File

@ -294,7 +294,7 @@ void CPUDump::getColumnRichText(int col, dsint rva, RichTextPainter::List & rich
{
RichTextPainter::CustomRichText_t curData;
curData.flags = RichTextPainter::FlagColor;
curData.textColor = textColor;
curData.textColor = mTextColor;
duint data = 0;
mMemPage->read((byte_t*)&data, rva, sizeof(duint));
@ -643,8 +643,8 @@ void CPUDump::hexAsciiSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewHexAscii);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //hex byte
wColDesc.itemCount = 16;
@ -677,8 +677,8 @@ void CPUDump::hexUnicodeSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewHexUnicode);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //hex byte
wColDesc.itemCount = 16;
@ -715,8 +715,8 @@ void CPUDump::hexCodepageSlot()
auto codepage = dialog.getSelectedCodepage();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //hex byte
wColDesc.itemCount = 16;
@ -743,8 +743,8 @@ void CPUDump::hexLastCodepageSlot()
Config()->setUint("HexDump", "DefaultView", (duint)ViewHexCodepage);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
duint lastCodepage;
auto allCodecs = QTextCodec::availableCodecs();
if(!BridgeSettingGetUint("Misc", "LastCodepage", &lastCodepage) || lastCodepage >= duint(allCodecs.size()))
@ -774,8 +774,8 @@ void CPUDump::textLastCodepageSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewTextCodepage);
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
duint lastCodepage;
auto allCodecs = QTextCodec::availableCodecs();
if(!BridgeSettingGetUint("Misc", "LastCodepage", &lastCodepage) || lastCodepage >= duint(allCodecs.size()))
@ -797,8 +797,8 @@ void CPUDump::textAsciiSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewTextAscii);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //ascii byte
wColDesc.itemCount = 64;
@ -823,8 +823,8 @@ void CPUDump::textUnicodeSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewTextUnicode);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //unicode short
wColDesc.itemCount = 64;
@ -852,8 +852,8 @@ void CPUDump::textCodepageSlot()
return;
auto codepage = dialog.getSelectedCodepage();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //text (in code page)
wColDesc.itemCount = 64;
@ -871,8 +871,8 @@ void CPUDump::integerSignedByteSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerSignedByte);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //signed short
wColDesc.itemCount = 8;
@ -896,8 +896,8 @@ void CPUDump::integerSignedShortSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerSignedShort);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //signed short
wColDesc.itemCount = 8;
@ -921,8 +921,8 @@ void CPUDump::integerSignedLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerSignedLong);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //signed long
wColDesc.itemCount = 4;
@ -946,8 +946,8 @@ void CPUDump::integerSignedLongLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerSignedLongLong);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //signed long long
wColDesc.itemCount = 2;
@ -971,8 +971,8 @@ void CPUDump::integerUnsignedByteSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerUnsignedByte);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //unsigned short
wColDesc.itemCount = 8;
@ -996,8 +996,8 @@ void CPUDump::integerUnsignedShortSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerUnsignedShort);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //unsigned short
wColDesc.itemCount = 8;
@ -1021,8 +1021,8 @@ void CPUDump::integerUnsignedLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerUnsignedLong);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //unsigned long
wColDesc.itemCount = 4;
@ -1046,8 +1046,8 @@ void CPUDump::integerUnsignedLongLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerUnsignedLongLong);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //unsigned long long
wColDesc.itemCount = 2;
@ -1071,8 +1071,8 @@ void CPUDump::integerHexShortSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerHexShort);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //hex short
wColDesc.itemCount = 8;
@ -1096,8 +1096,8 @@ void CPUDump::integerHexLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerHexLong);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //hex long
wColDesc.itemCount = 4;
@ -1121,8 +1121,8 @@ void CPUDump::integerHexLongLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewIntegerHexLongLong);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //hex long long
wColDesc.itemCount = 2;
@ -1146,8 +1146,8 @@ void CPUDump::floatFloatSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewFloatFloat);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //float dword
wColDesc.itemCount = 4;
@ -1171,8 +1171,8 @@ void CPUDump::floatDoubleSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewFloatDouble);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //float qword
wColDesc.itemCount = 2;
@ -1196,8 +1196,8 @@ void CPUDump::floatLongDoubleSlot()
{
Config()->setUint("HexDump", "DefaultView", (duint)ViewFloatLongDouble);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //float qword
wColDesc.itemCount = 2;
@ -1227,8 +1227,8 @@ void CPUDump::addressSlot()
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddress);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //void*
wColDesc.itemCount = 1;
@ -1263,8 +1263,8 @@ void CPUDump::addressAsciiSlot()
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddressAscii);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //void*
wColDesc.itemCount = 1;
@ -1314,8 +1314,8 @@ void CPUDump::addressUnicodeSlot()
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddressUnicode);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //void*
wColDesc.itemCount = 1;

View File

@ -13,8 +13,8 @@ CPUStack::CPUStack(CPUMultiDump* multiDump, QWidget* parent) : HexDump(parent)
setWindowTitle("Stack");
setShowHeader(false);
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
bStackFrozen = false;
mMultiDump = multiDump;
@ -61,9 +61,9 @@ void CPUStack::updateColors()
{
HexDump::updateColors();
backgroundColor = ConfigColor("StackBackgroundColor");
textColor = ConfigColor("StackTextColor");
selectionColor = ConfigColor("StackSelectionColor");
mBackgroundColor = ConfigColor("StackBackgroundColor");
mTextColor = ConfigColor("StackTextColor");
mSelectionColor = ConfigColor("StackSelectionColor");
mStackReturnToColor = ConfigColor("StackReturnToColor");
mStackSEHChainColor = ConfigColor("StackSEHChainColor");
mUserStackFrameColor = ConfigColor("StackFrameColor");
@ -341,7 +341,7 @@ void CPUStack::getColumnRichText(int col, dsint rva, RichTextPainter::List & ric
RichTextPainter::CustomRichText_t curData;
curData.highlight = false;
curData.flags = RichTextPainter::FlagColor;
curData.textColor = textColor;
curData.textColor = mTextColor;
if(col && mDescriptor.at(col - 1).isData == true) //paint stack data
{
@ -369,13 +369,13 @@ void CPUStack::getColumnRichText(int col, dsint rva, RichTextPainter::List & ric
else if(strcmp(comment.color, "!rtnclr") == 0)
curData.textColor = mStackReturnToColor;
else
curData.textColor = textColor;
curData.textColor = mTextColor;
}
else
curData.textColor = QColor(QString(comment.color));
}
else
curData.textColor = textColor;
curData.textColor = mTextColor;
}
else
curData.textColor = ConfigColor("StackInactiveTextColor");
@ -395,7 +395,7 @@ QString CPUStack::paintContent(QPainter* painter, dsint rowBase, int rowOffset,
bool wIsSelected = isSelected(wRva);
if(wIsSelected) //highlight if selected
painter->fillRect(QRect(x, y, w, h), QBrush(selectionColor));
painter->fillRect(QRect(x, y, w, h), QBrush(mSelectionColor));
if(col == 0) // paint stack address
{

View File

@ -22,7 +22,7 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
mSideBar = new CPUSideBar(mDisas);
mArgumentWidget = new CPUArgumentWidget(this);
connect(mDisas, SIGNAL(tableOffsetChanged(dsint)), mSideBar, SLOT(changeTopmostAddress(dsint)));
connect(mDisas, SIGNAL(viewableRows(int)), mSideBar, SLOT(setViewableRows(int)));
connect(mDisas, SIGNAL(viewableRowsChanged(int)), mSideBar, SLOT(setViewableRows(int)));
connect(mDisas, SIGNAL(selectionChanged(dsint)), mSideBar, SLOT(setSelection(dsint)));
connect(mDisas, SIGNAL(disassembledAt(dsint, dsint, bool, dsint)), mArgumentWidget, SLOT(disassembledAtSlot(dsint, dsint, bool, dsint)));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), mSideBar, SLOT(debugStateChangedSlot(DBGSTATE)));

View File

@ -1,135 +0,0 @@
#include <QVBoxLayout>
#include "CommandHelpView.h"
#include "ui_CommandHelpView.h"
#include "SearchListView.h"
CommandHelpView::CommandHelpView(QWidget* parent) : QWidget(parent), ui(new Ui::CommandHelpView)
{
ui->setupUi(this);
mCurrentMode = 0;
// Set main layout
mMainLayout = new QVBoxLayout;
mMainLayout->setContentsMargins(0, 0, 0, 0);
mMainLayout->addWidget(ui->mainSplitter);
setLayout(mMainLayout);
// Create reference view
mSearchListView = new SearchListView(true, this);
mSearchListView->mSearchStartCol = 1;
// Get font information
QFont wFont("Monospace", 8, QFont::Normal, false);
wFont.setStyleHint(QFont::Monospace);
wFont.setFixedPitch(true);
//int charwidth=QFontMetrics(wFont).width(QChar(' '));
// Create module list
mModuleList = new StdTable();
mModuleList->addColumnAt(0, tr("Module"), true);
// Setup symbol list
mSearchListView->mList->addColumnAt(0, tr("Command"), true);
// Setup search list
mSearchListView->mSearchList->addColumnAt(0, tr("Command"), true);
// Setup list splitter
ui->listSplitter->addWidget(mModuleList);
ui->listSplitter->addWidget(mSearchListView);
#ifdef _WIN64
// mModuleList : mSymbolList = 40 : 100
ui->listSplitter->setStretchFactor(0, 40);
ui->listSplitter->setStretchFactor(1, 100);
#else
// mModuleList : mSymbolList = 30 : 100
ui->listSplitter->setStretchFactor(0, 30);
ui->listSplitter->setStretchFactor(1, 100);
#endif //_WIN64
// Setup log edit
ui->symbolLogEdit->setFont(wFont);
ui->symbolLogEdit->setStyleSheet("QTextEdit { background-color: rgb(255, 251, 240) }");
ui->symbolLogEdit->setUndoRedoEnabled(false);
ui->symbolLogEdit->setReadOnly(true);
// Log : List = 2 : 9
ui->mainSplitter->setStretchFactor(1, 9);
ui->mainSplitter->setStretchFactor(0, 1);
connect(mModuleList, SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int)));
connect(mSearchListView->mList, SIGNAL(selectionChangedSignal(int)), this, SLOT(symbolSelectionChanged(int)));
//fill with example data
mModuleList->setRowCount(2);
mModuleList->setCellContent(0, 0, "x64dbg");
mModuleList->setCellContent(1, 0, "testplugin");
mModuleList->setSingleSelection(0);
}
CommandHelpView::~CommandHelpView()
{
delete ui;
}
void CommandHelpView::moduleSelectionChanged(int index)
{
mSearchListView->mList->setRowCount(0);
if(index == 0) //x64dbg
{
mCurrentMode = 0;
mSearchListView->mList->setRowCount(3);
mSearchListView->mList->setCellContent(0, 0, "InitDebug");
mSearchListView->mList->setCellContent(1, 0, "StopDebug");
mSearchListView->mList->setCellContent(2, 0, "run");
}
else if(index == 1) //testplugin
{
mCurrentMode = 1;
mSearchListView->mList->setRowCount(2);
mSearchListView->mList->setCellContent(0, 0, "plugin1");
mSearchListView->mList->setCellContent(1, 0, "grs");
}
mSearchListView->mList->reloadData();
mSearchListView->mList->setSingleSelection(0);
mSearchListView->mList->setTableOffset(0);
mSearchListView->mList->setFocus();
mSearchListView->mSearchBox->setText("");
}
void CommandHelpView::symbolSelectionChanged(int index)
{
QString info = "";
if(mCurrentMode == 0) //x64dbg
{
switch(index)
{
case 0: //InitDebug
info = tr("Initialize debugging a file.\n\nExample:\nInitDebug \"C:\\test.exe\", commandline, \"C:\\homeDir\"");
break;
case 1: //StopDebug
info = tr("Stop debugging (terminate the target).\n\nExample:\nStopDebug");
break;
case 2: //run
info = tr("Resume debugging.\n\nExample:\nrun");
break;
}
}
else if(mCurrentMode == 1) //testplugin
{
switch(index)
{
case 0: //plugin1
info = "Just a simple plugin test command.\n\nExample:\nplugin1";
break;
case 1: //grs
info = "Get relocation table size.\n\nExample:\ngrs 404000";
break;
}
}
ui->symbolLogEdit->setText(info);
}

View File

@ -1,38 +0,0 @@
#ifndef COMMANDHELPVIEW_H
#define COMMANDHELPVIEW_H
#include <QWidget>
class QVBoxLayout;
class SearchListView;
class StdTable;
namespace Ui
{
class CommandHelpView;
}
class CommandHelpView : public QWidget
{
Q_OBJECT
public:
explicit CommandHelpView(QWidget* parent = 0);
~CommandHelpView();
private slots:
void moduleSelectionChanged(int index);
void symbolSelectionChanged(int index);
signals:
void showCpu();
private:
Ui::CommandHelpView* ui;
QVBoxLayout* mMainLayout;
SearchListView* mSearchListView;
StdTable* mModuleList;
int mCurrentMode;
};
#endif // COMMANDHELPVIEW_H

View File

@ -1,103 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CommandHelpView</class>
<widget class="QWidget" name="CommandHelpView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>694</width>
<height>605</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QSplitter" name="mainSplitter">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>691</width>
<height>601</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<widget class="QSplitter" name="listSplitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>2</number>
</property>
<property name="childrenCollapsible">
<bool>false</bool>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="logLayout">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QTextEdit" name="symbolLogEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="symbolProgress">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>15</height>
</size>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -5,76 +5,55 @@
#include "LabeledSplitter.h"
#include "StringUtil.h"
#include "ReferenceView.h"
#include "StdSearchListView.h"
#include "MainWindow.h"
#include "MessagesBreakpoints.h"
#include <QVBoxLayout>
HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
{
mHandlesTable = new SearchListView(true, this, true);
mHandlesTable->mList->setWindowTitle("Handles");
mHandlesTable->mSearchStartCol = 0;
int wCharWidth = mHandlesTable->mList->getCharWidth();
// Setup handles list
mHandlesTable->mList->setDrawDebugOnly(true);
mHandlesTable->mList->addColumnAt(8 + 16 * wCharWidth, tr("Type"), true);
mHandlesTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("Type number"), true);
mHandlesTable->mList->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Handle"), true);
mHandlesTable->mList->addColumnAt(8 + 16 * wCharWidth, tr("Access"), true);
mHandlesTable->mList->addColumnAt(8 + wCharWidth * 20, tr("Name"), true);
mHandlesTable->mList->loadColumnFromConfig("Handle");
// Setup search list
mHandlesTable->mSearchList->addColumnAt(8 + 16 * wCharWidth, tr("Type"), true);
mHandlesTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("Type number"), true);
mHandlesTable->mSearchList->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Handle"), true);
mHandlesTable->mSearchList->addColumnAt(8 + 16 * wCharWidth, tr("Access"), true);
mHandlesTable->mSearchList->addColumnAt(8 + wCharWidth * 20, tr("Name"), true);
mHandlesTable->mSearchList->loadColumnFromConfig("Handle");
mWindowsTable = new SearchListView(true, this, true);
mWindowsTable->mList->setWindowTitle("Windows");
mWindowsTable->mSearchStartCol = 0;
// Setup windows list
mWindowsTable->mList->setDrawDebugOnly(true);
mWindowsTable->mList->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Proc"), true);
mWindowsTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("Handle"), true);
mWindowsTable->mList->addColumnAt(8 + 120 * wCharWidth, tr("Title"), true);
mWindowsTable->mList->addColumnAt(8 + 40 * wCharWidth, tr("Class"), true);
mWindowsTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("Thread"), true);
mWindowsTable->mList->addColumnAt(8 + 16 * wCharWidth, tr("Style"), true);
mWindowsTable->mList->addColumnAt(8 + 16 * wCharWidth, tr("StyleEx"), true);
mWindowsTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("Parent"), true);
mWindowsTable->mList->addColumnAt(8 + 20 * wCharWidth, tr("Size"), true);
mWindowsTable->mList->addColumnAt(8 + 6 * wCharWidth, tr("Enable"), true);
mWindowsTable->mList->loadColumnFromConfig("Window");
// Setup search list
mWindowsTable->mSearchList->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Proc"), true);
mWindowsTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("Handle"), true);
mWindowsTable->mSearchList->addColumnAt(8 + 120 * wCharWidth, tr("Title"), true);
mWindowsTable->mSearchList->addColumnAt(8 + 40 * wCharWidth, tr("Class"), true);
mWindowsTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("Thread"), true);
mWindowsTable->mSearchList->addColumnAt(8 + 16 * wCharWidth, tr("Style"), true);
mWindowsTable->mSearchList->addColumnAt(8 + 16 * wCharWidth, tr("StyleEx"), true);
mWindowsTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("Parent"), true);
mWindowsTable->mSearchList->addColumnAt(8 + 20 * wCharWidth, tr("Size"), true);
mWindowsTable->mSearchList->addColumnAt(8 + 6 * wCharWidth, tr("Enable"), true);
mWindowsTable->mSearchList->loadColumnFromConfig("Window");
mTcpConnectionsTable = new SearchListView(true, this, true);
mTcpConnectionsTable->setWindowTitle("TcpConnections");
mHandlesTable = new StdSearchListView(this, true, true);
mHandlesTable->setInternalTitle("Handles");
mHandlesTable->mSearchStartCol = 0;
// create tcp list
mTcpConnectionsTable->mList->setDrawDebugOnly(true);
mTcpConnectionsTable->mList->addColumnAt(8 + 64 * wCharWidth, tr("Remote address"), true);
mTcpConnectionsTable->mList->addColumnAt(8 + 64 * wCharWidth, tr("Local address"), true);
mTcpConnectionsTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("State"), true);
mTcpConnectionsTable->mList->loadColumnFromConfig("TcpConnection");
// create search list
mTcpConnectionsTable->mSearchList->addColumnAt(8 + 64 * wCharWidth, tr("Remote address"), true);
mTcpConnectionsTable->mSearchList->addColumnAt(8 + 64 * wCharWidth, tr("Local address"), true);
mTcpConnectionsTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("State"), true);
mTcpConnectionsTable->mSearchList->loadColumnFromConfig("TcpConnection");
mHandlesTable->setDrawDebugOnly(true);
int wCharWidth = mHandlesTable->getCharWidth();
mHandlesTable->addColumnAt(8 + 16 * wCharWidth, tr("Type"), true);
mHandlesTable->addColumnAt(8 + 8 * wCharWidth, tr("Type number"), true);
mHandlesTable->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Handle"), true);
mHandlesTable->addColumnAt(8 + 16 * wCharWidth, tr("Access"), true);
mHandlesTable->addColumnAt(8 + wCharWidth * 20, tr("Name"), true);
mHandlesTable->loadColumnFromConfig("Handle");
// Setup windows list
mWindowsTable = new StdSearchListView(this, true, true);
mWindowsTable->setInternalTitle("Windows");
mWindowsTable->setSearchStartCol(0);
mWindowsTable->setDrawDebugOnly(true);
wCharWidth = mWindowsTable->getCharWidth();
mWindowsTable->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Proc"), true);
mWindowsTable->addColumnAt(8 + 8 * wCharWidth, tr("Handle"), true);
mWindowsTable->addColumnAt(8 + 120 * wCharWidth, tr("Title"), true);
mWindowsTable->addColumnAt(8 + 40 * wCharWidth, tr("Class"), true);
mWindowsTable->addColumnAt(8 + 8 * wCharWidth, tr("Thread"), true);
mWindowsTable->addColumnAt(8 + 16 * wCharWidth, tr("Style"), true);
mWindowsTable->addColumnAt(8 + 16 * wCharWidth, tr("StyleEx"), true);
mWindowsTable->addColumnAt(8 + 8 * wCharWidth, tr("Parent"), true);
mWindowsTable->addColumnAt(8 + 20 * wCharWidth, tr("Size"), true);
mWindowsTable->addColumnAt(8 + 6 * wCharWidth, tr("Enable"), true);
mWindowsTable->loadColumnFromConfig("Window");
// Setup tcp list
mTcpConnectionsTable = new StdSearchListView(this, true, true);
mTcpConnectionsTable->setInternalTitle("TcpConnections");
mTcpConnectionsTable->setSearchStartCol(0);
mTcpConnectionsTable->setDrawDebugOnly(true);
wCharWidth = mTcpConnectionsTable->getCharWidth();
mTcpConnectionsTable->addColumnAt(8 + 64 * wCharWidth, tr("Remote address"), true);
mTcpConnectionsTable->addColumnAt(8 + 64 * wCharWidth, tr("Local address"), true);
mTcpConnectionsTable->addColumnAt(8 + 8 * wCharWidth, tr("State"), true);
mTcpConnectionsTable->loadColumnFromConfig("TcpConnection");
/*
mHeapsTable = new ReferenceView(this);
mHeapsTable->setWindowTitle("Heaps");
@ -84,6 +63,7 @@ HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
mHeapsTable->addColumnAt(20, tr("Flags"));
mHeapsTable->addColumnAt(50, tr("Comments"));
*/
mPrivilegesTable = new StdTable(this);
mPrivilegesTable->setWindowTitle("Privileges");
mPrivilegesTable->setDrawDebugOnly(true);
@ -143,10 +123,11 @@ HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
if(!IsWindowsVistaOrGreater())
{
mTcpConnectionsTable->mList->setRowCount(1);
mTcpConnectionsTable->mList->setCellContent(0, 0, tr("TCP Connection enumeration is only available on Windows Vista or greater."));
mTcpConnectionsTable->mList->reloadData();
mTcpConnectionsTable->setRowCount(1);
mTcpConnectionsTable->setCellContent(0, 0, tr("TCP Connection enumeration is only available on Windows Vista or greater."));
mTcpConnectionsTable->reloadData();
}
reloadData();
refreshShortcuts();
}
@ -163,12 +144,12 @@ void HandlesView::reloadData()
}
else
{
mHandlesTable->mList->setRowCount(0);
mHandlesTable->mList->reloadData();
mWindowsTable->mList->setRowCount(0);
mWindowsTable->mList->reloadData();
mTcpConnectionsTable->mList->setRowCount(0);
mTcpConnectionsTable->mList->reloadData();
mHandlesTable->setRowCount(0);
mHandlesTable->reloadData();
mWindowsTable->setRowCount(0);
mWindowsTable->reloadData();
mTcpConnectionsTable->setRowCount(0);
mTcpConnectionsTable->reloadData();
//mHeapsTable->setRowCount(0);
//mHeapsTable->reloadData();
@ -192,7 +173,7 @@ void HandlesView::handlesTableContextMenuSlot(QMenu* wMenu)
{
if(!DbgIsDebugging())
return;
StdTable & table = *mHandlesTable->mCurList;
auto & table = *mHandlesTable->mCurList;
QMenu wCopyMenu(tr("&Copy"), this);
wCopyMenu.setIcon(DIcon("copy.png"));
@ -214,7 +195,7 @@ void HandlesView::windowsTableContextMenuSlot(QMenu* wMenu)
{
if(!DbgIsDebugging())
return;
StdTable & table = *mWindowsTable->mCurList;
auto & table = *mWindowsTable->mCurList;
QMenu wCopyMenu(tr("Copy"), this);
wCopyMenu.setIcon(DIcon("copy.png"));
wMenu->addAction(mActionRefresh);
@ -249,7 +230,7 @@ void HandlesView::tcpConnectionsTableContextMenuSlot(QMenu* wMenu)
{
if(!DbgIsDebugging())
return;
StdTable & table = *mTcpConnectionsTable->mCurList;
auto & table = *mTcpConnectionsTable->mCurList;
QMenu wCopyMenu(tr("&Copy"), this);
wCopyMenu.setIcon(DIcon("copy.png"));
@ -359,7 +340,7 @@ void HandlesView::followInDisasmSlot()
void HandlesView::toggleBPSlot()
{
StdTable & mCurList = *mWindowsTable->mCurList;
auto & mCurList = *mWindowsTable->mCurList;
if(!DbgIsDebugging())
return;
@ -386,7 +367,7 @@ void HandlesView::toggleBPSlot()
void HandlesView::messagesBPSlot()
{
StdTable & mCurList = *mWindowsTable->mCurList;
auto & mCurList = *mWindowsTable->mCurList;
MessagesBreakpoints::MsgBreakpointData mbpData;
if(!mCurList.getRowCount())
@ -407,26 +388,27 @@ void HandlesView::enumHandles()
if(DbgFunctions()->EnumHandles(&handles))
{
auto count = handles.Count();
mHandlesTable->mList->setRowCount(count);
mHandlesTable->setRowCount(count);
for(auto i = 0; i < count; i++)
{
const HANDLEINFO & handle = handles[i];
char name[MAX_STRING_SIZE] = "";
char typeName[MAX_STRING_SIZE] = "";
DbgFunctions()->GetHandleName(handle.Handle, name, sizeof(name), typeName, sizeof(typeName));
mHandlesTable->mList->setCellContent(i, 0, typeName);
mHandlesTable->mList->setCellContent(i, 1, ToHexString(handle.TypeNumber));
mHandlesTable->mList->setCellContent(i, 2, ToHexString(handle.Handle));
mHandlesTable->mList->setCellContent(i, 3, ToHexString(handle.GrantedAccess));
mHandlesTable->mList->setCellContent(i, 4, name);
mHandlesTable->setCellContent(i, 0, typeName);
mHandlesTable->setCellContent(i, 1, ToHexString(handle.TypeNumber));
mHandlesTable->setCellContent(i, 2, ToHexString(handle.Handle));
mHandlesTable->setCellContent(i, 3, ToHexString(handle.GrantedAccess));
mHandlesTable->setCellContent(i, 4, name);
}
}
else
mHandlesTable->mList->setRowCount(0);
mHandlesTable->mList->reloadData();
mHandlesTable->setRowCount(0);
mHandlesTable->reloadData();
// refresh values also when in mSearchList
mHandlesTable->refreshSearchList();
}
//Enumerate windows and update windows table
void HandlesView::enumWindows()
{
@ -434,35 +416,35 @@ void HandlesView::enumWindows()
if(DbgFunctions()->EnumWindows(&windows))
{
auto count = windows.Count();
mWindowsTable->mList->setRowCount(count);
mWindowsTable->setRowCount(count);
for(auto i = 0; i < count; i++)
{
mWindowsTable->mList->setCellContent(i, 0, ToPtrString(windows[i].wndProc));
mWindowsTable->mList->setCellContent(i, 1, ToHexString(windows[i].handle));
mWindowsTable->mList->setCellContent(i, 2, QString(windows[i].windowTitle));
mWindowsTable->mList->setCellContent(i, 3, QString(windows[i].windowClass));
mWindowsTable->setCellContent(i, 0, ToPtrString(windows[i].wndProc));
mWindowsTable->setCellContent(i, 1, ToHexString(windows[i].handle));
mWindowsTable->setCellContent(i, 2, QString(windows[i].windowTitle));
mWindowsTable->setCellContent(i, 3, QString(windows[i].windowClass));
char threadname[MAX_THREAD_NAME_SIZE];
if(DbgFunctions()->ThreadGetName(windows[i].threadId, threadname))
mWindowsTable->mList->setCellContent(i, 4, QString::fromUtf8(threadname));
mWindowsTable->setCellContent(i, 4, QString::fromUtf8(threadname));
else if(Config()->getBool("Gui", "PidInHex"))
mWindowsTable->mList->setCellContent(i, 4, ToHexString(windows[i].threadId));
mWindowsTable->setCellContent(i, 4, ToHexString(windows[i].threadId));
else
mWindowsTable->mList->setCellContent(i, 4, QString::number(windows[i].threadId));
mWindowsTable->setCellContent(i, 4, QString::number(windows[i].threadId));
//Style
mWindowsTable->mList->setCellContent(i, 5, ToHexString(windows[i].style));
mWindowsTable->setCellContent(i, 5, ToHexString(windows[i].style));
//StyleEx
mWindowsTable->mList->setCellContent(i, 6, ToHexString(windows[i].styleEx));
mWindowsTable->mList->setCellContent(i, 7, ToHexString(windows[i].parent) + (windows[i].parent == ((duint)GetDesktopWindow()) ? tr(" (Desktop window)") : ""));
mWindowsTable->setCellContent(i, 6, ToHexString(windows[i].styleEx));
mWindowsTable->setCellContent(i, 7, ToHexString(windows[i].parent) + (windows[i].parent == ((duint)GetDesktopWindow()) ? tr(" (Desktop window)") : ""));
//Size
QString sizeText = QString("(%1,%2);%3x%4").arg(windows[i].position.left).arg(windows[i].position.top)
.arg(windows[i].position.right - windows[i].position.left).arg(windows[i].position.bottom - windows[i].position.top);
mWindowsTable->mList->setCellContent(i, 8, sizeText);
mWindowsTable->mList->setCellContent(i, 9, windows[i].enabled != FALSE ? tr("Enabled") : tr("Disabled"));
mWindowsTable->setCellContent(i, 8, sizeText);
mWindowsTable->setCellContent(i, 9, windows[i].enabled != FALSE ? tr("Enabled") : tr("Disabled"));
}
}
else
mWindowsTable->mList->setRowCount(0);
mWindowsTable->mList->reloadData();
mWindowsTable->setRowCount(0);
mWindowsTable->reloadData();
// refresh values also when in mSearchList
mWindowsTable->refreshSearchList();
}
@ -527,6 +509,7 @@ void HandlesView::AppendPrivilege(int row, const char* PrivilegeString)
break;
}
}
//Enumerate TCP connections and update TCP connections table
void HandlesView::enumTcpConnections()
{
@ -534,23 +517,24 @@ void HandlesView::enumTcpConnections()
if(DbgFunctions()->EnumTcpConnections(&connections))
{
auto count = connections.Count();
mTcpConnectionsTable->mList->setRowCount(count);
mTcpConnectionsTable->setRowCount(count);
for(auto i = 0; i < count; i++)
{
const TCPCONNECTIONINFO & connection = connections[i];
auto remoteText = QString("%1:%2").arg(connection.RemoteAddress).arg(connection.RemotePort);
mTcpConnectionsTable->mList->setCellContent(i, 0, remoteText);
mTcpConnectionsTable->setCellContent(i, 0, remoteText);
auto localText = QString("%1:%2").arg(connection.LocalAddress).arg(connection.LocalPort);
mTcpConnectionsTable->mList->setCellContent(i, 1, localText);
mTcpConnectionsTable->mList->setCellContent(i, 2, connection.StateText);
mTcpConnectionsTable->setCellContent(i, 1, localText);
mTcpConnectionsTable->setCellContent(i, 2, connection.StateText);
}
}
else
mTcpConnectionsTable->mList->setRowCount(0);
mTcpConnectionsTable->mList->reloadData();
mTcpConnectionsTable->setRowCount(0);
mTcpConnectionsTable->reloadData();
// refresh values also when in mSearchList
mTcpConnectionsTable->refreshSearchList();
}
/*
//Enumerate Heaps and update Heaps table
void HandlesView::enumHeaps()

View File

@ -8,7 +8,7 @@ class StdTable;
class ReferenceView;
class QVBoxLayout;
class LabeledSplitter;
class SearchListView;
class StdSearchListView;
class QMenu;
class HandlesView : public QWidget
@ -41,9 +41,9 @@ public slots:
private:
QVBoxLayout* mVertLayout;
LabeledSplitter* mSplitter;
SearchListView* mHandlesTable;
SearchListView* mTcpConnectionsTable;
SearchListView* mWindowsTable;
StdSearchListView* mHandlesTable;
StdSearchListView* mTcpConnectionsTable;
StdSearchListView* mWindowsTable;
//ReferenceView* mHeapsTable;
StdTable* mPrivilegesTable;

View File

@ -284,7 +284,7 @@ QString MemoryMapView::paintContent(QPainter* painter, dsint rowBase, int rowOff
#else //x86
duint addr = wStr.toULong(0, 16);
#endif //_WIN64
QColor color = textColor;
QColor color = mTextColor;
QColor backgroundColor = Qt::transparent;
bool isBp = (DbgGetBpxTypeAt(addr) & bp_memory) == bp_memory;
bool isCip = addr == mCipBase;
@ -304,7 +304,7 @@ QString MemoryMapView::paintContent(QPainter* painter, dsint rowBase, int rowOff
backgroundColor = ConfigColor("MemoryMapCipBackgroundColor");
}
else if(isSelected(rowBase, rowOffset) == true)
painter->fillRect(QRect(x, y, w, h), QBrush(selectionColor));
painter->fillRect(QRect(x, y, w, h), QBrush(mSelectionColor));
if(backgroundColor.alpha())
painter->fillRect(QRect(x, y, w - 1, h), QBrush(backgroundColor));

View File

@ -59,8 +59,8 @@ void ScriptView::updateColors()
{
StdTable::updateColors();
selectionColor = ConfigColor("DisassemblySelectionColor");
backgroundColor = ConfigColor("DisassemblyBackgroundColor");
mSelectionColor = ConfigColor("DisassemblySelectionColor");
mBackgroundColor = ConfigColor("DisassemblyBackgroundColor");
}
QString ScriptView::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h)
@ -68,7 +68,7 @@ QString ScriptView::paintContent(QPainter* painter, dsint rowBase, int rowOffset
bool wIsSelected = isSelected(rowBase, rowOffset);
// Highlight if selected
if(wIsSelected)
painter->fillRect(QRect(x, y, w, h), QBrush(selectionColor)); //ScriptViewSelectionColor
painter->fillRect(QRect(x, y, w, h), QBrush(mSelectionColor)); //ScriptViewSelectionColor
QString returnString;
int line = rowBase + rowOffset + 1;
SCRIPTLINETYPE linetype = DbgScriptGetLineType(line);

View File

@ -12,12 +12,12 @@ SourceView::SourceView(QString path, int line, QWidget* parent)
mIpLine(0)
{
mSourcePath = path;
mList->enableColumnSorting(false);
mSearchList->enableColumnSorting(false);
stdList()->enableColumnSorting(false);
stdSearchList()->enableColumnSorting(false);
addColumnAt(sizeof(duint) * 2, tr("Address"));
addColumnAt(6, tr("Line"));
addColumnAt(0, tr("Code"));
addColumnAtRef(sizeof(duint) * 2, tr("Address"));
addColumnAtRef(6, tr("Line"));
addColumnAtRef(0, tr("Code"));
connect(this, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(sourceContextMenu(QMenu*)));

View File

@ -6,11 +6,74 @@
#include "YaraRuleSelectionDialog.h"
#include "EntropyDialog.h"
#include "BrowseDialog.h"
#include "SearchListView.h"
#include "StdSearchListView.h"
#include "ZehSymbolTable.h"
#include <QVBoxLayout>
#include <QProcess>
#include <QFileDialog>
class SymbolSearchList : public AbstractSearchList
{
public:
friend class SymbolView;
SymbolSearchList()
{
mList = new ZehSymbolTable();
mSearchList = new ZehSymbolTable();
}
void lock() override
{
mList->mMutex.lock();
mSearchList->mMutex.lock();
}
void unlock() override
{
mSearchList->mMutex.unlock();
mList->mMutex.unlock();
}
AbstractStdTable* list() const override
{
return mList;
}
AbstractStdTable* searchList() const override
{
return mSearchList;
}
void filter(const QString & filter, FilterType type, int startColumn) override
{
mSearchList->setRowCount(0);
mSearchList->mData.clear();
mSearchList->mData.reserve(mList->mData.size());
mSearchList->mModules = mList->mModules;
int rows = mList->getRowCount();
for(int i = 0, j = 0; i < rows; i++)
{
if(rowMatchesFilter(filter, type, i, startColumn))
{
mSearchList->setRowCount(j + 1);
mSearchList->mData.push_back(mList->mData.at(i));
j++;
}
}
}
void addAction(QAction* action)
{
mList->addAction(action);
mSearchList->addAction(action);
}
private:
ZehSymbolTable* mList;
ZehSymbolTable* mSearchList;
};
SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView)
{
ui->setupUi(this);
@ -22,51 +85,26 @@ SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView
mMainLayout->addWidget(ui->mainSplitter);
setLayout(mMainLayout);
// Create symbol table
mSymbolTable = new ZehSymbolTable(this);
// Create reference view
mSearchListView = new SearchListView(true, this, true);
mSearchListView->mSearchStartCol = 1;
mSearchListView->setVisible(false);
mSymbolSearchList = new SymbolSearchList();
mSymbolList = new SearchListView(this, mSymbolSearchList, true, true);
mSymbolList->mSearchStartCol = 1;
// Create module list
mModuleList = new SearchListView(true, this);
mModuleList->mSearchStartCol = 0;
int charwidth = mModuleList->mList->getCharWidth();
mModuleList->mList->enableMultiSelection(true);
mModuleList->mList->setCipBase(true);
mModuleList->mList->addColumnAt(charwidth * 2 * sizeof(dsint) + 8, tr("Base"), true);
mModuleList->mList->addColumnAt(300, tr("Module"), true);
mModuleList->mList->addColumnAt(charwidth * 8, tr("Party"), true);
mModuleList->mList->addColumnAt(charwidth * 60, tr("Path"), true);
mModuleList->mList->loadColumnFromConfig("Module");
mModuleList->mSearchList->setCipBase(true);
mModuleList->mSearchList->addColumnAt(charwidth * 2 * sizeof(dsint) + 8, tr("Base"), true);
mModuleList->mSearchList->addColumnAt(300, "Module", true);
mModuleList->mSearchList->addColumnAt(charwidth * 8, tr("Party"), true);
mModuleList->mSearchList->addColumnAt(charwidth * 60, tr("Path"), true);
mModuleList->mSearchList->loadColumnFromConfig("Module");
// Setup symbol list
mSearchListView->mList->enableMultiSelection(true);
mSearchListView->mList->addColumnAt(charwidth * 2 * sizeof(dsint) + 8, tr("Address"), true);
mSearchListView->mList->addColumnAt(charwidth * 6 + 8, tr("Type"), true);
mSearchListView->mList->addColumnAt(charwidth * 80, tr("Symbol"), true);
mSearchListView->mList->addColumnAt(2000, tr("Symbol (undecorated)"), true);
mSearchListView->mList->loadColumnFromConfig("Symbol");
// Setup search list
mSearchListView->mSearchList->enableMultiSelection(true);
mSearchListView->mSearchList->addColumnAt(charwidth * 2 * sizeof(dsint) + 8, tr("Address"), true);
mSearchListView->mSearchList->addColumnAt(charwidth * 6 + 8, tr("Type"), true);
mSearchListView->mSearchList->addColumnAt(charwidth * 80, tr("Symbol"), true);
mSearchListView->mSearchList->addColumnAt(2000, tr("Symbol (undecorated)"), true);
mSearchListView->mSearchList->loadColumnFromConfig("Symbol");
mModuleList = new StdSearchListView(this, true, false);
mModuleList->setSearchStartCol(0);
mModuleList->enableMultiSelection(true);
mModuleList->setAddressColumn(0, true);
int charwidth = mModuleList->getCharWidth();
mModuleList->addColumnAt(charwidth * 2 * sizeof(dsint) + 8, tr("Base"), true);
mModuleList->addColumnAt(300, tr("Module"), true);
mModuleList->addColumnAt(charwidth * 8, tr("Party"), true);
mModuleList->addColumnAt(charwidth * 60, tr("Path"), true);
mModuleList->loadColumnFromConfig("Module");
// Setup list splitter
ui->listSplitter->addWidget(mModuleList);
ui->listSplitter->addWidget(mSymbolTable);
ui->listSplitter->addWidget(mSymbolList);
#ifdef _WIN64
// mModuleList : mSymbolList = 40 : 100
ui->listSplitter->setStretchFactor(0, 40);
@ -96,8 +134,8 @@ SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView
connect(Bridge::getBridge(), SIGNAL(clearLog()), this, SLOT(clearSymbolLogSlot()));
connect(Bridge::getBridge(), SIGNAL(clearSymbolLog()), this, SLOT(clearSymbolLogSlot()));
connect(Bridge::getBridge(), SIGNAL(selectionSymmodGet(SELECTIONDATA*)), this, SLOT(selectionGetSlot(SELECTIONDATA*)));
connect(mModuleList->mList, SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int)));
connect(mModuleList->mSearchList, SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int)));
connect(mModuleList->stdList(), SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int)));
connect(mModuleList->stdSearchList(), SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int)));
connect(mModuleList, SIGNAL(emptySearchResult()), this, SLOT(emptySearchResultSlot()));
connect(mModuleList, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(moduleContextMenu(QMenu*)));
connect(mModuleList, SIGNAL(enterPressedSignal()), this, SLOT(moduleFollow()));
@ -105,8 +143,8 @@ SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView
connect(Bridge::getBridge(), SIGNAL(setSymbolProgress(int)), ui->symbolProgress, SLOT(setValue(int)));
connect(Bridge::getBridge(), SIGNAL(symbolRefreshCurrent()), this, SLOT(symbolRefreshCurrent()));
connect(Bridge::getBridge(), SIGNAL(symbolSelectModule(duint)), this, SLOT(symbolSelectModule(duint)));
connect(mSearchListView, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(symbolContextMenu(QMenu*)));
connect(mSearchListView, SIGNAL(enterPressedSignal()), this, SLOT(enterPressedSlot()));
connect(mSymbolList, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(symbolContextMenu(QMenu*)));
connect(mSymbolList, SIGNAL(enterPressedSignal()), this, SLOT(enterPressedSlot()));
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateStyle()));
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateStyle()));
}
@ -114,6 +152,7 @@ SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView
SymbolView::~SymbolView()
{
delete ui;
delete mSymbolSearchList;
}
inline void saveSymbolsSplitter(QSplitter* splitter, QString name)
@ -144,11 +183,26 @@ void SymbolView::loadWindowSettings()
loadSymbolsSplitter(ui->mainSplitter, "mHSymbolsLogSplitter");
}
void SymbolView::setModuleSymbols(duint base, const std::vector<void*> & symbols)
void SymbolView::invalidateSymbolSource(duint base)
{
//TODO: reload actual symbol list, race conditions
GuiSymbolLogAdd(QString("[SymbolView] base: %1, count: %2\n").arg(ToPtrString(base)).arg(symbols.size()).toUtf8().constData());
mModuleSymbolMap[base] = symbols;
mSymbolSearchList->lock();
for(auto mod : mSymbolSearchList->mList->mModules)
{
if(mod == base)
{
mSymbolSearchList->mList->mData.clear();
mSymbolSearchList->mList->mData.shrink_to_fit();
mSymbolSearchList->mList->setRowCount(0);
mSymbolSearchList->mSearchList->mData.clear();
mSymbolSearchList->mSearchList->mData.shrink_to_fit();
mSymbolSearchList->mSearchList->setRowCount(0);
mSymbolSearchList->mSearchList->setHighlightText(QString());
GuiSymbolLogAdd(QString("[SymbolView] reload symbols for base %1\n").arg(ToPtrString(base)).toUtf8().constData());
// TODO: properly reload symbol list
break;
}
}
mSymbolSearchList->unlock();
}
void SymbolView::setupContextMenu()
@ -167,15 +221,13 @@ void SymbolView::setupContextMenu()
mToggleBreakpoint = new QAction(DIcon("breakpoint.png"), tr("Toggle Breakpoint"), this);
mToggleBreakpoint->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mToggleBreakpoint);
mSearchListView->mList->addAction(mToggleBreakpoint);
mSearchListView->mSearchList->addAction(mToggleBreakpoint);
mSymbolSearchList->addAction(mToggleBreakpoint);
connect(mToggleBreakpoint, SIGNAL(triggered()), this, SLOT(toggleBreakpoint()));
mToggleBookmark = new QAction(DIcon("bookmark_toggle.png"), tr("Toggle Bookmark"), this);
mToggleBookmark->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mToggleBookmark);
mSearchListView->mList->addAction(mToggleBookmark);
mSearchListView->mSearchList->addAction(mToggleBookmark);
mSymbolSearchList->addAction(mToggleBookmark);
connect(mToggleBookmark, SIGNAL(triggered()), this, SLOT(toggleBookmark()));
//Modules
@ -190,50 +242,43 @@ void SymbolView::setupContextMenu()
mFollowInMemMap = new QAction(DIcon("memmap_find_address_page.png"), tr("Follow in Memory Map"), this);
mFollowInMemMap->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mFollowInMemMap);
mModuleList->mList->addAction(mFollowInMemMap);
mModuleList->mSearchList->addAction(mFollowInMemMap);
mModuleList->addAction(mFollowInMemMap);
connect(mFollowInMemMap, SIGNAL(triggered()), this, SLOT(moduleFollowMemMap()));
mDownloadSymbolsAction = new QAction(DIcon("pdb.png"), tr("&Download Symbols for This Module"), this);
mDownloadSymbolsAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mDownloadSymbolsAction);
mModuleList->mList->addAction(mDownloadSymbolsAction);
mModuleList->mSearchList->addAction(mDownloadSymbolsAction);
mModuleList->addAction(mDownloadSymbolsAction);
connect(mDownloadSymbolsAction, SIGNAL(triggered()), this, SLOT(moduleDownloadSymbols()));
mDownloadAllSymbolsAction = new QAction(DIcon("pdb.png"), tr("Download Symbols for &All Modules"), this);
mDownloadAllSymbolsAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mDownloadAllSymbolsAction);
mModuleList->mList->addAction(mDownloadAllSymbolsAction);
mModuleList->mSearchList->addAction(mDownloadAllSymbolsAction);
mModuleList->addAction(mDownloadAllSymbolsAction);
connect(mDownloadAllSymbolsAction, SIGNAL(triggered()), this, SLOT(moduleDownloadAllSymbols()));
mCopyPathAction = new QAction(DIcon("copyfilepath.png"), tr("Copy File &Path"), this);
mCopyPathAction->setShortcutContext(Qt::WidgetShortcut);
this->addAction(mCopyPathAction);
mModuleList->mList->addAction(mCopyPathAction);
mModuleList->mSearchList->addAction(mCopyPathAction);
mModuleList->addAction(mCopyPathAction);
connect(mCopyPathAction, SIGNAL(triggered()), this, SLOT(moduleCopyPath()));
mBrowseInExplorer = new QAction(DIcon("browseinexplorer.png"), tr("Browse in Explorer"), this);
mBrowseInExplorer->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mBrowseInExplorer);
mModuleList->mList->addAction(mBrowseInExplorer);
mModuleList->mSearchList->addAction(mBrowseInExplorer);
mModuleList->addAction(mBrowseInExplorer);
connect(mBrowseInExplorer, SIGNAL(triggered()), this, SLOT(moduleBrowse()));
mLoadLib = new QAction(DIcon("lib_load.png"), tr("Load library..."), this);
mLoadLib->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mLoadLib);
mModuleList->mList->addAction(mLoadLib);
mModuleList->mSearchList->addAction(mLoadLib);
mModuleList->addAction(mLoadLib);
connect(mLoadLib, SIGNAL(triggered()), this, SLOT(moduleLoad()));
mFreeLib = new QAction(DIcon("lib_free.png"), tr("Free library"), this);
mFreeLib->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mFreeLib);
mModuleList->mList->addAction(mFreeLib);
mModuleList->mSearchList->addAction(mFreeLib);
mModuleList->addAction(mFreeLib);
connect(mFreeLib, SIGNAL(triggered()), this, SLOT(moduleFree()));
mYaraAction = new QAction(DIcon("yara.png"), tr("&Yara Memory..."), this);
@ -245,29 +290,25 @@ void SymbolView::setupContextMenu()
mEntropyAction = new QAction(DIcon("entropy.png"), tr("Entropy..."), this);
mEntropyAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mEntropyAction);
mModuleList->mList->addAction(mEntropyAction);
mModuleList->mSearchList->addAction(mEntropyAction);
mModuleList->addAction(mEntropyAction);
connect(mEntropyAction, SIGNAL(triggered()), this, SLOT(moduleEntropy()));
mModSetUserAction = new QAction(DIcon("markasuser.png"), tr("Mark as &user module"), this);
mModSetUserAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mModSetUserAction);
mModuleList->mList->addAction(mModSetUserAction);
mModuleList->mSearchList->addAction(mModSetUserAction);
mModuleList->addAction(mModSetUserAction);
connect(mModSetUserAction, SIGNAL(triggered()), this, SLOT(moduleSetUser()));
mModSetSystemAction = new QAction(DIcon("markassystem.png"), tr("Mark as &system module"), this);
mModSetSystemAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mModSetSystemAction);
mModuleList->mList->addAction(mModSetSystemAction);
mModuleList->mSearchList->addAction(mModSetSystemAction);
mModuleList->addAction(mModSetSystemAction);
connect(mModSetSystemAction, SIGNAL(triggered()), this, SLOT(moduleSetSystem()));
mModSetPartyAction = new QAction(DIcon("markasparty.png"), tr("Mark as &party..."), this);
mModSetPartyAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(mModSetPartyAction);
mModuleList->mList->addAction(mModSetPartyAction);
mModuleList->mSearchList->addAction(mModSetPartyAction);
mModuleList->addAction(mModSetPartyAction);
connect(mModSetPartyAction, SIGNAL(triggered()), this, SLOT(moduleSetParty()));
//Shortcuts
@ -307,79 +348,55 @@ void SymbolView::clearSymbolLogSlot()
ui->symbolLogEdit->clear();
}
void SymbolView::cbSymbolEnum(SYMBOLINFO* symbol, void* user)
{
StdTable* symbolList = (StdTable*)user;
dsint index = symbolList->getRowCount();
symbolList->setRowCount(index + 1);
symbolList->setCellContent(index, 0, ToPtrString(symbol->addr));
if(symbol->decoratedSymbol)
{
symbolList->setCellContent(index, 2, symbol->decoratedSymbol);
}
else
{
symbolList->setCellContent(index, 2, QString());
}
if(symbol->undecoratedSymbol)
{
symbolList->setCellContent(index, 3, symbol->undecoratedSymbol);
}
else
{
symbolList->setCellContent(index, 3, QString());
}
if(symbol->isImported)
{
symbolList->setCellContent(index, 1, tr("Import"));
}
else
{
symbolList->setCellContent(index, 1, tr("Export"));
}
}
void SymbolView::moduleSelectionChanged(int index)
{
Q_UNUSED(index);
setUpdatesEnabled(false);
/*mSearchListView->mList->setRowCount(0);
std::vector<duint> selectedModules;
for(auto index : mModuleList->mCurList->getSelection())
{
QString mod = mModuleList->mCurList->getCellContent(index, 1);
if(!mModuleBaseList.count(mod))
continue;
DbgSymbolEnumFromCache(mModuleBaseList[mod], cbSymbolEnum, mSearchListView->mList);
QString modBase = mModuleList->mCurList->getCellContent(index, 0);
duint wVA;
if(DbgFunctions()->ValFromString(modBase.toUtf8().constData(), &wVA))
selectedModules.push_back(wVA);
}
mSearchListView->mList->reloadData();
mSearchListView->mList->setSingleSelection(0);
mSearchListView->mList->setTableOffset(0);
if(!mSearchListView->isSearchBoxLocked())
mSearchListView->mSearchBox->setText("");
else
mSearchListView->refreshSearchList();*/
QString modBase = mModuleList->mCurList->getCellContent(mModuleList->mCurList->getInitialSelection(), 0);
duint wVA;
if(!DbgFunctions()->ValFromString(modBase.toUtf8().constData(), &wVA))
return;
mSymbolTable->mData = mModuleSymbolMap[wVA];
mSymbolTable->setRowCount(mSymbolTable->mData.size());
mSymbolTable->reloadData();
std::vector<SYMBOLPTR> data;
for(auto base : selectedModules)
{
DbgSymbolEnum(base, [](const SYMBOLPTR * info, void* userdata)
{
((std::vector<SYMBOLPTR>*)userdata)->push_back(*info);
return true; // TODO: allow aborting (enumeration in a separate thread)
}, &data);
}
mSymbolSearchList->lock();
mSymbolSearchList->mList->mModules = std::move(selectedModules);
mSymbolSearchList->mList->mData = std::move(data);
mSymbolSearchList->mList->setRowCount(mSymbolSearchList->mList->mData.size());
mSymbolSearchList->unlock();
mSymbolSearchList->mList->setSingleSelection(0);
mSymbolSearchList->mList->setTableOffset(0);
mSymbolSearchList->mList->reloadData();
if(!mSymbolList->isSearchBoxLocked())
mSymbolList->mSearchBox->setText("");
else
mSymbolList->refreshSearchList();
setUpdatesEnabled(true);
}
void SymbolView::updateSymbolList(int module_count, SYMBOLMODULEINFO* modules)
{
mModuleList->mList->setRowCount(module_count);
mModuleList->stdList()->setRowCount(module_count);
if(!module_count)
{
mSearchListView->mList->setRowCount(0);
mSearchListView->mList->setSingleSelection(0);
mModuleList->mList->setSingleSelection(0);
// TODO
//mSymbolList->mList->setRowCount(0);
//mSymbolList->mList->setSingleSelection(0);
mModuleList->stdList()->setSingleSelection(0);
}
mModuleBaseList.clear();
@ -388,27 +405,27 @@ void SymbolView::updateSymbolList(int module_count, SYMBOLMODULEINFO* modules)
QString modName(modules[i].name);
mModuleBaseList.insert(modName, modules[i].base);
int party = DbgFunctions()->ModGetParty(modules[i].base);
mModuleList->mList->setCellContent(i, 0, ToPtrString(modules[i].base));
mModuleList->mList->setCellUserdata(i, 0, modules[i].base);
mModuleList->mList->setCellContent(i, 1, modName);
mModuleList->stdList()->setCellContent(i, 0, ToPtrString(modules[i].base));
mModuleList->stdList()->setCellUserdata(i, 0, modules[i].base);
mModuleList->stdList()->setCellContent(i, 1, modName);
switch(party)
{
case 0:
mModuleList->mList->setCellContent(i, 2, tr("User"));
mModuleList->stdList()->setCellContent(i, 2, tr("User"));
break;
case 1:
mModuleList->mList->setCellContent(i, 2, tr("System"));
mModuleList->stdList()->setCellContent(i, 2, tr("System"));
break;
default:
mModuleList->mList->setCellContent(i, 2, tr("Party: %1").arg(party));
mModuleList->stdList()->setCellContent(i, 2, tr("Party: %1").arg(party));
break;
}
char szModPath[MAX_PATH] = "";
if(!DbgFunctions()->ModPathFromAddr(modules[i].base, szModPath, _countof(szModPath)))
*szModPath = '\0';
mModuleList->mList->setCellContent(i, 3, szModPath);
mModuleList->stdList()->setCellContent(i, 3, szModPath);
}
mModuleList->mList->reloadData();
mModuleList->stdList()->reloadData();
//NOTE: DO NOT CALL mModuleList->refreshSearchList() IT WILL DEGRADE PERFORMANCE!
if(modules)
BridgeFree(modules);
@ -416,11 +433,11 @@ void SymbolView::updateSymbolList(int module_count, SYMBOLMODULEINFO* modules)
void SymbolView::symbolContextMenu(QMenu* wMenu)
{
if(!mSearchListView->mCurList->getRowCount())
if(!mSymbolList->mCurList->getRowCount())
return;
wMenu->addAction(mFollowSymbolAction);
wMenu->addAction(mFollowSymbolDumpAction);
if(mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 1) == tr("Import"))
if(mSymbolList->mCurList->getCellContent(mSymbolList->mCurList->getInitialSelection(), 1) == tr("Import"))
wMenu->addAction(mFollowSymbolImportAction);
wMenu->addSeparator();
wMenu->addAction(mToggleBreakpoint);
@ -429,22 +446,22 @@ void SymbolView::symbolContextMenu(QMenu* wMenu)
void SymbolView::symbolRefreshCurrent()
{
mModuleList->mList->setSingleSelection(mModuleList->mList->getInitialSelection());
mModuleList->stdList()->setSingleSelection(mModuleList->stdList()->getInitialSelection());
}
void SymbolView::symbolFollow()
{
DbgCmdExec(QString("disasm " + mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0)).toUtf8().constData());
DbgCmdExec(QString("disasm " + mSymbolList->mCurList->getCellContent(mSymbolList->mCurList->getInitialSelection(), 0)).toUtf8().constData());
}
void SymbolView::symbolFollowDump()
{
DbgCmdExecDirect(QString("dump " + mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0)).toUtf8().constData());
DbgCmdExecDirect(QString("dump " + mSymbolList->mCurList->getCellContent(mSymbolList->mCurList->getInitialSelection(), 0)).toUtf8().constData());
}
void SymbolView::symbolFollowImport()
{
auto addrText = mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0);
auto addrText = mSymbolList->mCurList->getCellContent(mSymbolList->mCurList->getInitialSelection(), 0);
auto addr = DbgValFromString(QString("[%1]").arg(addrText).toUtf8().constData());
if(!DbgMemIsValidReadPtr(addr))
return;
@ -461,12 +478,12 @@ void SymbolView::symbolFollowImport()
void SymbolView::symbolSelectModule(duint base)
{
for(dsint i = 0; i < mModuleList->mList->getRowCount(); i++)
for(dsint i = 0; i < mModuleList->stdList()->getRowCount(); i++)
{
if(mModuleList->mList->getCellUserdata(i, 0) == base)
if(mModuleList->stdList()->getCellUserdata(i, 0) == base)
{
mModuleList->mList->setSingleSelection(i);
mModuleList->mSearchList->hide(); //This could be described as a hack, but you could also say it's like wiping sandpaper over your new white Tesla.
mModuleList->stdList()->setSingleSelection(i);
mModuleList->stdSearchList()->hide(); //This could be described as a hack, but you could also say it's like wiping sandpaper over your new white Tesla.
mModuleList->mSearchBox->clear();
break;
}
@ -475,10 +492,10 @@ void SymbolView::symbolSelectModule(duint base)
void SymbolView::enterPressedSlot()
{
auto addr = DbgValFromString(mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0).toUtf8().constData());
auto addr = DbgValFromString(mSymbolList->mCurList->getCellContent(mSymbolList->mCurList->getInitialSelection(), 0).toUtf8().constData());
if(!DbgMemIsValidReadPtr(addr))
return;
if(mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 1) == tr("Import"))
if(mSymbolList->mCurList->getCellContent(mSymbolList->mCurList->getInitialSelection(), 1) == tr("Import"))
symbolFollowImport();
else if(DbgFunctions()->MemIsCodePage(addr, false))
symbolFollow();
@ -625,20 +642,20 @@ void SymbolView::toggleBreakpoint()
if(!DbgIsDebugging())
return;
if(!mSearchListView->mCurList->getRowCount())
if(!mSymbolList->mCurList->getRowCount())
return;
auto selection = mSearchListView->mCurList->getSelection();
auto selection = mSymbolList->mCurList->getSelection();
for(auto selectedIdx : selection)
{
QString addrText = mSearchListView->mCurList->getCellContent(selectedIdx, 0);
QString addrText = mSymbolList->mCurList->getCellContent(selectedIdx, 0);
duint wVA;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &wVA))
return;
//Import means that the address is an IAT entry so we read the actual function address
if(mSearchListView->mCurList->getCellContent(selectedIdx, 1) == tr("Import"))
if(mSymbolList->mCurList->getCellContent(selectedIdx, 1) == tr("Import"))
DbgMemRead(wVA, &wVA, sizeof(wVA));
if(!DbgMemIsValidReadPtr(wVA))
@ -665,9 +682,9 @@ void SymbolView::toggleBookmark()
if(!DbgIsDebugging())
return;
if(!mSearchListView->mCurList->getRowCount())
if(!mSymbolList->mCurList->getRowCount())
return;
QString addrText = mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0);
QString addrText = mSymbolList->mCurList->getCellContent(mSymbolList->mCurList->getInitialSelection(), 0);
duint wVA;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &wVA))
return;
@ -709,8 +726,7 @@ void SymbolView::moduleSetSystem()
int i = mModuleList->mCurList->getInitialSelection();
duint modbase = DbgValFromString(mModuleList->mCurList->getCellContent(i, 0).toUtf8().constData());
DbgFunctions()->ModSetParty(modbase, 1);
mModuleList->mCurList->setCellContent(i, 2, tr("System"));
mModuleList->mCurList->reloadData();
DbgFunctions()->RefreshModuleList();
}
void SymbolView::moduleSetUser()
@ -718,8 +734,7 @@ void SymbolView::moduleSetUser()
int i = mModuleList->mCurList->getInitialSelection();
duint modbase = DbgValFromString(mModuleList->mCurList->getCellContent(i, 0).toUtf8().constData());
DbgFunctions()->ModSetParty(modbase, 0);
mModuleList->mCurList->setCellContent(i, 2, tr("User"));
mModuleList->mCurList->reloadData();
DbgFunctions()->RefreshModuleList();
}
void SymbolView::moduleSetParty()
@ -736,6 +751,7 @@ void SymbolView::moduleSetParty()
if(ok)
{
DbgFunctions()->ModSetParty(modbase, party);
/* TODO: refresh module list
switch(party)
{
case 0:
@ -748,7 +764,7 @@ void SymbolView::moduleSetParty()
mModuleList->mCurList->setCellContent(i, 2, tr("Party: %1").arg(party));
break;
}
mModuleList->mCurList->reloadData();
mModuleList->mCurList->reloadData();*/
}
else
SimpleErrorBox(this, tr("Error"), tr("The party number can only be an integer"));
@ -764,7 +780,7 @@ void SymbolView::moduleFollowMemMap()
void SymbolView::emptySearchResultSlot()
{
// No result after search
mSearchListView->mCurList->setRowCount(0);
mSymbolList->mCurList->setRowCount(0);
}
void SymbolView::selectionGetSlot(SELECTIONDATA* selection)

View File

@ -3,10 +3,11 @@
#include <QWidget>
#include "Bridge.h"
#include "ZehSymbolTable.h"
class QMenu;
class StdSearchListView;
class SearchListView;
class SymbolSearchList;
class QVBoxLayout;
namespace Ui
@ -20,12 +21,12 @@ class SymbolView : public QWidget
public:
explicit SymbolView(QWidget* parent = 0);
~SymbolView();
~SymbolView() override;
void setupContextMenu();
void saveWindowSettings();
void loadWindowSettings();
void setModuleSymbols(duint base, const std::vector<void*> & symbols);
void invalidateSymbolSource(duint base);
private slots:
void updateStyle();
@ -70,9 +71,9 @@ private:
QVBoxLayout* mMainLayout;
QVBoxLayout* mSymbolLayout;
QWidget* mSymbolPlaceHolder;
SearchListView* mSearchListView;
SearchListView* mModuleList;
ZehSymbolTable* mSymbolTable;
SearchListView* mSymbolList;
StdSearchListView* mModuleList;
SymbolSearchList* mSymbolSearchList;
QMap<QString, duint> mModuleBaseList;
QAction* mFollowSymbolAction;
QAction* mFollowSymbolDumpAction;
@ -95,8 +96,6 @@ private:
QAction* mLoadLib;
QAction* mFreeLib;
std::map<duint, std::vector<void*>> mModuleSymbolMap;
static void cbSymbolEnum(SYMBOLINFO* symbol, void* user);
};

View File

@ -10,8 +10,8 @@ class WatchView : public StdTable
public:
WatchView(CPUMultiDump* parent);
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
void updateColors();
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) override;
void updateColors() override;
public slots:
void contextMenuSlot(const QPoint & event);

View File

@ -1,33 +1,71 @@
#include "ZehSymbolTable.h"
#include "Bridge.h"
#include "RichTextPainter.h"
class SymbolInfoWrapper
{
SYMBOLINFO info;
public:
SymbolInfoWrapper()
{
memset(&info, 0, sizeof(SYMBOLINFO));
}
~SymbolInfoWrapper()
{
if(info.freeDecorated)
BridgeFree(info.decoratedSymbol);
if(info.freeUndecorated)
BridgeFree(info.undecoratedSymbol);
}
SYMBOLINFO* operator&() { return &info; }
SYMBOLINFO* operator->() { return &info; }
};
ZehSymbolTable::ZehSymbolTable(QWidget* parent)
: AbstractStdTable(parent)
: AbstractStdTable(parent),
mMutex(QMutex::Recursive)
{
auto charwidth = getCharWidth();
//enableMultiSelection(true); //TODO
enableMultiSelection(true);
setAddressColumn(0);
addColumnAt(charwidth * 2 * sizeof(dsint) + 8, tr("Address"), true);
addColumnAt(charwidth * 6 + 8, tr("Type"), true);
addColumnAt(charwidth * 80, tr("Symbol"), true);
addColumnAt(2000, tr("Symbol (undecorated)"), true);
//loadColumnFromConfig("Symbol"); //TODO
loadColumnFromConfig("Symbol");
updateColors();
}
QString ZehSymbolTable::getCellContent(int r, int c)
{
QMutexLocker lock(&mMutex);
if(!isValidIndex(r, c))
return QString();
SYMBOLINFO info = {0};
DbgGetSymbolInfo(mData.at(r), &info);
SymbolInfoWrapper info;
DbgGetSymbolInfo(&mData.at(r), &info);
switch(c)
{
case ColAddr:
return ToPtrString(info.addr);
return ToPtrString(info->addr);
case ColType:
return info.isImported ? tr("Import") : tr("Export");
switch(info->type)
{
case sym_import:
return tr("Import");
case sym_export:
return tr("Export");
case sym_symbol:
return tr("Symbol");
default:
__debugbreak();
}
case ColDecorated:
return info.decoratedSymbol;
return info->decoratedSymbol;
case ColUndecorated:
return info.undecoratedSymbol;
return info->undecoratedSymbol;
default:
return QString();
}
@ -35,30 +73,32 @@ QString ZehSymbolTable::getCellContent(int r, int c)
bool ZehSymbolTable::isValidIndex(int r, int c)
{
QMutexLocker lock(&mMutex);
return r >= 0 && r < mData.size() && c >= 0 && c <= ColUndecorated;
}
void ZehSymbolTable::sortRows(int column, bool ascending)
{
std::stable_sort(mData.begin(), mData.end(), [column, ascending](void* a, void* b)
QMutexLocker lock(&mMutex);
std::stable_sort(mData.begin(), mData.end(), [column, ascending](const SYMBOLPTR & a, const SYMBOLPTR & b)
{
SYMBOLINFO ainfo, binfo;
DbgGetSymbolInfo(a, &ainfo);
DbgGetSymbolInfo(b, &binfo);
SymbolInfoWrapper ainfo, binfo;
DbgGetSymbolInfo(&a, &ainfo);
DbgGetSymbolInfo(&b, &binfo);
bool less;
switch(column)
{
case ColAddr:
less = ainfo.addr < binfo.addr;
less = ainfo->addr < binfo->addr;
break;
case ColType:
less = ainfo.isImported < binfo.isImported;
less = ainfo->type < binfo->type;
break;
case ColDecorated:
less = strcmp(ainfo.decoratedSymbol, binfo.decoratedSymbol) < 0;
less = strcmp(ainfo->decoratedSymbol, binfo->decoratedSymbol) < 0;
break;
case ColUndecorated:
less = strcmp(ainfo.undecoratedSymbol, binfo.undecoratedSymbol) < 0;
less = strcmp(ainfo->undecoratedSymbol, binfo->undecoratedSymbol) < 0;
break;
}
return ascending ? less : !less;

View File

@ -1,21 +1,26 @@
#pragma once
#include "AbstractStdTable.h"
#include <QMutex>
class ZehSymbolTable : public AbstractStdTable
{
Q_OBJECT
public:
ZehSymbolTable(QWidget* parent);
ZehSymbolTable(QWidget* parent = nullptr);
QString getCellContent(int r, int c) override;
bool isValidIndex(int r, int c) override;
void sortRows(int column, bool ascending) override;
friend class SymbolView;
friend class SearchListViewSymbols;
friend class SymbolSearchList;
private:
std::vector<void*> mData;
std::vector<duint> mModules;
std::vector<SYMBOLPTR> mData;
QMutex mMutex;
enum
{

View File

@ -132,7 +132,7 @@ QString TraceBrowser::paintContent(QPainter* painter, dsint rowBase, int rowOffs
bool wIsSelected = (index >= mSelection.fromIndex && index <= mSelection.toIndex);
if(wIsSelected)
{
painter->fillRect(QRect(x, y, w, h), QBrush(selectionColor));
painter->fillRect(QRect(x, y, w, h), QBrush(mSelectionColor));
}
if(index >= mTraceFile->Length())
return "";
@ -836,7 +836,7 @@ void TraceBrowser::updateColors()
AbstractTableView::updateColors();
//CapstoneTokenizer::UpdateColors(); //Already called in disassembly
mDisasm->UpdateConfig();
backgroundColor = ConfigColor("DisassemblyBackgroundColor");
mBackgroundColor = ConfigColor("DisassemblyBackgroundColor");
mInstructionHighlightColor = ConfigColor("InstructionHighlightColor");
mSelectionColor = ConfigColor("DisassemblySelectionColor");

View File

@ -14,12 +14,12 @@ class TraceBrowser : public AbstractTableView
Q_OBJECT
public:
explicit TraceBrowser(QWidget* parent = 0);
~TraceBrowser();
~TraceBrowser() override;
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) override;
void prepareData();
virtual void updateColors();
void prepareData() override;
void updateColors() override;
void expandSelectionUpTo(duint to);
void setSingleSelection(duint index);
@ -37,25 +37,25 @@ private:
void copySelectionSlot(bool copyBytes);
void copySelectionToFileSlot(bool copyBytes);
void contextMenuEvent(QContextMenuEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void contextMenuEvent(QContextMenuEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mouseDoubleClickEvent(QMouseEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
VaHistory mHistory;
MenuBuilder* mMenuBuilder;
bool mRvaDisplayEnabled;
duint mRvaDisplayBase;
typedef struct _SelectionData_t
struct SelectionData
{
duint firstSelectedIndex;
duint fromIndex;
duint toIndex;
} SelectionData_t;
};
SelectionData_t mSelection;
SelectionData mSelection;
CapstoneTokenizer::SingleToken mHighlightToken;
bool mHighlightingMode;
bool mPermanentHighlightingMode;
@ -102,7 +102,6 @@ signals:
void displayReferencesWidget();
public slots:
void openFileSlot();
void openSlot(const QString & fileName);
void toggleRunTraceSlot();

View File

@ -109,7 +109,6 @@ SOURCES += \
Src/Utils/RichTextPainter.cpp \
Src/Gui/TabBar.cpp \
Src/Gui/TabWidget.cpp \
Src/Gui/CommandHelpView.cpp \
Src/BasicView/HistoryLineEdit.cpp \
Src/Utils/Configuration.cpp \
Src/Gui/CPUSideBar.cpp \
@ -124,7 +123,6 @@ SOURCES += \
Src/Gui/PatchDialog.cpp \
Src/Gui/PatchDialogGroupSelector.cpp \
Src/Utils/UpdateChecker.cpp \
Src/BasicView/SearchListViewTable.cpp \
Src/Gui/CallStackView.cpp \
Src/Gui/ShortcutsDialog.cpp \
Src/BasicView/ShortcutEdit.cpp \
@ -187,7 +185,8 @@ SOURCES += \
Src/Tracer/TraceFileSearch.cpp \
Src/Gui/MultiItemsSelectWindow.cpp \
Src/BasicView/AbstractStdTable.cpp \
Src/Gui/ZehSymbolTable.cpp
Src/Gui/ZehSymbolTable.cpp \
Src/BasicView/StdSearchListView.cpp
HEADERS += \
@ -227,7 +226,6 @@ HEADERS += \
Src/Utils/RichTextPainter.h \
Src/Gui/TabBar.h \
Src/Gui/TabWidget.h \
Src/Gui/CommandHelpView.h \
Src/BasicView/HistoryLineEdit.h \
Src/Utils/Configuration.h \
Src/Gui/CPUSideBar.h \
@ -242,7 +240,6 @@ HEADERS += \
Src/Gui/PatchDialog.h \
Src/Gui/PatchDialogGroupSelector.h \
Src/Utils/UpdateChecker.h \
Src/BasicView/SearchListViewTable.h \
Src/Gui/CallStackView.h \
Src/Gui/ShortcutsDialog.h \
Src/BasicView/ShortcutEdit.h \
@ -310,7 +307,9 @@ HEADERS += \
Src/Tracer/TraceFileSearch.h \
Src/Gui/MultiItemsSelectWindow.h \
Src/BasicView/AbstractStdTable.h \
Src/Gui/ZehSymbolTable.h
Src/Gui/ZehSymbolTable.h \
Src/BasicView/AbstractSearchList.h \
Src/BasicView/StdSearchListView.h
FORMS += \
@ -322,7 +321,6 @@ FORMS += \
Src/Gui/SymbolView.ui \
Src/Gui/SettingsDialog.ui \
Src/Gui/ExceptionRangeDialog.ui \
Src/Gui/CommandHelpView.ui \
Src/Gui/AppearanceDialog.ui \
Src/Gui/CloseDialog.ui \
Src/Gui/HexEditDialog.ui \

View File

@ -15,7 +15,6 @@ SOURCES += \
gui/Src/Gui/CloseDialog.cpp \
gui/Src/Gui/CodepageSelectionDialog.cpp \
gui/Src/Gui/ColumnReorderDialog.cpp \
gui/Src/Gui/CommandHelpView.cpp \
gui/Src/Gui/CommandLineEdit.cpp \
gui/Src/Gui/CPUArgumentWidget.cpp \
gui/Src/Gui/CPUDisassembly.cpp \
@ -169,7 +168,6 @@ SOURCES += \
gui/Src/BasicView/HistoryLineEdit.cpp \
gui/Src/BasicView/ReferenceView.cpp \
gui/Src/BasicView/SearchListView.cpp \
gui/Src/BasicView/SearchListViewTable.cpp \
gui/Src/BasicView/ShortcutEdit.cpp \
gui/Src/BasicView/StdTable.cpp \
gui/Src/Memory/MemoryPage.cpp \
@ -226,7 +224,8 @@ SOURCES += \
gui/Src/Tracer/TraceFileSearch.cpp \
gui/Src/Gui/MultiItemsSelectWindow.cpp \
gui/Src/BasicView/AbstractStdTable.cpp \
gui/Src/Gui/ZehSymbolTable.cpp
gui/Src/Gui/ZehSymbolTable.cpp \
gui/Src/BasicView/StdSearchListView.cpp
HEADERS += \
gui/Src/Exports.h \
@ -242,7 +241,6 @@ HEADERS += \
gui/Src/Gui/CloseDialog.h \
gui/Src/Gui/CodepageSelectionDialog.h \
gui/Src/Gui/ColumnReorderDialog.h \
gui/Src/Gui/CommandHelpView.h \
gui/Src/Gui/CommandLineEdit.h \
gui/Src/Gui/CPUArgumentWidget.h \
gui/Src/Gui/CPUDisassembly.h \
@ -406,7 +404,6 @@ HEADERS += \
gui/Src/BasicView/HistoryLineEdit.h \
gui/Src/BasicView/ReferenceView.h \
gui/Src/BasicView/SearchListView.h \
gui/Src/BasicView/SearchListViewTable.h \
gui/Src/BasicView/ShortcutEdit.h \
gui/Src/BasicView/StdTable.h \
gui/Src/Memory/MemoryPage.h \
@ -464,7 +461,8 @@ HEADERS += \
gui/Src/Tracer/TraceFileSearch.h \
gui/Src/Gui/MultiItemsSelectWindow.h \
gui/Src/BasicView/AbstractStdTable.h \
gui/Src/Gui/ZehSymbolTable.h
gui/Src/Gui/ZehSymbolTable.h \
gui/Src/BasicView/StdSearchListView.h
FORMS += \
gui/Src/Gui/AppearanceDialog.ui \
@ -475,7 +473,6 @@ FORMS += \
gui/Src/Gui/CloseDialog.ui \
gui/Src/Gui/CodepageSelectionDialog.ui \
gui/Src/Gui/ColumnReorderDialog.ui \
gui/Src/Gui/CommandHelpView.ui \
gui/Src/Gui/CPUArgumentWidget.ui \
gui/Src/Gui/CPUWidget.ui \
gui/Src/Gui/DataCopyDialog.ui \