Skip to content

feat: add durable navigation-conveniences extension layer#12

Merged
tinysec merged 1 commit into
masterfrom
feat/navigation-conveniences
Jul 6, 2026
Merged

feat: add durable navigation-conveniences extension layer#12
tinysec merged 1 commit into
masterfrom
feat/navigation-conveniences

Conversation

@tinysec

@tinysec tinysec commented Jul 6, 2026

Copy link
Copy Markdown
Owner

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/Struct wrappers are sealed and regenerated from the upstream C++ header on every resync, so anything added there is wiped. A root file (like UnsafeUtils.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

Convenience Basis
D Enumeration.GetMemberByName / GetMemberByValue over Members
D EnumerationBuilder.GetMemberByName / GetMemberByValue over Members
D Type.GetChildren() switch on TypeClass (mirror Python Type.children)
D StructureType.GetMemberByName forwarder to Structure.GetMemberByName
D Function.GetLowLevelILExitsAt GetInstructionStart + GetExitsForInstruction
C BinaryView.GetDerivedStrings BNGetDerivedStrings + hand-written BNDerivedString interop

BNDerivedString uses LayoutKind.Explicit with offsets pinned to binaryninjacore.h (the embedded bool before 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 input ToNative marshaling + 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 NavigationConvenienceTests e2e module (15 checks/sample) across 3 samples -> 1413 passed / 0 failed / 3 skipped (was 1368). GetDerivedStrings returns 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.

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.
@tinysec tinysec merged commit 61bb4c7 into master Jul 6, 2026
1 check passed
@tinysec tinysec deleted the feat/navigation-conveniences branch July 6, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant