Skip to content

feat: expose TypeLibrary Duplicate/Register/RemoveNamed*/LookupByGuid#35

Merged
tinysec merged 1 commit into
masterfrom
feat/type-library-missing-wrappers
Jul 8, 2026
Merged

feat: expose TypeLibrary Duplicate/Register/RemoveNamed*/LookupByGuid#35
tinysec merged 1 commit into
masterfrom
feat/type-library-missing-wrappers

Conversation

@tinysec

@tinysec tinysec commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Closes HIGH-severity missing-capi gap #19. Five TypeLibrary P/Invokes were declared but had no managed wrappers, leaving the lifecycle and named-store mutation surface incomplete vs Python.

Wrapper P/Invoke Python
Duplicate() BNDuplicateTypeLibrary duplicate (typelibrary.py:142)
Register() BNRegisterTypeLibrary register (typelibrary.py:244)
RemoveNamedObject(QualifiedName) BNRemoveTypeLibraryNamedObject remove_named_object (typelibrary.py:383)
RemoveNamedType(QualifiedName) BNRemoveTypeLibraryNamedType remove_named_type (typelibrary.py:416)
static LookupByGuid(Architecture, string) BNLookupTypeLibraryByGuid lookup_by_guid

Notes

  • Register is a void method (Python oddly exposes it as a @property returning None; C# can't have a void-returning property, so a method is the correct translation).
  • The two Remove P/Invokes take BNQualifiedName* (an IntPtr), unlike Add* which take it by reference (in BNQualifiedName) — an inconsistency from auto-generation. The wrappers pin the converted struct via ScopedAllocator.AllocStruct rather than editing the generated P/Invoke files.

E2E tests (harness repo)

TypeLibraryMissingWrapperTests (4 tests, all 5 wrappers covered):

  • DuplicateReturnsIndependentInstanceWithFreshGuid — distinct handle, same name, fresh GUID.
  • RegisterThenLookupByGuidFindsLibrary — round-trips Register + LookupByGuid.
  • AddThenRemoveNamedTypeRoundTrips / AddThenRemoveNamedObjectRoundTrips — add → GetNamed* non-null → remove → null.

Full harness regression 56/56.

Closes HIGH missing-capi gap #19. The binding declared the five
P/Invokes (BNDuplicateTypeLibrary, BNRegisterTypeLibrary,
BNRemoveTypeLibraryNamedObject, BNRemoveTypeLibraryNamedType,
BNLookupTypeLibraryByGuid) but exposed no managed wrappers, so the
TypeLibrary lifecycle and named-store mutation surface was incomplete
vs Python (typelibrary.py duplicate/register/remove_named_object/
remove_named_type/lookup_by_guid).

Add:
- TypeLibrary.Duplicate() (fresh-GUID copy),
- TypeLibrary.Register() (method form of Python's register property),
- TypeLibrary.RemoveNamedObject(QualifiedName) / RemoveNamedType,
  pinning the BNQualifiedName via ScopedAllocator.AllocStruct because
  the Remove P/Invokes take BNQualifiedName* (a pointer) whereas Add
  takes it by reference,
- static TypeLibrary.LookupByGuid(Architecture, string).
@tinysec tinysec merged commit e017b2d into master Jul 8, 2026
1 check passed
@tinysec tinysec deleted the feat/type-library-missing-wrappers branch July 8, 2026 16:47
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