| 73 | } |
| 74 | |
| 75 | DSCRef<SharedCacheController> SharedCacheController::Initialize(BinaryView& view, SharedCache&& cache) |
| 76 | { |
| 77 | auto id = GetViewIdFromFileMetadata(*view.GetFile()); |
| 78 | std::unique_lock<std::shared_mutex> lock(GlobalControllersMutex); |
| 79 | auto logger = new Logger("SharedCache.Controller", view.GetFile()->GetSessionId()); |
| 80 | DSCRef<SharedCacheController> controller = new SharedCacheController(std::move(cache), logger); |
| 81 | |
| 82 | // Pull the settings from the view. |
| 83 | if (Ref<Settings> settings = view.GetLoadSettings(VIEW_NAME)) |
| 84 | { |
| 85 | if (settings->Contains("loader.dsc.processObjC")) |
| 86 | controller->m_processObjC = settings->Get<bool>("loader.dsc.processObjC", &view); |
| 87 | if (settings->Contains("loader.dsc.processCFStrings")) |
| 88 | controller->m_processCFStrings = settings->Get<bool>("loader.dsc.processCFStrings", &view); |
| 89 | if (settings->Contains("loader.dsc.regionFilter")) |
| 90 | controller->m_regionFilter = std::regex(settings->Get<std::string>("loader.dsc.regionFilter", &view)); |
| 91 | } |
| 92 | |
| 93 | // TODO: Support old shared cache metadata |
| 94 | // TODO: Not strictly necessary as the user has already loaded the information into the database, this would just |
| 95 | // TODO: prevent incidental extra work from being done when loading a region or image. |
| 96 | // const uint64_t oldStateCount = view.GetUIntMetadata(OLD_METADATA_KEY_COUNT); |
| 97 | |
| 98 | // Check the view auto metadata for shared cache information. |
| 99 | // This effectively restores the state of the opened database to when it was last saved. |
| 100 | // NOTE: We store on the parent view because hilariously, the metadata is not present until after view init. |
| 101 | if (const auto metadata = view.GetParentView()->QueryMetadata(METADATA_KEY)) |
| 102 | controller->LoadMetadata(*metadata); |
| 103 | |
| 104 | GlobalControllers().insert({id, controller}); |
| 105 | return controller; |
| 106 | } |
| 107 | |
| 108 | DSCRef<SharedCacheController> SharedCacheController::FromView(const BinaryView& view) |
| 109 | { |
nothing calls this directly
no test coverage detected