diff options
| author | Peter LaFosse <peter@vector35.com> | 2023-08-09 09:11:56 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2023-11-03 10:41:51 -0400 |
| commit | c69eec3c4b4cd0b8ed25ec379bfd32a8513b4447 (patch) | |
| tree | 112a41d3115c3077e97acbda4b74ed71e99e0faf /examples/triage/headers.cpp | |
| parent | 1a49d7361cd1e6e008479581e822965df91eca7c (diff) | |
Add support for showing compiler information in the triage summary
Diffstat (limited to 'examples/triage/headers.cpp')
| -rw-r--r-- | examples/triage/headers.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/triage/headers.cpp b/examples/triage/headers.cpp index 20332527..1bdc31fe 100644 --- a/examples/triage/headers.cpp +++ b/examples/triage/headers.cpp @@ -1,5 +1,6 @@ #include <cstring> #include <time.h> +#include <map> #include "headers.h" #include "fontsettings.h" #include "theme.h" @@ -261,6 +262,39 @@ PEHeaders::PEHeaders(BinaryViewRef data) AddField("DLL Characteristics", dllCharValues); } + + auto richHeaderIdentifiers = data->QueryMetadata("RichHeaderLookupIdentifiers"); + auto richHeaderNames = data->QueryMetadata("RichHeaderLookupNames"); + auto richHeader = data->QueryMetadata("RichHeader"); + if (richHeaderIdentifiers && richHeaderIdentifiers && richHeader) // Should only be present on PE files + { + std::vector<QString> compilersUsed; + + // Get a set of unique identifiers + std::map<uint64_t, uint64_t> identifiers; + for (auto& entry : richHeader->GetArray()) + { + auto kv = entry->GetKeyValueStore(); + identifiers[kv["ObjectVersionValue"]->GetUnsignedInteger()] += kv["ObjectCount"]->GetUnsignedInteger(); + } + auto lookupVersionStrings = [&](uint64_t id) -> std::string { + auto ids = richHeaderIdentifiers->GetUnsignedIntegerList(); + auto names = richHeaderNames->GetStringList(); + for (size_t i = 0; i < ids.size(); i++) + { + if (ids[i] == id) + return names[i]; + if (ids[i] > id && i > 0) + return names[i - 1] + " and " + names[i]; + } + return "Unknown"; + }; + for (auto& entry : identifiers) + compilersUsed.push_back(QString::fromStdString(lookupVersionStrings(entry.first) + " (" + std::to_string(entry.second) + " objects)")); + + AddField("Compiler(s) Used", compilersUsed); + } + SetColumns(3); SetRowsPerColumn(9); } |
