summaryrefslogtreecommitdiff
path: root/view/sharedcache
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2024-11-13 15:26:37 -0500
committerkat <kat@vector35.com>2024-11-13 16:18:10 -0500
commit6bd0f078c302ff641c01767be01d9f20445521ab (patch)
tree551df6c34678f2766d7329430d422880fa1d686a /view/sharedcache
parentd553396c16a1f356f35f383d7838df8b4d8717b5 (diff)
[SharedCache] Fix a bndb deserialization error caused by last commit
Diffstat (limited to 'view/sharedcache')
-rw-r--r--view/sharedcache/CMakeLists.txt2
-rw-r--r--view/sharedcache/core/DSCView.cpp50
-rw-r--r--view/sharedcache/core/SharedCache.h60
3 files changed, 34 insertions, 78 deletions
diff --git a/view/sharedcache/CMakeLists.txt b/view/sharedcache/CMakeLists.txt
index 6c695b05..63ba602b 100644
--- a/view/sharedcache/CMakeLists.txt
+++ b/view/sharedcache/CMakeLists.txt
@@ -30,7 +30,7 @@ endif()
set(HARD_FAIL_MODE OFF CACHE BOOL "Enable hard fail mode")
set(SLIDEINFO_DEBUG_TAGS OFF CACHE BOOL "Enable debug tags in slideinfo")
set(VIEW_NAME "DSCView" CACHE STRING "Name of the view")
-set(METADATA_VERSION 1 CACHE STRING "Version of the metadata")
+set(METADATA_VERSION 2 CACHE STRING "Version of the metadata")
add_subdirectory(core)
add_subdirectory(api)
diff --git a/view/sharedcache/core/DSCView.cpp b/view/sharedcache/core/DSCView.cpp
index 06a73a69..31af3bd7 100644
--- a/view/sharedcache/core/DSCView.cpp
+++ b/view/sharedcache/core/DSCView.cpp
@@ -662,27 +662,18 @@ bool DSCView::Init()
}
std::vector<std::pair<uint64_t, std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>>>> exportInfos;
- for (auto& exportInfo : result["exportInfos"].GetArray())
- {
- std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> exportInfoVec;
- for (auto& exportInfoPair : exportInfo.GetArray())
- {
- exportInfoVec.push_back({exportInfoPair[0].GetUint64(), { (BNSymbolType)exportInfoPair[1].GetUint(), exportInfoPair[2].GetString()}});
- }
- exportInfos.push_back({exportInfo[0].GetUint64(), exportInfoVec});
- }
- std::vector<std::pair<uint64_t, std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>>>> symbolInfos;
- for (auto& symbolInfo : result["symbolInfos"].GetArray())
+ for (const auto& obj1 : result["exportInfos"].GetArray())
{
- std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> symbolInfoVec;
- for (auto& symbolInfoPair : symbolInfo.GetArray())
+ std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> innerVec;
+ for (const auto& obj2 : obj1["value"].GetArray())
{
- symbolInfoVec.push_back({symbolInfoPair[0].GetUint64(), { (BNSymbolType)symbolInfoPair[1].GetUint(), symbolInfoPair[2].GetString()}});
+ std::pair<BNSymbolType, std::string> innerPair = { (BNSymbolType)obj2["val1"].GetUint64(), obj2["val2"].GetString() };
+ innerVec.push_back({ obj2["key"].GetUint64(), innerPair });
}
- symbolInfos.push_back({symbolInfo[0].GetUint64(), symbolInfoVec});
- }
+ exportInfos.push_back({obj1["key"].GetUint64(), innerVec});
+ }
// We need to re-map data located in the Raw (parent parent) viewtype to the DSCRaw (parent) viewtype.
for (auto region : regionsMappedIntoMemory)
{
@@ -693,31 +684,6 @@ bool DSCView::Init()
}
BeginBulkModifySymbols();
- for (const auto & [imageBaseAddr, symbolList] : symbolInfos)
- {
- std::vector<Ref<Symbol>> symbolsList;
- for (const auto & [symAddr, symTypeAndName] : symbolList)
- {
- symbolsList.push_back(new Symbol(symTypeAndName.first, symTypeAndName.second, symAddr));
- }
-
- auto typelib = GetTypeLibrary(imageStartToInstallName[imageBaseAddr]);
-
- for (const auto& symbol : symbolsList)
- {
- if (typelib)
- {
- auto type = typelib->GetNamedObject(symbol->GetRawName());
- if (type)
- {
- DefineAutoSymbolAndVariableOrFunction(GetDefaultPlatform(), symbol, type);
- continue;
- }
- }
- DefineAutoSymbol(symbol);
- }
- }
-
for (const auto & [imageBaseAddr, exportList] : exportInfos)
{
std::vector<Ref<Symbol>> symbolsList;
@@ -730,6 +696,8 @@ bool DSCView::Init()
for (const auto& symbol : symbolsList)
{
+ if (!IsValidOffset(symbol->GetAddress()))
+ continue;
if (typelib)
{
auto type = typelib->GetNamedObject(symbol->GetRawName());
diff --git a/view/sharedcache/core/SharedCache.h b/view/sharedcache/core/SharedCache.h
index a27b15a0..81c02620 100644
--- a/view/sharedcache/core/SharedCache.h
+++ b/view/sharedcache/core/SharedCache.h
@@ -953,41 +953,28 @@ namespace SharedCacheCore {
}
m_activeContext.doc.AddMember("headers", headers, m_activeContext.allocator);
// std::vector<std::pair<uint64_t, std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>>>> m_exportInfos
- rapidjson::Value exportInfos(rapidjson::kArrayType);
- for (auto& exportInfo : m_exportInfos)
+ // std::vector<std::pair<uint64_t, std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>>>> exportInfos;
+ rapidjson::Document exportInfos(rapidjson::kArrayType);
+
+ for (const auto& pair1 : m_exportInfos)
{
- rapidjson::Value exportInfoArr(rapidjson::kArrayType);
- for (auto& exportInfoPair : exportInfo.second)
+ rapidjson::Value subObj(rapidjson::kObjectType);
+ rapidjson::Value subArr(rapidjson::kArrayType);
+ for (const auto& pair2 : pair1.second)
{
- rapidjson::Value exportInfoPairArr(rapidjson::kArrayType);
- exportInfoPairArr.PushBack(exportInfoPair.first, m_activeContext.allocator);
- exportInfoPairArr.PushBack(exportInfoPair.second.first, m_activeContext.allocator);
- exportInfoPairArr.PushBack(
- rapidjson::Value(exportInfoPair.second.second.c_str(), m_activeContext.allocator),
- m_activeContext.allocator);
- exportInfoArr.PushBack(exportInfoPairArr, m_activeContext.allocator);
+ rapidjson::Value subSubObj(rapidjson::kObjectType);
+ subSubObj.AddMember("key", pair2.first, m_activeContext.allocator);
+ subSubObj.AddMember("val1", pair2.second.first, m_activeContext.allocator);
+ subSubObj.AddMember("val2", pair2.second.second, m_activeContext.allocator);
+ subArr.PushBack(subSubObj, m_activeContext.allocator);
}
- exportInfos.PushBack(exportInfoArr, m_activeContext.allocator);
+
+ subObj.AddMember("key", pair1.first, m_activeContext.allocator);
+ subObj.AddMember("value", subArr, m_activeContext.allocator);
+
+ exportInfos.PushBack(subObj, m_activeContext.allocator);
}
m_activeContext.doc.AddMember("exportInfos", exportInfos, m_activeContext.allocator);
- // std::vector<std::pair<uint64_t, std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>>>> m_symbolInfos
- rapidjson::Value symbolInfos(rapidjson::kArrayType);
- for (auto& symbolInfo : m_symbolInfos)
- {
- rapidjson::Value symbolInfoArr(rapidjson::kArrayType);
- for (auto& symbolInfoPair : symbolInfo.second)
- {
- rapidjson::Value symbolInfoPairArr(rapidjson::kArrayType);
- symbolInfoPairArr.PushBack(symbolInfoPair.first, m_activeContext.allocator);
- symbolInfoPairArr.PushBack(symbolInfoPair.second.first, m_activeContext.allocator);
- symbolInfoPairArr.PushBack(
- rapidjson::Value(symbolInfoPair.second.second.c_str(), m_activeContext.allocator),
- m_activeContext.allocator);
- symbolInfoArr.PushBack(symbolInfoPairArr, m_activeContext.allocator);
- }
- symbolInfos.PushBack(symbolInfoArr, m_activeContext.allocator);
- }
- m_activeContext.doc.AddMember("symbolInfos", symbolInfos, m_activeContext.allocator);
rapidjson::Value backingCaches(rapidjson::kArrayType);
for (auto bc : m_backingCaches)
@@ -1053,15 +1040,16 @@ namespace SharedCacheCore {
MSL(m_imageStarts);
MSL(m_baseFilePath);
m_exportInfos.clear();
- for (auto& exportInfo : m_activeDeserContext.doc["exportInfos"].GetArray())
+ for (const auto& obj1 : m_activeDeserContext.doc["exportInfos"].GetArray())
{
- std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> exportInfoVec;
- for (auto& exportInfoPair : exportInfo.GetArray())
+ std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> innerVec;
+ for (const auto& obj2 : obj1["value"].GetArray())
{
- exportInfoVec.push_back({exportInfoPair[0].GetUint64(),
- {(BNSymbolType)exportInfoPair[1].GetUint(), exportInfoPair[2].GetString()}});
+ std::pair<BNSymbolType, std::string> innerPair = { (BNSymbolType)obj2["val1"].GetUint64(), obj2["val2"].GetString() };
+ innerVec.push_back({ obj2["key"].GetUint64(), innerPair });
}
- m_exportInfos[exportInfo[0].GetUint64()] = exportInfoVec;
+
+ m_exportInfos[obj1["key"].GetUint64()] = innerVec;
}
m_symbolInfos.clear();
for (auto& symbolInfo : m_activeDeserContext.doc["symbolInfos"].GetArray())