diff options
| author | Mason Reed <mason@vector35.com> | 2025-04-04 23:45:06 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-04-06 20:00:37 -0400 |
| commit | 2e855275732aed00486ca100f4151f4074d9949e (patch) | |
| tree | 24916cf3ffe405706c18d34808d26ef2de893139 /view/sharedcache/core/ffi.cpp | |
| parent | 41450c3df2be33b817c864fb71ca38d76d81d2ab (diff) | |
[SharedCache] Add a named symbol map
Fixes https://github.com/Vector35/binaryninja-api/issues/6561
- Also tightens the SharedCache class to move only, to prevent accidental copies.
- Also removes some extra copies in FFI when should pass by ref
- Also adds `get_symbol_with_name` to python API
The current named symbol map is populated in a worker thread spawned in the view init. This is because populating the map can take about 1 second.
If we are fine with another 1 second added to the view init time then we can add it serially but I don't think this way is _that_ bad, no analysis consults
this, however a user might add a workflow that would be racing this. So we need to add a mutex.
Diffstat (limited to 'view/sharedcache/core/ffi.cpp')
| -rw-r--r-- | view/sharedcache/core/ffi.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/view/sharedcache/core/ffi.cpp b/view/sharedcache/core/ffi.cpp index 0b37196f..e4e92acd 100644 --- a/view/sharedcache/core/ffi.cpp +++ b/view/sharedcache/core/ffi.cpp @@ -195,7 +195,7 @@ extern "C" bool BNSharedCacheControllerGetRegionAt( BNSharedCacheController* controller, uint64_t address, BNSharedCacheRegion* outRegion) { - auto region = controller->object->GetCache().GetRegionAt(address); + const auto region = controller->object->GetCache().GetRegionAt(address); if (!region) return false; *outRegion = RegionToApi(*region); @@ -205,7 +205,7 @@ extern "C" bool BNSharedCacheControllerGetRegionContaining( BNSharedCacheController* controller, uint64_t address, BNSharedCacheRegion* outRegion) { - auto region = controller->object->GetCache().GetRegionContaining(address); + const auto region = controller->object->GetCache().GetRegionContaining(address); if (!region) return false; *outRegion = RegionToApi(*region); @@ -214,7 +214,7 @@ extern "C" BNSharedCacheRegion* BNSharedCacheControllerGetRegions(BNSharedCacheController* controller, size_t* count) { - auto regions = controller->object->GetCache().GetRegions(); + const auto& regions = controller->object->GetCache().GetRegions(); *count = regions.size(); BNSharedCacheRegion* apiRegions = new BNSharedCacheRegion[*count]; int idx = 0; @@ -225,7 +225,7 @@ extern "C" BNSharedCacheRegion* BNSharedCacheControllerGetLoadedRegions(BNSharedCacheController* controller, size_t* count) { - auto loadedRegionStarts = controller->object->GetLoadedRegions(); + const auto& loadedRegionStarts = controller->object->GetLoadedRegions(); // TODO: This translation should likely exist in the core cache controller class? std::vector<CacheRegion> loadedRegions; @@ -271,7 +271,7 @@ extern "C" bool BNSharedCacheControllerGetImageAt( BNSharedCacheController* controller, uint64_t address, BNSharedCacheImage* outImage) { - auto image = controller->object->GetCache().GetImageAt(address); + const auto image = controller->object->GetCache().GetImageAt(address); if (!image) return false; *outImage = ImageToApi(*image); @@ -281,7 +281,7 @@ extern "C" bool BNSharedCacheControllerGetImageContaining( BNSharedCacheController* controller, uint64_t address, BNSharedCacheImage* outImage) { - auto image = controller->object->GetCache().GetImageContaining(address); + const auto image = controller->object->GetCache().GetImageContaining(address); if (!image) return false; *outImage = ImageToApi(*image); @@ -291,7 +291,7 @@ extern "C" bool BNSharedCacheControllerGetImageWithName( BNSharedCacheController* controller, const char* name, BNSharedCacheImage* outImage) { - auto image = controller->object->GetCache().GetImageWithName(name); + const auto image = controller->object->GetCache().GetImageWithName(name); if (!image) return false; *outImage = ImageToApi(*image); @@ -317,7 +317,7 @@ extern "C" BNSharedCacheImage* BNSharedCacheControllerGetImages(BNSharedCacheController* controller, size_t* count) { - auto images = controller->object->GetCache().GetImages(); + const auto& images = controller->object->GetCache().GetImages(); *count = images.size(); BNSharedCacheImage* apiImages = new BNSharedCacheImage[*count]; size_t idx = 0; @@ -328,7 +328,7 @@ extern "C" BNSharedCacheImage* BNSharedCacheControllerGetLoadedImages(BNSharedCacheController* controller, size_t* count) { - auto loadedImageStarts = controller->object->GetLoadedImages(); + const auto& loadedImageStarts = controller->object->GetLoadedImages(); // TODO: This translation should likely exist in the core cache controller class? std::vector<CacheImage> loadedImages; @@ -362,7 +362,7 @@ extern "C" bool BNSharedCacheControllerGetSymbolAt( BNSharedCacheController* controller, uint64_t address, BNSharedCacheSymbol* outSymbol) { - auto symbol = controller->object->GetCache().GetSymbolAt(address); + const auto symbol = controller->object->GetCache().GetSymbolAt(address); if (!symbol) return false; *outSymbol = SymbolToApi(*symbol); @@ -372,7 +372,7 @@ extern "C" bool BNSharedCacheControllerGetSymbolWithName( BNSharedCacheController* controller, const char* name, BNSharedCacheSymbol* outSymbol) { - auto symbol = controller->object->GetCache().GetSymbolWithName(name); + const auto symbol = controller->object->GetCache().GetSymbolWithName(name); if (!symbol) return false; *outSymbol = SymbolToApi(*symbol); @@ -381,7 +381,7 @@ extern "C" BNSharedCacheSymbol* BNSharedCacheControllerGetSymbols(BNSharedCacheController* controller, size_t* count) { - auto symbols = controller->object->GetCache().GetSymbols(); + const auto& symbols = controller->object->GetCache().GetSymbols(); *count = symbols.size(); BNSharedCacheSymbol* apiSymbols = new BNSharedCacheSymbol[*count]; size_t idx = 0; @@ -405,7 +405,7 @@ extern "C" BNSharedCacheEntry* BNSharedCacheControllerGetEntries(BNSharedCacheController* controller, size_t* count) { - auto entries = controller->object->GetCache().GetEntries(); + const auto& entries = controller->object->GetCache().GetEntries(); *count = entries.size(); BNSharedCacheEntry* apiEntries = new BNSharedCacheEntry[*count]; size_t idx = 0; |
