1
0
Fork 0

improve code and fix bugs

This commit is contained in:
Duncan Ogilvie 2020-09-14 19:56:11 +02:00
parent c5c55de12f
commit 54051bdcd1
10 changed files with 39 additions and 27 deletions

View File

@ -226,8 +226,8 @@ StackSelectionColor=#414141
StackTextColor=#E0E0E0
StructAlternateBackgroundColor=#313131
StructBackgroundColor=#212121
SymbolUserTextColor=#F88478
SymbolSystemTextColor=#A0A0A0
SymbolUserTextColor=#E0E0E0
SymbolSystemTextColor=#E0E0E0
SymbolLoadedTextColor=#E0E0E0
SymbolLoadingTextColor=#E1EA76
SymbolUnloadedTextColor=#A0A0A0

View File

@ -184,8 +184,8 @@ typedef bool (*ENUMHANDLES)(ListOf(HANDLEINFO) handles);
typedef bool (*GETHANDLENAME)(duint handle, char* name, size_t nameSize, char* typeName, size_t typeNameSize);
typedef bool (*ENUMTCPCONNECTIONS)(ListOf(TCPCONNECTIONINFO) connections);
typedef duint(*GETDBGEVENTS)();
typedef int (*MODGETPARTY)(duint base);
typedef void (*MODSETPARTY)(duint base, int party);
typedef MODULEPARTY(*MODGETPARTY)(duint base);
typedef void (*MODSETPARTY)(duint base, MODULEPARTY party);
typedef bool(*WATCHISWATCHDOGTRIGGERED)(unsigned int id);
typedef bool(*MEMISCODEPAGE)(duint addr, bool refresh);
typedef bool(*ANIMATECOMMAND)(const char* command);

View File

@ -37,12 +37,22 @@ namespace Exprfunc
duint modsystem(duint addr)
{
return ModGetParty(addr) == 1;
SHARED_ACQUIRE(LockModules);
auto info = ModInfoFromAddr(addr);
if(info)
return info->party == mod_system;
else
return 0;
}
duint moduser(duint addr)
{
return ModGetParty(addr) == 0;
SHARED_ACQUIRE(LockModules);
auto info = ModInfoFromAddr(addr);
if(info)
return info->party == mod_user;
else
return 0;
}
duint modrva(duint addr)

View File

