2

https://msdn.microsoft.com/en-us/library/windows/desktop/bb174562(v=vs.85).aspx

According to the documentation of IDXGIResource::GetSharedHandle, I should be able to "marshal this handle to another process to share a resource with a device in another process".

But it's not clear how to pass this handle. Can I just pass the value of this handle to another process? Or do I need some specific method?

Thanks!

sean
  • 468
  • 5
  • 10

2 Answers2

3

Microsoft's documentation now suggests using CreateSharedHandle() instead of GetSharedHandle() and creating the texture with D3D11_RESOURCE_MISC_SHARED_NTHANDLE. I had to call DuplicateHandle() in order to pass the created HANDLE to another process to be opened with OpenSharedResource1().

  • CreateSharedHandle() requires IDXGIResource1 – thewhiteambit Aug 07 '21 at 15:21
  • I'm having some difficulties with this. I'm curious why you needed to use `DuplicateHandle()`, when others say they can use the handle directly in the other process? – sleep Mar 24 '22 at 03:25
  • 1
    @JarrodSmith, CreateSharedHandle returns a "NT" handle which is local to the process, but can be passed to a different process via DuplicateHandle. On the other hand, GetSharedHandle returns a completely different, OS-global handle that can be directly (as a numerical value) used in all processes. To confuse matters, they both use the same C type for the handle. – Andrzej Szombierski Oct 14 '22 at 17:15
2

Yes, you can pass this handle directly to another process and access it via OpenSharedResource function.

VuVirt
  • 1,887
  • 11
  • 13