feat: add durable navigation-conveniences extension layer#12
Merged
Conversation
Mirror the ergonomic object-navigation surface of the official Python binding (Type.children, Enumeration/EnumerationBuilder member-by-name/value lookup, StructureType.GetMemberByName, Function.GetLowLevelILExitsAt, and BinaryView.GetDerivedStrings) as extension methods in a single root file. This file lives OUTSIDE the generated Handle/Type/Struct tree on purpose: the generator regenerates those wrappers from the upstream C++ header on every resync, so anything added there is wiped, while a root file (like UnsafeUtils.cs) survives. Extension methods also leave the generated C++ mirror untouched. Every member is pure C# composition over existing accessors or a thin wrapper over an already-present export, so all are e2e-validatable. BNDerivedString interop uses LayoutKind.Explicit with offsets pinned to the C ABI in binaryninjacore.h (the embedded bool before an 8-byte-aligned struct is the one non-obvious case), and a one-shot runtime self-check locks the layout to 48/24 bytes. Validation: new out-of-repo NavigationConvenience e2e module (15 checks) across 3 samples -> 1413 passed / 0 failed / 3 skipped. GetDerivedStrings returns 0 on these samples, so per-element field decode is verified-by-construction (locked layout + proven UTF-8 string-ref read) rather than by data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the ergonomic object-navigation surface from the official Python binding as a durable extension-method layer in a single root file (
NavigationExtensions.cs), without touching the generated C++ mirror.Why this shape
The generated
Handle/Type/Structwrappers aresealedand regenerated from the upstream C++ header on every resync, so anything added there is wiped. A root file (likeUnsafeUtils.cs) survives; extension methods also leave the generated mirror untouched. Every member is pure C# composition over existing accessors, or a thin wrapper over an already-present export — so all are e2e-validatable.Conveniences added
Enumeration.GetMemberByName / GetMemberByValueMembersEnumerationBuilder.GetMemberByName / GetMemberByValueMembersType.GetChildren()TypeClass(mirror PythonType.children)StructureType.GetMemberByNameStructure.GetMemberByNameFunction.GetLowLevelILExitsAtGetInstructionStart+GetExitsForInstructionBinaryView.GetDerivedStringsBNGetDerivedStrings+ hand-writtenBNDerivedStringinteropBNDerivedStringusesLayoutKind.Explicitwith offsets pinned tobinaryninjacore.h(the embeddedboolbefore an 8-byte-aligned struct is the one non-obvious case) plus a one-shot runtime self-check locking the layout to 48/24 bytes.Deferred:
GetDerivedStringCodeReferences(needs inputToNativemarshaling + a producing sample to validate) and the Category-B items whose core exports are absent in the installed build (ReturnValueLocation,CallingConvention.AreStackArguments*).Validation
New out-of-repo
NavigationConvenienceTestse2e module (15 checks/sample) across 3 samples -> 1413 passed / 0 failed / 3 skipped (was 1368).GetDerivedStringsreturns 0 on these samples, so per-element field decode is verified-by-construction (locked layout + the binding's proven UTF-8 string-ref read) rather than by data.Closes the navigation-parity audit: the binding mirrors C++ 1:1 (no defects); this layer adopts the worth-learning Python ergonomics durably.