feat: update magicblob parser lib.
This commit is contained in:
@@ -55,14 +55,14 @@ void MagicBlob::read(const fs::path& path) {
|
||||
n_rva += rva;
|
||||
rva = n_rva;
|
||||
|
||||
m_entities.emplace(hash, std::make_unique<MagicEntry>(flags, rva));
|
||||
m_entries.emplace(hash, std::make_unique<MagicEntry>(flags, rva));
|
||||
}
|
||||
}
|
||||
|
||||
MagicEntry const* MagicBlob::query(std::string_view symbol) const {
|
||||
auto query_hash = XXH64(symbol.data(), symbol.size(), m_query_seed);
|
||||
if (m_entities.contains(query_hash)) {
|
||||
return m_entities.at(query_hash).get();
|
||||
if (m_entries.contains(query_hash)) {
|
||||
return m_entries.at(query_hash).get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -7,14 +7,20 @@ namespace di::data_format {
|
||||
|
||||
class MagicBlob : public StreamedIO {
|
||||
public:
|
||||
using for_each_callback_t = std::function<void(hash_t, MagicEntry const&)>;
|
||||
|
||||
void read(const fs::path& path) override;
|
||||
|
||||
constexpr size_t count() const { return m_entities.size(); }
|
||||
void for_each(const for_each_callback_t& callback) const {
|
||||
for (const auto& [hash, entry] : m_entries) callback(hash, *entry);
|
||||
}
|
||||
|
||||
constexpr size_t count() const { return m_entries.size(); }
|
||||
|
||||
MagicEntry const* query(std::string_view symbol) const;
|
||||
|
||||
private:
|
||||
std::unordered_map<hash_t, std::unique_ptr<MagicEntry>> m_entities;
|
||||
std::unordered_map<hash_t, std::unique_ptr<MagicEntry>> m_entries;
|
||||
|
||||
// MagicBlob uses a custom algorithm to transform the stored seed. When
|
||||
// querying, you should use m_query_seed.
|
||||
|
||||
@@ -12,10 +12,10 @@ struct MagicEntry {
|
||||
// Do not put the original hash in the entry yet.
|
||||
// hash_t hash;
|
||||
|
||||
constexpr bool is_function() { return flags[0]; }
|
||||
constexpr bool _unk2() { return flags[1]; }
|
||||
constexpr bool is_verbose() { return flags[2]; }
|
||||
constexpr bool _unk4() { return flags[3]; }
|
||||
constexpr bool is_function() const { return flags[0]; }
|
||||
constexpr bool _unk2() const { return flags[1]; }
|
||||
constexpr bool is_verbose() const { return flags[2]; }
|
||||
constexpr bool _unk4() const { return flags[3]; }
|
||||
};
|
||||
|
||||
} // namespace di
|
||||
|
||||
Reference in New Issue
Block a user