Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make MIDL3 arrays with "weak" ownership? #770

Closed
forderud opened this issue Jan 7, 2022 · 5 comments
Closed

How to make MIDL3 arrays with "weak" ownership? #770

forderud opened this issue Jan 7, 2022 · 5 comments

Comments

@forderud
Copy link

forderud commented Jan 7, 2022

I'm working on a code base that is using "classical" COM interfaces with SAFEARRAY for exchanging image data efficiently both in-proc and across process boundaries, regardless if the client is C++, C# or Python (using comtypes). This is achieved by tagging the SAFEARRAY object with FADF_AUTO to make the ownership weak and implementing IMarshal for custom marshaling, where the image data buffer is stored in a shared memory segment with lifetime controlled by the ref-count of the parent object providing the image data.

One nice property of this is that the client only sees a "regular" SAFEARRAY buffer. It don't need to know that it's using shared memory behind the scenes for zero-copy data exchange across process boundaries. This is just an implementation detail.

I've recently started to "modernize" the interfaces to WinRT/MIDL3. I then want to achieve something similar with UInt8[] or a similar array type. However, I've so far been unable to discover any flags for making ownership "weak" when creating a winrt::com_array<uint8_t> in the C++ server implementation.

Would it be possible to get some guidance on how to create a MIDL3 interface with arrays with "weak" ownership that is out-of-proc compatible?

@forderud forderud changed the title How to make MIDL3 arrays have "weak" ownership? How to make MIDL3 arrays with "weak" ownership? Jan 7, 2022
@JaiganeshKumaran
Copy link

Would it be possible to get some guidance on how to create a MIDL3 interface with arrays with "weak" ownership that is out-of-proc compatible?

There's no such feature. A MIDL 3 array simply represents a pair of size and data.

@forderud
Copy link
Author

forderud commented Jan 1, 2023

There's no such feature. A MIDL 3 array simply represents a pair of size and data.

Thanks for confirming my assumption. It then seems like I'm stuck with SAFEARRAY and "classical" COM for the time being.

@github-actions
Copy link

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@forderud
Copy link
Author

Is there somewhere where I can submit a MIDL3 enhancement request for supporting "SAFEARRAY" or similar memory-buffers that can optionally utilize externally managed buffers (like with FADF_AUTO)?

@kennykerr
Copy link
Contributor

MIDL3 is constrained by the WinRT type system so this is unlikely to happen, but you can raise the question here: https://docs.microsoft.com/en-us/answers/topics/windows-api.html

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

No branches or pull requests

3 participants