@ -821,11 +821,11 @@ bool ModLoad(duint Base, duint Size, const char* FullPath)
Utf8Sysdir.append("\\");
if(_memicmp(Utf8Sysdir.c_str(), FullPath, Utf8Sysdir.size()) == 0)
{
info.party = 1;
info.party = mod_system;
}
else
{
info.party = 0;
info.party = mod_user;
}
// Load module data
@ -1129,7 +1129,7 @@ void ModEnum(const std::function<void(const MODINFO &)> & cbEnum)
cbEnum(*mod.second);
}
int ModGetParty(duint Address)
MODULEPARTY ModGetParty(duint Address)
{
SHARED_ACQUIRE(LockModules);
@ -1137,12 +1137,12 @@ int ModGetParty(duint Address)
// If the module is not found, it is an user module
if(!module)
return 0;
return mod_user;
return module->party;
}
void ModSetParty(duint Address, int Party)
void ModSetParty(duint Address, MODULEPARTY Party)
{
EXCLUSIVE_ACQUIRE(LockModules);

View File

@ -116,7 +116,7 @@ struct MODINFO
HANDLE fileMap = nullptr;
ULONG_PTR fileMapVA = 0;
int party; // Party. Currently used value: 0: User, 1: System
MODULEPARTY party; // Party. Currently used value: 0: User, 1: System
MODINFO()
{
@ -164,8 +164,8 @@ int ModPathFromName(const char* Module, char* Path, int Size);
/// <param name="cbEnum">Enumeration function.</param>
void ModEnum(const std::function<void(const MODINFO &)> & cbEnum);
int ModGetParty(duint Address);
void ModSetParty(duint Address, int Party);
MODULEPARTY ModGetParty(duint Address);
void ModSetParty(duint Address, MODULEPARTY Party);
bool ModRelocationsFromAddr(duint Address, std::vector<MODRELOCATIONINFO> & Relocations);
bool ModRelocationAtAddr(duint Address, MODRELOCATIONINFO* Relocation);
bool ModRelocationsInRange(duint Address, duint Size, std::vector<MODRELOCATIONINFO> & Relocations);

View File

@ -467,7 +467,7 @@ QString CPUStack::paintContent(QPainter* painter, dsint rowBase, int rowOffset,
int width = 5;
int offset = 2;
auto result = HexDump::paintContent(painter, rowBase, rowOffset, 1, x + (width - 2), y, w - (width - 2), h);
if(party == MODULEPARTY::mod_user)
if(party == mod_user)
painter->setPen(QPen(mUserStackFrameColor, 2));
else
painter->setPen(QPen(mSystemStackFrameColor, 2));

View File

@ -84,10 +84,10 @@ void CallStackView::updateCallStack()
int party = DbgFunctions()->ModGetParty(callstack.entries[i].to);
switch(party)
{
case MODULEPARTY::mod_user:
case mod_user:
setCellContent(i, 5, tr("User"));
break;
case MODULEPARTY::mod_system:
case mod_system:
setCellContent(i, 5, tr("System"));
break;
default:

View File

@ -303,16 +303,18 @@ QString MemoryMapView::paintContent(QPainter* painter, dsint rowBase, int rowOff
}
else if(col == 2) //info
{
QString wStr = StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);;
QString wStr = StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
auto addr = getCellUserdata(rowBase + rowOffset, 0);
if(wStr.startsWith(" \""))
{
painter->setPen(ConfigColor("MemoryMapSectionTextColor"));
painter->drawText(QRect(x + 4, y, getColumnWidth(col) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
return QString();
}
else if(DbgFunctions()->ModGetParty(getCellUserdata(rowBase + rowOffset, 0)) == MODULEPARTY::mod_user)
else if(DbgFunctions()->ModBaseFromAddr(addr) == addr) // module header page
{
painter->setPen(ConfigColor("SymbolUserTextColor"));
auto party = DbgFunctions()->ModGetParty(addr);
painter->setPen(ConfigColor(party == mod_user ? "SymbolUserTextColor" : "SymbolSystemTextColor"));
painter->drawText(QRect(x + 4, y, getColumnWidth(col) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
return QString();
}

View File

@ -42,7 +42,7 @@ public:
{
if(c == ColParty || c == ColPath)
{
if(DbgFunctions()->ModGetParty(getCellUserdata(r, ColBase)) != MODULEPARTY::mod_system)
if(DbgFunctions()->ModGetParty(getCellUserdata(r, ColBase)) != mod_system)
return mSymbolUserTextColor;
else
return mSymbolSystemTextColor;
@ -769,7 +769,7 @@ void SymbolView::moduleSetSystem()
{
int i = mModuleList->mCurList->getInitialSelection();
duint modbase = DbgValFromString(mModuleList->mCurList->getCellContent(i, ColBase).toUtf8().constData());
DbgFunctions()->ModSetParty(modbase, 1);
DbgFunctions()->ModSetParty(modbase, mod_system);
DbgFunctions()->RefreshModuleList();
}
@ -777,7 +777,7 @@ void SymbolView::moduleSetUser()
{
int i = mModuleList->mCurList->getInitialSelection();
duint modbase = DbgValFromString(mModuleList->mCurList->getCellContent(i, ColBase).toUtf8().constData());
DbgFunctions()->ModSetParty(modbase, 0);
DbgFunctions()->ModSetParty(modbase, mod_user);
DbgFunctions()->RefreshModuleList();
}
@ -793,9 +793,9 @@ void SymbolView::moduleSetParty()
bool ok;
party = mLineEditeditText.toInt(&ok);
int i = mModuleList->mCurList->getInitialSelection();
if(ok)
if(ok && (party == mod_user || party == mod_system))
{
DbgFunctions()->ModSetParty(modbase, party);
DbgFunctions()->ModSetParty(modbase, (MODULEPARTY)party);
/* TODO: refresh module list
switch(party)
{
@ -812,7 +812,7 @@ void SymbolView::moduleSetParty()
mModuleList->mCurList->reloadData();*/
}
else
SimpleErrorBox(this, tr("Error"), tr("The party number can only be an integer"));
SimpleErrorBox(this, tr("Error"), tr("The party number can only be 0 or 1"));
}
}

View File

@ -239,7 +239,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
defaultColors.insert("BreakpointSummaryKeywordColor", QColor("#8B671F"));
defaultColors.insert("BreakpointSummaryStringColor", QColor("#008000"));
defaultColors.insert("PatchRelocatedByteHighlightColor", QColor("#0000DD"));
defaultColors.insert("SymbolUserTextColor", QColor("#FF0000"));
defaultColors.insert("SymbolUserTextColor", QColor("#000000"));
defaultColors.insert("SymbolSystemTextColor", QColor("#000000"));
defaultColors.insert("SymbolUnloadedTextColor", QColor("#000000"));
defaultColors.insert("SymbolLoadingTextColor", QColor("#8B671F"));