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

Method ProcessEntrySlideInfo

view/sharedcache/core/SharedCache.cpp:412–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412void SharedCache::ProcessEntrySlideInfo(const CacheEntry& entry) const
413{
414 auto slideInfoProcessor = SlideInfoProcessor(GetBaseAddress());
415
416 // This will be set for every associated `VirtualMemoryRegion` so that any accesses though the VM will be always be slid.
417 // NOTE: This MUST be called on the CacheEntry object owned by SharedCache, otherwise persistence through the `SharedCacheController` will not occur.
418 // NOTE: This will keep a copy of a processor in the `WeakFileAccessor` until that object is destroyed (likely view destruction).
419 // NOTE: This will keep a copy of the cache entry in the `WeakFileAccessor` until that object is destroyed (likely view destruction).
420 auto reviveCallback = [slideInfoProcessor, entry](MappedFileAccessor& revivedAccessor) {
421 slideInfoProcessor.ProcessEntry(revivedAccessor, entry);
422 };
423
424 // Use the current entry accessor, don't register the callback for this one as we want calls through the VM to be slid only.
425 // Actually process the slide info for this entry, everything else besides this is to support revived file accessors.
426 auto slideMappings = slideInfoProcessor.ProcessEntry(*entry.GetAccessor().lock(), entry);
427
428 // Register the revive callback for all virtual memory regions that have been slid.
429 // The reason we don't just set this on the entry accessor is that accessor is not consulted for anything really after
430 // this point, everything else will be going through the virtual memory, and because the callback is on the weak accessor
431 // reference and not the file accessor cache itself this matters.
432 auto vm = GetVirtualMemory();
433 for (const auto& mapping : slideMappings)
434 {
435 // Because the mapping address is a file offset for us to consult the virtual memory we must first call `GetMappedAddress`.
436 if (auto mappedMappingAddr = entry.GetMappedAddress(mapping.address))
437 {
438 if (auto vmRegion = vm->GetRegionAtAddress(*mappedMappingAddr))
439 {
440 // Ok we have the virtual memory region, lets register the callback on its accessor.
441 vmRegion->fileAccessor.RegisterReviveCallback(reviveCallback);
442 continue;
443 }
444 }
445
446 LogWarn("Failed to register revive callback for slide mapping %llx in entry '%s'", mapping.address, entry.GetFileName().c_str());
447 }
448}
449
450void SharedCache::ProcessSymbols()
451{

Callers 1

InitControllerMethod · 0.80

Calls 9

SlideInfoProcessorClass · 0.85
ProcessEntryMethod · 0.80
GetAccessorMethod · 0.80
GetMappedAddressMethod · 0.80
GetRegionAtAddressMethod · 0.80
c_strMethod · 0.80
GetFileNameMethod · 0.80
lockMethod · 0.45

Tested by

no test coverage detected