diff options
| author | Mason Reed <mason@vector35.com> | 2025-04-14 01:43:28 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-04-14 03:20:51 -0400 |
| commit | bf64859f5aa261fa8db7bfdd9af4f67826ff4e5b (patch) | |
| tree | cc549d191d3b95fc48d9aa2d6316b70722a46759 /view/sharedcache | |
| parent | ea47d4c85e78533ea7e88adc442159414feb3f7f (diff) | |
[SharedCache] Expose cache entry name in the API
Allows us to display the user friendly name of the cache entry in the triage view
Diffstat (limited to 'view/sharedcache')
| -rw-r--r-- | view/sharedcache/api/sharedcache.cpp | 2 | ||||
| -rw-r--r-- | view/sharedcache/api/sharedcacheapi.h | 1 | ||||
| -rw-r--r-- | view/sharedcache/api/sharedcachecore.h | 1 | ||||
| -rw-r--r-- | view/sharedcache/core/ffi.cpp | 7 | ||||
| -rw-r--r-- | view/sharedcache/ui/dsctriage.cpp | 8 |
5 files changed, 13 insertions, 6 deletions
diff --git a/view/sharedcache/api/sharedcache.cpp b/view/sharedcache/api/sharedcache.cpp index 922a7ff3..d1ec680d 100644 --- a/view/sharedcache/api/sharedcache.cpp +++ b/view/sharedcache/api/sharedcache.cpp @@ -78,6 +78,7 @@ BNSharedCacheEntry EntryToApi(const CacheEntry &entry) { BNSharedCacheEntry apiEntry {}; apiEntry.path = BNAllocString(entry.path.c_str()); + apiEntry.name = BNAllocString(entry.name.c_str()); apiEntry.entryType = entry.entryType; const auto &mappings = entry.mappings; apiEntry.mappingCount = mappings.size(); @@ -92,6 +93,7 @@ CacheEntry EntryFromApi(BNSharedCacheEntry apiEntry) { CacheEntry entry {}; entry.path = apiEntry.path; + entry.name = apiEntry.name; entry.entryType = apiEntry.entryType; entry.mappings.reserve(apiEntry.mappingCount); for (size_t i = 0; i < apiEntry.mappingCount; i++) diff --git a/view/sharedcache/api/sharedcacheapi.h b/view/sharedcache/api/sharedcacheapi.h index 5a842cba..097c185b 100644 --- a/view/sharedcache/api/sharedcacheapi.h +++ b/view/sharedcache/api/sharedcacheapi.h @@ -278,6 +278,7 @@ namespace SharedCacheAPI { struct CacheEntry { std::string path; + std::string name; BNSharedCacheEntryType entryType; std::vector<CacheMappingInfo> mappings; }; diff --git a/view/sharedcache/api/sharedcachecore.h b/view/sharedcache/api/sharedcachecore.h index ab2acb60..00b24b60 100644 --- a/view/sharedcache/api/sharedcachecore.h +++ b/view/sharedcache/api/sharedcachecore.h @@ -97,6 +97,7 @@ extern "C" typedef struct BNSharedCacheEntry { char* path; + char* name; BNSharedCacheEntryType entryType; size_t mappingCount; BNSharedCacheMappingInfo* mappings; diff --git a/view/sharedcache/core/ffi.cpp b/view/sharedcache/core/ffi.cpp index e4e92acd..1ae561ae 100644 --- a/view/sharedcache/core/ffi.cpp +++ b/view/sharedcache/core/ffi.cpp @@ -134,6 +134,7 @@ BNSharedCacheEntry EntryToApi(const CacheEntry& entry) { BNSharedCacheEntry apiEntry; apiEntry.path = BNAllocString(entry.GetFilePath().c_str()); + apiEntry.name = BNAllocString(entry.GetFileName().c_str()); apiEntry.entryType = EntryTypeToApi(entry.GetType()); const auto& mappings = entry.GetMappings(); apiEntry.mappingCount = mappings.size(); @@ -408,15 +409,15 @@ extern "C" const auto& entries = controller->object->GetCache().GetEntries(); *count = entries.size(); BNSharedCacheEntry* apiEntries = new BNSharedCacheEntry[*count]; - size_t idx = 0; - for (const auto& [_, entry] : entries) - apiEntries[idx++] = EntryToApi(entry); + for (size_t i = 0; i < *count; i++) + apiEntries[i] = EntryToApi(entries[i]); return apiEntries; } void BNSharedCacheFreeEntry(BNSharedCacheEntry entry) { BNFreeString(entry.path); + BNFreeString(entry.name); delete[] entry.mappings; } diff --git a/view/sharedcache/ui/dsctriage.cpp b/view/sharedcache/ui/dsctriage.cpp index 6b0ec0d5..e2cf8147 100644 --- a/view/sharedcache/ui/dsctriage.cpp +++ b/view/sharedcache/ui/dsctriage.cpp @@ -355,8 +355,8 @@ void DSCTriageView::initCacheInfoTables() auto cacheInfoSubwidget = new QWidget; auto mappingTable = new FilterableTableView(cacheInfoSubwidget); - m_mappingModel = new QStandardItemModel(0, 4, mappingTable); - m_mappingModel->setHorizontalHeaderLabels({"Address", "Size", "File Address", "File Path"}); + m_mappingModel = new QStandardItemModel(0, 5, mappingTable); + m_mappingModel->setHorizontalHeaderLabels({"Address", "Size", "File Address", "File Name", "File Path"}); // Apply custom column styling mappingTable->setItemDelegateForColumn(0, new AddressColorDelegate(mappingTable)); @@ -366,7 +366,8 @@ void DSCTriageView::initCacheInfoTables() mappingTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed); mappingTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed); mappingTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); - mappingTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch); + mappingTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents); + mappingTable->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch); mappingTable->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -527,6 +528,7 @@ void DSCTriageView::RefreshData() new QStandardItem(QString("0x%1").arg(mapping.vmAddress, 0, 16)), new QStandardItem(QString("0x%1").arg(mapping.size, 0, 16)), new QStandardItem(QString("0x%1").arg(mapping.fileOffset, 0, 16)), + new QStandardItem(QString::fromStdString(entry.name)), new QStandardItem(QString::fromStdString(entry.path)) }); } |
