| 227 | } |
| 228 | |
| 229 | void SharedCache::AddEntry(CacheEntry entry) |
| 230 | { |
| 231 | // Get the file accessor to associate with the virtual memory region. |
| 232 | auto fileAccessor = FileAccessorCache::Global().Open(entry.GetFilePath()); |
| 233 | |
| 234 | // Populate virtual memory using the entry mappings, by doing so we can now |
| 235 | // read the memory of the mapped regions of the cache entry file. |
| 236 | const auto& mappings = entry.GetMappings(); |
| 237 | for (const auto& mapping : mappings) |
| 238 | { |
| 239 | m_vm->MapRegion(fileAccessor, {mapping.address, mapping.address + mapping.size}, mapping.fileOffset); |
| 240 | |
| 241 | // Recalculate the base address. |
| 242 | if (mapping.address < m_baseAddress || m_baseAddress == 0) |
| 243 | m_baseAddress = mapping.address; |
| 244 | } |
| 245 | |
| 246 | // We are done and can make the entry visible to the entire cache. |
| 247 | m_entries.push_back(std::move(entry)); |
| 248 | } |
| 249 | |
| 250 | bool SharedCache::ProcessEntryImage(const std::string& path, const dyld_cache_image_info& info) |
| 251 | { |