Skip to content

Commit 8eb1b5e

Browse files
committed
wip
1 parent 0711738 commit 8eb1b5e

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

view/sharedcache/core/SharedCache.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ CacheEntryId SharedCache::AddEntry(CacheEntry entry)
180180
m_vm->MapRegion(fileAccessor, {mapping.address, mapping.address + mapping.size}, mapping.fileOffset);
181181

182182
// Recalculate the base address.
183-
if (mapping.address < m_baseAddress)
183+
if (mapping.address < m_baseAddress || m_baseAddress == 0)
184184
m_baseAddress = mapping.address;
185185
}
186186

@@ -456,8 +456,7 @@ bool CacheProcessor::ProcessCache(SharedCache& cache)
456456
// NOTE: This is extremely error-prone!
457457
// We are going to start trying to find files next to this one on disk!
458458
std::filesystem::path basePath = std::filesystem::path(baseFilePath).parent_path();
459-
std::string pattern = fmt::format(".*{}\\.([0-9]+|symbols|dylddata)$", FileName(baseFilePath));
460-
auto subCachePattern = std::regex(pattern);
459+
std::string baseFileName = FileName(baseFilePath);
461460
for (const auto &entry : std::filesystem::directory_iterator(basePath))
462461
{
463462
if (!entry.is_regular_file())
@@ -468,8 +467,8 @@ bool CacheProcessor::ProcessCache(SharedCache& cache)
468467
if (currentFilePath == baseFilePath)
469468
continue;
470469

471-
// Filter files that dont end with .NUMBER or .symbols or .dylddata
472-
if (!std::regex_match(currentFilePath, subCachePattern))
470+
// Filter files that don't contain the base file name i.e. "dyld_shared_cache_arm64e"
471+
if (currentFilePath.find(baseFileName) == std::string::npos)
473472
continue;
474473

475474
auto additionalEntry = CacheEntry::FromFile(currentFilePath, CacheEntryType::Secondary);

view/sharedcache/core/SharedCacheController.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,13 @@ bool SharedCacheController::LoadRegion(BinaryView& view, const CacheRegion& regi
8383
}
8484

8585
// NOTE: Adding a data memory region will store the entire contents of the region in the BNDB.
86+
// TODO: We can use the AddRemoteMemoryRegion if we want to reload on view init.
8687
view.GetMemoryMap()->AddDataMemoryRegion(region.name, region.start, buffer, region.flags);
8788
// TODO: We might want to make this auto if we decide to "reload" all loaded region in view init.
8889
view.AddUserSection(region.name, region.start, region.size, region.SectionSemanticsForRegion());
8990

91+
LogInfo("Loaded region %s at %p", region.name.c_str(), region.start);
92+
9093
m_loadedRegions.insert(region.start);
9194

9295
return true;

view/sharedcache/core/Utility.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,16 @@ void ApplySymbol(Ref<BinaryView> view, Ref<TypeLibrary> typeLib, Ref<Symbol> sym
109109
std::vector<FunctionParameter> callTypeParams;
110110
auto cc = view->GetDefaultArchitecture()->GetCallingConventionByName("apple-arm64-objc-fast-arc-" + num);
111111

112-
callTypeParams.emplace_back("obj", view->GetTypeByName({ "id" }), true, Variable());
113-
114-
auto funcType = Type::FunctionType(view->GetTypeByName({ "id" }), cc, callTypeParams);
115-
func->SetUserType(funcType);
112+
if (auto idType = view->GetTypeByName({ "id" }))
113+
{
114+
callTypeParams.emplace_back("obj", idType, true, Variable());
115+
auto funcType = Type::FunctionType(idType, cc, callTypeParams);
116+
func->SetUserType(funcType);
117+
}
118+
else
119+
{
120+
LogWarn("Failed to find id type for %llx, objective-c processor not ran?", func->GetStart());
121+
}
116122
}
117123
}
118124
}

0 commit comments

Comments
 (0)