summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/SharedCache.h
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2024-10-30 08:39:09 -0400
committerkat <kat@vector35.com>2024-11-05 09:03:12 -0500
commitf4a4b17b9e30cf603eb614e153d68226a3b24520 (patch)
treee33d18742c1a9e9b47af04df24bf88248c17f06a /view/sharedcache/core/SharedCache.h
parentfd8eb478a7a3bbc848da37bd33e62c2d8cf26b99 (diff)
[SharedCache] Implement LoadedImage API, Fix serialized image names, more robust system for out-of-date databases
Diffstat (limited to 'view/sharedcache/core/SharedCache.h')
-rw-r--r--view/sharedcache/core/SharedCache.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/view/sharedcache/core/SharedCache.h b/view/sharedcache/core/SharedCache.h
index 2f099773..9e9688bd 100644
--- a/view/sharedcache/core/SharedCache.h
+++ b/view/sharedcache/core/SharedCache.h
@@ -940,6 +940,8 @@ namespace SharedCacheCore {
void Store() override
{
+ m_activeContext.doc.AddMember("metadataVersion", METADATA_VERSION, m_activeContext.allocator);
+
MSS(m_viewState);
MSS_CAST(m_cacheFormat, uint8_t);
MSS(m_imageStarts);
@@ -1026,6 +1028,19 @@ namespace SharedCacheCore {
}
void Load() override
{
+ if (m_activeDeserContext.doc.HasMember("metadataVersion"))
+ {
+ if (m_activeDeserContext.doc["metadataVersion"].GetUint() != METADATA_VERSION)
+ {
+ m_logger->LogError("SharedCache metadata version mismatch");
+ return;
+ }
+ }
+ else
+ {
+ m_logger->LogError("SharedCache metadata version missing");
+ return;
+ }
m_viewState = MSL_CAST(m_viewState, uint8_t, DSCViewState);
m_cacheFormat = MSL_CAST(m_cacheFormat, uint8_t, SharedCacheFormat);
m_headers.clear();
@@ -1101,6 +1116,8 @@ namespace SharedCacheCore {
si.LoadFromValue(siV);
m_nonImageRegions.push_back(si);
}
+
+ m_metadataValid = true;
}
private:
@@ -1108,7 +1125,7 @@ namespace SharedCacheCore {
/* VIEW STATE BEGIN -- SERIALIZE ALL OF THIS AND STORE IT IN RAW VIEW */
// Updated as the view is loaded further, more images are added, etc
- DSCViewState m_viewState;
+ DSCViewState m_viewState = DSCViewStateUnloaded;
std::unordered_map<uint64_t, std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>>>
m_exportInfos;
std::unordered_map<uint64_t, std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>>>
@@ -1116,6 +1133,8 @@ namespace SharedCacheCore {
// ---
// Serialized once by PerformInitialLoad and available after m_viewState == Loaded
+ bool m_metadataValid = false;
+
std::string m_baseFilePath;
SharedCacheFormat m_cacheFormat;
@@ -1171,7 +1190,10 @@ namespace SharedCacheCore {
void FindSymbolAtAddrAndApplyToAddr(uint64_t symbolLocation, uint64_t targetLocation, bool triggerReanalysis);
- std::vector<BackingCache> BackingCaches() const { return m_backingCaches; }
+ std::vector<BackingCache> BackingCaches() const {
+
+ return m_backingCaches;
+ }
DSCViewState State() const { return m_viewState; }