MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / SharedCacheBuilder

Class SharedCacheBuilder

view/sharedcache/core/SharedCacheBuilder.h:7–44  ·  view source on GitHub ↗

This constructs a Cache, give it a file path, and it will add all relevant cache entries.

Source from the content-addressed store, hash-verified

5
6// This constructs a Cache, give it a file path, and it will add all relevant cache entries.
7class SharedCacheBuilder
8{
9 BinaryNinja::Ref<BinaryNinja::BinaryView> m_view;
10 BinaryNinja::Ref<BinaryNinja::Logger> m_logger;
11
12 // When we call `AddFile` it will start populating this caches entries.
13 // This cache is what is returned via `Finalize`.
14 SharedCache m_cache;
15
16 // List of already processedFiles so we skip adding them again.
17 std::set<std::string> m_processedFiles;
18 // The base file name (i.e. "dyld_shared_cache_arm64e"), this is used to filter out non-relevant files.
19 std::string m_primaryFileName;
20
21public:
22 explicit SharedCacheBuilder(BinaryNinja::Ref<BinaryNinja::BinaryView> view);
23
24 SharedCache& GetCache() { return m_cache; };
25 std::set<std::string> GetProcessedFiles() { return m_processedFiles; };
26 std::string GetPrimaryFileName() { return m_primaryFileName; };
27
28 // Set the base file name used when filtering in `AddFile`.
29 void SetPrimaryFileName(const std::string& baseFileName) { m_primaryFileName = baseFileName; };
30
31 // Returns a shared cache that is ready for processing, this should include all the required shared cache entries.
32 SharedCache Finalize();
33
34 // Tries to add the file to the shared cache, if the file has already been processed or is not valid
35 // then false will be returned, true if the file was added to the shared cache. A file can only be added once.
36 bool AddFile(
37 const std::string& filePath, const std::string& fileName, CacheEntryType cacheType = CacheEntryType::Secondary);
38
39 // Process a directory on the file system.
40 size_t AddDirectory(const std::string& directoryPath);
41
42 // Process a directory in a project.
43 size_t AddProjectFolder(BinaryNinja::Ref<BinaryNinja::ProjectFolder> folder);
44};

Callers 1

InitControllerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected