GetSharedHandle() and Access Violation

Hello,

Just had a quick question about GetSharedHandle. As far as I can tell, it should be readable from another program using OpenSharedResource.

I’m using MonoGame as my platform and sending the rendered image to OpenVR via their Submit() function. This passes a Texture_t object with a handle as the parameter. I presume that this handle is just a DX11 shared handle that OpenVR will read and send to the HMD.

When the handle is set to anything other than zero, my p/invoke call to the OpenVR API is causing an access violation. I presume this is something to do with the shared memory between the MonoGame render target and OpenVR attempting to access it. I would have thought that calling an API with the shared resource as a pointer should work fine, but it’s not working for me at present.

Anyone have any ideas?

1 Like

Just to test, and share the code, this also causes an Access Violation.

IntPtr Store = renderTarget.GetSharedHandle();
Byte b = Marshal.ReadByte(Store);