Skip to content

feat: add BinaryDataNotification (55 callbacks) + Register/UnregisterDataNotification#40

Merged
tinysec merged 1 commit into
masterfrom
feat/binary-data-notification
Jul 9, 2026
Merged

feat: add BinaryDataNotification (55 callbacks) + Register/UnregisterDataNotification#40
tinysec merged 1 commit into
masterfrom
feat/binary-data-notification

Conversation

@tinysec

@tinysec tinysec commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Closes parity gap #0.

Mirrors Python BinaryDataNotification (binaryview.py:247) and the C BNBinaryDataNotification struct (55 callback slots), using the same delegate-rooting pattern as PR #39 (TypeArchive notifications).

Changes

  • Struct/BNBinaryDataNotification.cs: flesh out the empty stub into an abstract BinaryDataNotification base with 55 virtual On* methods, each citing its Python source line. The six OnExternalLibrary*/OnExternalLocation* events have no Python equivalent and expose the struct slots directly for completeness.
  • Delegate/BinaryDataNotificationCallbacks.cs (new): 9 delegate types (shared by signature shape) + BinaryDataNotificationContext that roots 55 wrapper delegates, marshals each native callback into managed objects, and builds/frees the BNBinaryDataNotification struct. Borrowed handles are add-ref'd via the existing NewFromHandle factories; borrowed struct pointers (BNDataVariable*, BNTagReference*, BNDerivedString*) are read via PtrToStructure. Throwing overrides are swallowed (Python logs and continues).
  • Handle/BNBinaryView.cs: RegisterDataNotification/UnregisterDataNotification + per-view context map, replacing the two generator-emitted TODOs.

Design notes

  • Python's NotificationType opt-in filtering is not reproduced: all 55 slots are always wired (matching the TypeArchive approach in PR feat: TypeArchive type-add/update/rename/delete notifications #39). The notification_barrier slot is wired but driven by the core's notification loop (active during analysis), so it is not delivered in a static headless database.

Verification

  • dotnet build -c Release: clean, 0 warnings.
  • E2E (local harness, cat.bndb), new BinaryDataNotificationTests:
    • DefineUserTypeOnTypeDefined (QualifiedName + Type payload)
    • DefineUserDataVariableOnDataVariableAdded (borrowed BNDataVariable* → view-attached DataVariable; type width proves the BNType* was wrapped)
    • DefineAutoSymbolOnSymbolAdded (handle payload)
    • register/unregister idempotent
  • Full harness suite: 68/68 pass (66 prior + 2 new), no regressions.

…DataNotification

Closes parity gap #0. Mirrors Python BinaryDataNotification (binaryview.py:247)
and the C BNBinaryDataNotification struct (55 callback slots), using the same
delegate-rooting pattern as PR #39 (TypeArchive notifications):

- Struct/BNBinaryDataNotification.cs: flesh out the empty stub into an abstract
  BinaryDataNotification base with 55 virtual methods (On*), each citing its
  Python source line. The six OnExternalLibrary*/OnExternalLocation* events have
  no Python equivalent and expose the struct slots directly.
- Delegate/BinaryDataNotificationCallbacks.cs: 9 delegate types (shared by
  signature shape) + BinaryDataNotificationContext that roots 55 wrapper
  delegates, marshals each native callback into managed objects, and builds/frees
  the BNBinaryDataNotification struct. Borrowed handles are add-ref'd via the
  existing NewFromHandle factories; borrowed struct pointers (BNDataVariable*,
  BNTagReference*, BNDerivedString*) are read via PtrToStructure. Throwing
  overrides are swallowed (Python logs and continues).
- Handle/BNBinaryView.cs: RegisterDataNotification/UnregisterDataNotification
  + per-view context map, replacing the two generator-emitted TODOs.

Python's NotificationType opt-in filtering is not reproduced: all 55 slots are
always wired (matching the TypeArchive approach). The notification_barrier slot
is wired but driven by the core's notification loop, so it is not delivered in a
static headless database.
@tinysec tinysec merged commit 1461ef9 into master Jul 9, 2026
1 check passed
@tinysec tinysec deleted the feat/binary-data-notification branch July 9, 2026 03:05
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