mirror of
https://github.com/x64dbg/x64dbg.git
synced 2024-11-27 06:40:24 +00:00
Show ordinal names in the undecorated symbol column
Thanks to @dmex for the suggestion
This commit is contained in:
parent
e608f9346c
commit
2ed439677e
@ -283,7 +283,7 @@ static void ReadImportDirectory(MODINFO & Info, ULONG_PTR FileMapVA)
|
||||
// Import by ordinal
|
||||
entry.ordinal = THUNK_VAL(Info.headers, thunkData, u1.Ordinal) & 0xffff;
|
||||
char buf[18];
|
||||
sprintf_s(buf, "Ordinal%u", (ULONG)entry.ordinal);
|
||||
sprintf_s(buf, "Ordinal#%u", (ULONG)entry.ordinal);
|
||||
entry.name = String((const char*)buf);
|
||||
}
|
||||
}
|
||||
|
@ -52,10 +52,69 @@ QString ZehSymbolTable::getCellContent(int r, int c)
|
||||
return QString();
|
||||
SymbolInfoWrapper info;
|
||||
DbgGetSymbolInfo(&mData.at(r), &info);
|
||||
return symbolInfoString(&info, 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)
|
||||
{
|
||||
QMutexLocker lock(&mMutex);
|
||||
std::stable_sort(mData.begin(), mData.end(), [this, column, ascending](const SYMBOLPTR & a, const SYMBOLPTR & b)
|
||||
{
|
||||
SymbolInfoWrapper ainfo, binfo;
|
||||
DbgGetSymbolInfo(&a, &ainfo);
|
||||
DbgGetSymbolInfo(&b, &binfo);
|
||||
switch(column)
|
||||
{
|
||||
case ColAddr:
|
||||
return ascending ? ainfo->addr < binfo->addr : ainfo->addr > binfo->addr;
|
||||
|
||||
case ColType:
|
||||
return ascending ? ainfo->type < binfo->type : ainfo->type > binfo->type;
|
||||
|
||||
case ColOrdinal:
|
||||
// If we are sorting by ordinal make the exports the first entries
|
||||
if(ainfo->type == sym_export && binfo->type != sym_export)
|
||||
return ascending;
|
||||
else if(ainfo->type != sym_export && binfo->type == sym_export)
|
||||
return !ascending;
|
||||
else
|
||||
return ascending ? ainfo->ordinal < binfo->ordinal : ainfo->ordinal > binfo->ordinal;
|
||||
|
||||
case ColDecorated:
|
||||
{
|
||||
auto acell = symbolInfoString(&ainfo, ColDecorated);
|
||||
auto bcell = symbolInfoString(&binfo, ColDecorated);
|
||||
int result = QString::compare(acell, bcell);
|
||||
return ascending ? result < 0 : result > 0;
|
||||
}
|
||||
|
||||
case ColUndecorated:
|
||||
{
|
||||
auto acell = symbolInfoString(&ainfo, ColUndecorated);
|
||||
auto bcell = symbolInfoString(&binfo, ColUndecorated);
|
||||
int result = QString::compare(acell, bcell);
|
||||
return ascending ? result < 0 : result > 0;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QString ZehSymbolTable::symbolInfoString(const SYMBOLINFO* info, int c)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case ColAddr:
|
||||
return ToPtrString(info->addr);
|
||||
|
||||
case ColType:
|
||||
switch(info->type)
|
||||
{
|
||||
@ -68,12 +127,15 @@ QString ZehSymbolTable::getCellContent(int r, int c)
|
||||
default:
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
case ColOrdinal:
|
||||
if(info->type == sym_export)
|
||||
return QString::number(info->ordinal);
|
||||
else
|
||||
return QString();
|
||||
|
||||
case ColDecorated:
|
||||
{
|
||||
char modname[MAX_MODULE_SIZE];
|
||||
// Get module name for import symbols
|
||||
if(info->type == sym_import)
|
||||
@ -84,51 +146,41 @@ QString ZehSymbolTable::getCellContent(int r, int c)
|
||||
return QString(modname).append('.').append(info->decoratedSymbol);
|
||||
}
|
||||
return info->decoratedSymbol;
|
||||
}
|
||||
|
||||
case ColUndecorated:
|
||||
{
|
||||
if(*info->undecoratedSymbol == '\0' && strstr(info->decoratedSymbol, "Ordinal") == info->decoratedSymbol)
|
||||
{
|
||||
char label[MAX_LABEL_SIZE] = "";
|
||||
switch(info->type)
|
||||
{
|
||||
case sym_import:
|
||||
{
|
||||
duint wVA;
|
||||
if(DbgMemRead(info->addr, &wVA, sizeof(duint)))
|
||||
{
|
||||
DbgGetLabelAt(wVA, SEG_DEFAULT, label);
|
||||
return label;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case sym_export:
|
||||
{
|
||||
DbgGetLabelAt(info->addr, SEG_DEFAULT, label);
|
||||
return label;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return info->undecoratedSymbol;
|
||||
}
|
||||
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
QMutexLocker lock(&mMutex);
|
||||
std::stable_sort(mData.begin(), mData.end(), [column, ascending](const SYMBOLPTR & a, const SYMBOLPTR & b)
|
||||
{
|
||||
SymbolInfoWrapper ainfo, binfo;
|
||||
DbgGetSymbolInfo(&a, &ainfo);
|
||||
DbgGetSymbolInfo(&b, &binfo);
|
||||
switch(column)
|
||||
{
|
||||
case ColAddr:
|
||||
return ascending ? ainfo->addr < binfo->addr : ainfo->addr > binfo->addr;
|
||||
case ColType:
|
||||
return ascending ? ainfo->type < binfo->type : ainfo->type > binfo->type;
|
||||
case ColOrdinal:
|
||||
// If we are sorting by ordinal make the exports the first entries
|
||||
if(ainfo->type == sym_export && binfo->type != sym_export)
|
||||
return ascending;
|
||||
else if(ainfo->type != sym_export && binfo->type == sym_export)
|
||||
return !ascending;
|
||||
else
|
||||
return ascending ? ainfo->ordinal < binfo->ordinal : ainfo->ordinal > binfo->ordinal;
|
||||
case ColDecorated:
|
||||
{
|
||||
int result = strcmp(ainfo->decoratedSymbol, binfo->decoratedSymbol);
|
||||
return ascending ? result < 0 : result > 0;
|
||||
}
|
||||
case ColUndecorated:
|
||||
{
|
||||
int result = strcmp(ainfo->undecoratedSymbol, binfo->undecoratedSymbol);
|
||||
return ascending ? result < 0 : result > 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -35,4 +35,6 @@ private:
|
||||
ColDecorated,
|
||||
ColUndecorated
|
||||
};
|
||||
|
||||
QString symbolInfoString(const SYMBOLINFO* info, int c);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user