summaryrefslogtreecommitdiff
path: root/view
AgeCommit message (Collapse)Author
2025-04-02[SharedCache] Don't crash if we have a different metadata versionMason Reed
Also we now initialize m_cacheInfo when calling `DeserializeFromRawView` the responsibility is on the caller to handle
2025-04-02[SharedCache] Warn when loading BNDB with different shared cache metadata ↵Mason Reed
version This does not actually give the user control to exit early, that looks to need core changes.
2025-03-28belated copyright year updateJordan Wiens
2025-03-28Fix initial navigation to DSCTriage viewPeter LaFosse
2025-03-19[KernelCache] Improvements to triage view; Fix double-click double-load ↵kat
issue, dont prompt on loading from symbol, auto-navigate to symbol when clicked, loading first if required
2025-03-19Disable MH_FILESET parsing in Mach-O viewkat
2025-03-19Add iOS/macOS MH_FILESET KernelCache View and loader.kat
This loader is inspired by/based on our dyld_shared_cache loader, following the same design language. It targets primarily the latest kernels, but should support any with the MH_FILESET format. It allows you to decide which images you would like to map in (the kernel itself included), resulting in targeted analysis when you may only need to load a singular image. It also supports dropping in compressed KernelCaches, directly from the ipsw. This is an early solution and we have many more changes and improvements planned. We look forward to your feedback
2025-03-19Add Kernel64 pointer format generickat
2025-03-18Fix loading .gnu_debugdata when loading an ELF with non-zero baseJosh Ferrell
2025-03-18[SharedCache] Limit sections being added in `SharedCache::InitializeHeader` ↵WeiN76LQh
to the regions being loaded The logic before would default to adding a section unless it was from a region in the `regionsToLoad` argument and its header had already been initialized. However if a user does `Load Section by Address` then there's only one region in `regionsToLoad`. All sections not in that region would be automatically added, even if they had already been or the user hadn't requested them to be loaded.
2025-03-18dyld_shared_cache: Resolve issue where Cache info tables were mistakenly ↵kat
editable
2025-03-18MachO/ObjC: Avoid generating names containing non-printable charsDaniel Roethlisberger
Avoid generating ObjC symbol names containing non-printable characters for both 8 and 16 bit character encodings.
2025-03-18[SharedCache] Improvements to triage view; Fix double-click double-load ↵kat
issue, dont prompt on loading from symbol, auto-navigate to symbol when clicked, loading first if required
2025-03-18Documentation and type hints for sharedcache.py, properly import ↵kat
binaryninja.sharedcache automatically
2025-03-18[SharedCache] Resolve x86_64h binaries not being recognizedkat
2025-03-07Allow PE view endianness to be overridden to BEBrandon Miller
2025-03-04Use robust check for MIPS architecture when generating the lazy bind ↵Brian Potchik
resolver symbol.
2025-03-03Perform fixups for MIPS local GOT slots using synthetic relocation entries.Brian Potchik
2025-03-03Correctly perform fixups for MIPS32 local symbols using synthetic relocation ↵Brian Potchik
entries.
2025-02-28[SharedCache] Fix symbol view navigation away from DSCTriage into Linear/Graphkat
2025-02-26[SharedCache] Add the ability to install the plugin using CMakeWeiN76LQh
Using `-t install` currently doesn't install the plugin into the Binary Ninja user plugin directory. This commit fixes that.
2025-02-26[SharedCache] Fix loading DSC BNDB from a local project crashingGlenn Smith
Also fixes a BinaryViewRef leak
2025-02-24Implement Rust MemoryMapMason Reed
Also split out SegmentFlags and fix some UB with the section creation
2025-02-19[SharedCache] Don't capture `this` within lambda passed to ↵Mark Rowe
MMappedFileAccessor::Open Nothing guarantees that the `SharedCache` lives long enough.
2025-02-18[SharedCache] Fix un-updated symbols listMason Reed
There was a second BeginBulkModifySymbols after rebasing the new processing symbols commit
2025-02-17[SharedCache] Fix building on windows due to unresolved extern symbolsMason Reed
This is _probably_ the fix? I am not actually sure I am pushing so the CI can figure it out for me :)
2025-02-17[SharedCache] Remove using namespace statement from headersMason Reed
2025-02-17Don't fully initialize when in parseOnly modePeter LaFosse
2025-02-17[SharedCache] Split out symbol processing into own functionMason Reed
Split out from https://github.com/WeiN76LQh/binaryninja-api/tree/process-local-symbols
2025-02-17[SharedCache] Define BackingCacheTypeWeiN76LQh
Split out from https://github.com/WeiN76LQh/binaryninja-api/tree/process-local-symbols
2025-02-17[SharedCache] Remove serialization of "unsigned long" in favor of uintX_tGlenn Smith
2025-02-17Fix assert on deserialize routines_command_64Glenn Smith
2025-02-17[SharedCache] Split state into initial, loaded, and modifiedMark Rowe
The initial state is initialized during `PerformInitialLoad` and is immutable after that point. This required some slight restructuring of how information about memory regions is tracked as that was previously modified as regions were loaded. Memory regions are now stored in a map from their address range to the `MemoryRegion` object. This makes it cheap to look them up by address which is a common operation. The modified state consists of changes since the last save to the `DSCView` / `ViewSpecificState`. This means it is no longer necessary to copy any state when mutating a `SharedCache` instance for the first time. Instead, its data structures start off empty and are populated as images, sections, or symbol information is loaded. The loaded state consists of all modified state that has since been saved. It lives on the `ViewSpecificState`. Saving modified state merges it into the the existing loaded state. This pattern is carried over to the `Metadata` stored on the `DSCView`. The initial state is stored under its own metadata key, and each modified state is stored under a key with an incrementing number. This means each save of the state only needs to serialize the state that changed, rather than reserializing all of the state all of the time. There are two huge benefits from these changes: 1. At no point does `SharedCache` have to copy its in memory state. The basic copy-on-write approach introduced in #6129 reduced how often these copies are made, but they're still frequent and very expensive. 1. At no point does `SharedCache` have to re-serialize state to JSON that it has already serialized. JSON serialization previously added hundreds of milliseconds to any mutating operation on `SharedCache`. As a result, this speeds up the initial load of the shared cache by around 2x and loading of subsequent images improves by about the same. One trade-off is that the serialization / deserialization logic is more complicated. There are two reasons for this: 1. The state is now split across multiple metadata keys and needs to be merged when it is loaded. 2. The in-memory representation uses pointers to identify memory regions. These relationships have to be re-established after the JSON is deserialized. As a future direction it is worth considering whether the logic owned by `SharedCache` could be split in a similar manner to the data. The initial loading of the cache header, loading of images, and handling of symbol information are all mostly independent and work on separate data. If the logic were split into separate classes it would be easier to reason about which data is valid when, and would easily permit concurrent loading of multiple images from the shared library in a thread-safe manner.
2025-02-13Add licensing check for Rust codeMason Reed
If we add new rust dependencies we should now be alerted when a new license type is added.
2025-02-13[SharedCache] Use StringRef for performanceGlenn Smith
2025-02-13Remove bintxt.Brian Potchik
2025-02-12[SharedCache] Remove designator initializationMason Reed
Fixes MSVC C++17 failing to compile, hopefully.
2025-02-12[SharedCache] Don't pretty-print the metadataGlenn Smith
2025-02-12[SharedCache] Fix crash when trying to deserialize a `routines_command_64` ↵Mason Reed
which had not been serialized. We will just return early, this is fine as the previous code would effectively do the same thing.
2025-02-12[SharedCache] Fix misc compiler warningsMason Reed
These are from clang so there are still a bunch of warnings on GCC and MSVC
2025-02-12[SharedCache] Fix designator order for fieldsMason Reed
This apparently is not an issue on LLVM, but GCC and MSVC both seem to dislike this.
2025-02-12[SharedCache] Always initialize logger firstMason Reed
Potential nullptr deref on invalid view type (see the error log right after the logger init)
2025-02-12[SharedCache] Appease formatting rulezMason Reed
This is a meaningless commit, i'm throwing this in for when someone inevitably calls out the inconsistent "formatting" (what style is this again?)
2025-02-12[SharedCache] Fix performance when loading images from iOS 14 shared cachesMark Rowe
A logic error in `FindSymbolAtAddrAndApplyToAddr` meant that a code path that would attempt to re-use existing symbol definitions in the view would still fall back to searching the exported symbol list. `FindSymbolAtAddrAndApplyToAddr` is updated to return early if a symbol already exists at the target location and the target location is the same as the symbol location. Additionally, in the event a symbol was found in the view at the symbol location, it is applied to the target location and then the function returns. Additionally, `WillMutateState` is moved after these initial checks so it is only called in the codepaths that attempt to locate the symbol amongst the exported symbols. After these changes it is now possible to load QuartzCore from the iOS 14 shared cache in around 70 seconds. Previously it would run for hours without the load completing.
2025-02-12[SharedCache] Don't crash if we open a file with slide version 1Mason Reed
Also add some other misc error reporting and nullptr check
2025-02-12Add Symbol constructor for pre-allocated core namespaceMason Reed
This allows a consumer to bypass the alloc + free of the API NameSpace, removing the need for the consumer to manually construct a symbol for said behavior.
2025-02-12[SharedCache] Rework how file accessors are handledMark Rowe
Previously, `MMappedFileAccessor::Open` attempted to impose a fixed limit on the number of file accessors that were live at one time. This was done because the default file descriptor limit on some platforms is relatively low (256 on macOS). Given that recent iOS shared caches can contain 60+ files it is easy to tie up a large percentage of this limit by opening one or two shared caches. This is problematic as if the limit imposed by `MMappedFileAccessor::Open` is reached, the attempt to access the file will block waiting for another file accessor to be closed. This can lead to a deadlock. This commit makes three changes to this strategy: 1. It attempts to raise the file descriptor limit to 1024. Unix systems support both soft and hard file descriptor limits. The soft file descriptor limit is what is enforced, but a process can explicitly raise the limit to any value below the hard limit if it wishes. 2. The fixed limit on open files accessors is changed to a soft limit. `FileAccessorCache` is introduced to manage the caching of file accessors. It provides a basic LRU cache. Whenever a new file is opened, the cache of open accessors is pruned to stay below the target limit (50% of the soft file descriptor limit). This limiting is primarily done to allow files containing dirty pages to be unmapped if they're no longer being used. LRU isn't the optimal strategy for this, but it is simple to implement and understand. Ideally there'd be some access time component to the cache so files that haven't been accessed can be released. 3. File accessors are cached even for sessions corresponding to views that have been closed. The "Open Selection with Options..." context menu hits this case as a view is created and destroyed as part of populating the options dialog, and the real view is then created in the same session. The most significant benefit of this change is that the logic around opening / closing file accessors is simpler and can no longer deadlock. While working on this I noticed that `SharedCache` opened some files via `MMappedFileAccessor::Open` without specifying a post-open operation to apply slide information. Instead, it would explicitly apply the slide information after opening the file. This works fine so long as the file accessor limit is never hit. If it is hit and the accessor is closed, the next time the file is opened it will not have any slide information applied. This would lead to very confusing bugs.
2025-02-12[SharedCache] Simplify MMappedFileAccessor::Read* methodsMark Rowe
This change is mostly motivated by simplifying the code, but it also brings minor correctness and performance benefits. 1. The pointer returned by mmap is stored as a uint8_t* rather than void* as that is how it is used. This reduces how often it needs to be cast to a different type before it is used. 2. Read methods for primitives delegate to a new Read template function that in turn delegates to the general-purpose `Read(void* dest, size_t address, size_t length)`. This improves the consistency of bounds checking and simplifies the code. The compiler is more than willing to inline this so we get less repetition with no overhead. 3. ReadNullTermString now uses std::find to find the nul byte and directly constructs the string from that range of bytes. This removes an unnecessary allocation that was previously being forced by the use reserve followed by shrink_to_fit. It also avoids repeated reallocation for longer strings as they grew past the the reserved size as they were being built up a character at a time.
2025-02-12[SharedCache] Make MetadataSerializable::Load staticMark Rowe
`MetadataSerializable` is updated to allow a subclass to optionally specify the return type of `Load`. If not specified it defaults to the subclass itself. `SharedCache` specifies `std::optional` to represent the case where the serialized metadata is in a format or version it does not recognize. By making `Load` a static member function and having it return a new object it becomes easier to reason about the state of objects when a deserialization failure occurs. It can return `std::optional` to indicate failure and there is no object left in an unknown state. Prior to this, `Load` worked on an existing instance of an object. It was unclear what state the object would be in if a deserialization failure occurred (its original state prior to `Load`? some partially-loaded state? a null state?). The failure itself also had to be communicated out of band.
2025-02-10[SharedCache] Optimizations regarding stl container usage in SharedCache.cppkat