QueryInterface for IUnknown fails for instance of IDXGIOutputDuplication

  • Thread starter Thread starter crazyjncsu
  • Start date Start date
C

crazyjncsu

Guest
In the Windows 10 Anniversary Update (final bits), querying for IUnknown for a returned instance of IDXGIOutputDuplication seems to cause an access violation.

It is necessary to query for IUnknown to use this stuff with .NET, as the RCW (runtime callable wrapper) makes this call to determine the identity of the underlying object.

This can be reproduced in your sample available here:

Windows DXGI desktop duplication sample in C++ for Visual Studio 2012

In file DuplicationManager.cpp, add these two lines after the call to DuplicateOutput succeeds:

void* unknown;
DWORD result = m_DeskDupl->QueryInterface(IID_IUnknown, &unknown);

Context:

hr = DxgiOutput1->DuplicateOutput(m_Device, &m_DeskDupl);
DxgiOutput1->Release();
DxgiOutput1 = nullptr;
if (FAILED(hr))
{
if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE)
{
MessageBoxW(nullptr, L"There is already the maximum number of applications using the Desktop Duplication API running, please close one of those applications and then try again.", L"Error", MB_OK);
return DUPL_RETURN_ERROR_UNEXPECTED;
}
return ProcessFailure(m_Device, L"Failed to get duplicate output in DUPLICATIONMANAGER", L"Error", hr, CreateDuplicationExpectedErrors);
}

void* unknown;
DWORD result = m_DeskDupl->QueryInterface(IID_IUnknown, &unknown);

return DUPL_RETURN_SUCCESS;



Please advise!

Continue reading...
 
Back
Top