diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-11-29 15:40:00 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-11-30 18:35:18 -0500 |
| commit | d9a0b4e14ee9df749ad685fa723d537552627012 (patch) | |
| tree | 9aeea20c273d6453fa5af3d8108a4e39ab3578ce /examples | |
| parent | 4c242707996e94877d3e2762a2ef88835e98abbc (diff) | |
Triage View: show typelib status of imports
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/triage/imports.cpp | 34 | ||||
| -rw-r--r-- | examples/triage/imports.h | 6 |
2 files changed, 35 insertions, 5 deletions
diff --git a/examples/triage/imports.cpp b/examples/triage/imports.cpp index aa3b18b7..b96457f8 100644 --- a/examples/triage/imports.cpp +++ b/examples/triage/imports.cpp @@ -7,10 +7,12 @@ GenericImportsModel::GenericImportsModel(BinaryViewRef data) { - m_nameCol = 1; + m_data = data; + m_typeLibCol = 1; + m_nameCol = 2; m_moduleCol = -1; m_ordinalCol = -1; - m_totalCols = 2; + m_totalCols = 3; m_sortCol = 0; m_sortOrder = Qt::AscendingOrder; m_allEntries = data->GetSymbolsOfType(ImportAddressSymbol); @@ -24,10 +26,11 @@ GenericImportsModel::GenericImportsModel(BinaryViewRef data) } if (m_hasModules) { - m_nameCol = 3; + m_nameCol = 4; m_moduleCol = 1; m_ordinalCol = 2; - m_totalCols = 4; + m_typeLibCol = 3; + m_totalCols = 5; } m_entries = m_allEntries; } @@ -61,6 +64,8 @@ QVariant GenericImportsModel::data(const QModelIndex& index, int role) const return getNamespace(m_entries[index.row()]); if (index.column() == m_ordinalCol) return QString::number(m_entries[index.row()]->GetOrdinal()); + if (index.column() == m_typeLibCol) + return getLibrarySource(m_entries[index.row()]); return QVariant(); } @@ -79,6 +84,8 @@ QVariant GenericImportsModel::headerData(int section, Qt::Orientation orientatio return QString("Module"); if (section == m_ordinalCol) return QString("Ordinal"); + if (section == m_typeLibCol) + return QString("Type Library"); return QVariant(); } @@ -118,6 +125,16 @@ QString GenericImportsModel::getNamespace(SymbolRef sym) const } +QString GenericImportsModel::getLibrarySource(SymbolRef sym) const +{ + auto imported = m_data->LookupImportedObjectLibrary(m_data->GetDefaultPlatform(), sym->GetAddress()); + if (!imported.has_value()) + return QString("No Library"); + + return QString::fromStdString(imported->first->GetName()); +} + + void GenericImportsModel::performSort(int col, Qt::SortOrder order) { std::sort(m_entries.begin(), m_entries.end(), [&](SymbolRef a, SymbolRef b) { @@ -149,6 +166,13 @@ void GenericImportsModel::performSort(int col, Qt::SortOrder order) else return a->GetOrdinal() > b->GetOrdinal(); } + else if (col == m_typeLibCol) + { + if (order == Qt::AscendingOrder) + return getLibrarySource(a) < getLibrarySource(b); + else + return getLibrarySource(a) > getLibrarySource(b); + } return false; }); } @@ -198,6 +222,8 @@ ImportsTreeView::ImportsTreeView(ImportsWidget* parent, TriageView* view, Binary sortByColumn(0, Qt::AscendingOrder); if (m_model->HasOrdinalCol()) setColumnWidth(m_model->GetOrdinalCol(), 55); + setColumnWidth(m_model->GetTypeLibCol(), 90); + resizeColumnToContents(m_model->GetNameCol()); setFont(getMonospaceFont(this)); diff --git a/examples/triage/imports.h b/examples/triage/imports.h index 2199aa47..c90e91dc 100644 --- a/examples/triage/imports.h +++ b/examples/triage/imports.h @@ -7,13 +7,15 @@ class GenericImportsModel : public QAbstractItemModel { + BinaryViewRef m_data; std::vector<SymbolRef> m_allEntries, m_entries; bool m_hasModules; - int m_nameCol, m_moduleCol, m_ordinalCol; + int m_nameCol, m_moduleCol, m_ordinalCol, m_typeLibCol; int m_totalCols, m_sortCol; Qt::SortOrder m_sortOrder; QString getNamespace(SymbolRef sym) const; + QString getLibrarySource(SymbolRef sym) const; void performSort(int col, Qt::SortOrder order); public: @@ -32,6 +34,8 @@ class GenericImportsModel : public QAbstractItemModel bool HasOrdinalCol() const { return m_ordinalCol != -1; } int GetOrdinalCol() const { return m_ordinalCol; } + int GetTypeLibCol() const { return m_typeLibCol; } + int GetNameCol() const { return m_nameCol; } }; |
