| 372 | |
| 373 | |
| 374 | KernelCache::KernelCache(BinaryNinja::Ref<BinaryNinja::BinaryView> kcView) : m_kcView(kcView), |
| 375 | m_viewSpecificState(ViewSpecificStateForView(kcView)) |
| 376 | { |
| 377 | std::lock_guard lock(m_mutex); |
| 378 | m_logger = LogRegistry::GetLogger("KernelCache", kcView->GetFile()->GetSessionId()); |
| 379 | if (kcView->GetTypeName() != KC_VIEW_NAME) |
| 380 | { |
| 381 | // Unreachable? |
| 382 | m_logger->LogError("Attempted to create KernelCache object from non-KernelCache view"); |
| 383 | return; |
| 384 | } |
| 385 | |
| 386 | INIT_KERNELCACHE_API_OBJECT() |
| 387 | DeserializeFromRawView(lock); |
| 388 | if (!m_metadataValid) |
| 389 | return; |
| 390 | |
| 391 | if (m_modifiedState->viewState.value_or(m_viewSpecificState->viewState) != KCViewStateUnloaded) |
| 392 | { |
| 393 | m_viewSpecificState->progress = LoadProgressFinished; |
| 394 | return; |
| 395 | } |
| 396 | |
| 397 | std::unique_lock viewOperationsLock(m_viewSpecificState->viewOperationsThatInfluenceMetadataMutex); |
| 398 | |
| 399 | try { |
| 400 | PerformInitialLoad(lock); |
| 401 | } |
| 402 | catch (...) |
| 403 | { |
| 404 | m_logger->LogError("Failed to perform initial load of KernelCache"); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | KernelCache::~KernelCache() { |
| 409 | } |
nothing calls this directly
no test coverage detected