Repository navigation
Expand safe COM projections and lifecycle support - #144
Merged
Merged
Conversation
Provide non-consuming COM projectAs with registered safe descriptors, restricted in-process IMMDevice activation with native NULL parameters, and exact GetId ownership. Preserve the WinRT root and dynamic architecture; require complete COM regeneration with manifest v3. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
Mixed-language test coverageWorkflow status: ✅ Passed
|
This was referenced Sep 7, 2026
Preserve the five existing target IIDs, in-process context, native NULL parameters and owned result contract. Validate named evidence records and lower dynamic-length IID lists without changing generated bindings or coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
* Add metadata-driven native COM one-shot completion Generate bounded audio activation promises with validated WinMD contracts, libffi export/result plans, a native-only FTM signal sink, and owner-local result collection. Preserve synchronous JS callback thread restrictions. Cover publication, HRESULTs, ownership, teardown, bounds, and WinRT regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb * Add guarded COM borrowed-copy transactions for Audio, WIC and MF (#146) * Add guarded COM borrowed-copy transactions Add metadata-validated owned-copy plans for Audio, WIC BGRA8 and linear Media Foundation buffers. Observe real successful Audio initialization and GetService calls, retain canonical identity provenance across aliases, and finalize native borrows exactly once with thread and poison guards. Preserve WIC's existing complete surface, keep three copy-only facades out of complete-interface counts, require full regeneration, and add exact metadata evidence, native fixtures, live x64/i686 tests and regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb * Refactor COM borrowed copies into typed execution recipes Centralize reviewed ABI and lifecycle evidence in a shared contracts crate. Execute typed bindings, bounds, copies and finalizers through one plan-driven runtime while preserving public APIs and supported interfaces. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb * Guard managed COM arguments before native dispatch Retain shared apartment and lifecycle contexts across interface aliases and supported containers. Recheck receivers and inputs after native coercion, preserve deferred WinRT lifetime behavior, and reject poisoned buffer inputs before IMFSample can retain them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb * Project ambiguous COM overloads as explicit slot-named methods (#147) Preserve existing arity/shape dispatch for distinguishable groups. Emit stable AtSlot names for previously unsupported ordinary overloads without guessing ABI behavior, retain each validated method plan, reject alias collisions, and update exact coverage evidence. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
Share the isolated COM runtime declaration fixture between overload and sink tests. Keep strict TypeScript and negative assertions while removing the coverage-time dependency on bindings/js/dist. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
shisan (qiutongMS)
approved these changes
Sep 9, 2026
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.
Summary
Consolidates the four reviewed COM projection changes into one final PR, including the changes from #145, #146, and #147, which have been merged into this stack.
The goal is to expand safe, typed JavaScript COM usage while preserving dynwinrt's metadata-driven, purely dynamic architecture and existing WinRT behavior.
Included capabilities
Safe COM entry points
Public, non-consuming
projectAs(value, InterfaceClass)performs real QI and returns an independently owned result. BoundedIMMDevice.activate(InterfaceClass)uses exact activation contracts, in-process context, native NULL parameters, and owned results. The named, documented activation-target registry preserves the original five-target allowlist without expansion.IMMDevice.getId()has exact CoTaskMem ownership.Native completion to JavaScript Promise
A reusable native-only, one-shot completion mechanism initially supports the bounded
ActivateAudioInterfaceAsyncprojection. Completion signals the initiating owner thread; it neither executes JavaScript nor moves apartment-bound results on the callback thread. Start/result/activation HRESULTs, early or duplicate completion, NULL results, and teardown are handled separately.Guarded borrowed-buffer copies
Audio gains
writeFramesCopy,writeSilence, andreadPacketCopy; WIC gainsreadLockedBgra8Copy; linear MF gainsreadCopyandreplaceCopy.One shared reviewed contract registry and a typed, plan-driven executor control native bindings, extents, copies, commits, normal/abort cleanup, and result mapping. There is no per-family execution switch or compiled per-interface native adapter. Canonical-identity context sharing, observed Audio initialization/GetService provenance, owner-thread guards, exactly-once cleanup, and poisoning protect each transaction.
Common argument admission covers objects, aliases, and supported interface-bearing containers. Retained context survives original-wrapper release, and a final check after native coercion/QI rejects invalid receiver or argument state before dispatch. This closes the poisoned-buffer
IMFSample.addBuffer()input path without an API-specific exception.Explicit COM overload projection
Previously ambiguous ordinary methods receive stable
<camelName>AtSlot<absoluteSlot>entry points. Existing distinguishable overload dispatch, native slots, ABI signatures, and lifecycle contracts remain unchanged. Collisions and unsupported synthesized/dynamic groups still fail closed. This promotes the same 24 additional complete-safe interfaces.Compatibility and safety boundaries
The WinRT public model, generated WinRT APIs, and npm root API remain unchanged. Private lowering exposes only a generic fallible pre-dispatch hook; COM lifecycle policy stays in the COM binding layer. Unbound WinRT bookkeeping remains thread-safe until first COM use.
Unknown ABI or ownership contracts fail closed. Ordinary synchronous JavaScript COM callbacks retain their owner-thread restriction. This does not introduce general cross-apartment JavaScript scheduling, COM servers, public aggregation/custom-marshaling support, or full Automation callbacks.
Borrowed storage is exposed only as owned copies, with a 64 MiB operation cap. No native-backed JavaScript Buffer/ArrayBuffer or raw borrow address escapes. WIC copying is STA-only, READ-only BGRA8; general MF2D/plane/pitch access and exclusive event-driven Audio render remain unsupported. Writes are not promised atomic rollback.
Audio render/capture and linear MF are bounded copy-only facades, not complete native-interface projections, and remain excluded from the complete-safe census.
Regeneration requirement
Generated COM file-ownership manifests are now version 5, and borrowed-copy descriptors are version 2. Delete old generated COM output and fully regenerate all selected roots with matching runtime and codegen. Do not mix old and new wrappers or edit manifest versions manually. Unsafe support schema 12 is unchanged.
Current coverage and evidence
Against Microsoft.Windows.SDK.Win32Metadata 71.0.14-preview, the consolidated result is 5,721 / 7,929 complete-safe interface projections.
The exact-contract registry contains 532 registered and metadata-matched entries, with 431 consumed by complete-safe plans. These are dependency counts, not a claim that every entry independently adds an interface.
The constituent PRs retain detailed design and regression records covering native ownership/failure paths, x64/i686 ABI, generated JavaScript/TypeScript, stock WinRT/COM execution, and unchanged public API surfaces. Audio failure/capture scenarios use controlled fixtures rather than real hardware recording.