[host] DXGI: fix Secure Desktop wait logic

Fixes #20
This commit is contained in:
Geoffrey McRae 2017-12-17 02:26:47 +11:00
parent 287b983d27
commit b77a34b8b6

View File

@ -346,32 +346,34 @@ GrabStatus DXGI::GrabFrame(FrameInfo & frame)
if (SUCCEEDED(status)) if (SUCCEEDED(status))
break; break;
HDESK desktop = NULL;
switch (status) switch (status)
{ {
case DXGI_ERROR_ACCESS_LOST: // desktop switch, mode change or switch DWM on or off // desktop switch, mode change, switch DWM on or off or Secure Desktop
return GRAB_STATUS_REINIT; case DXGI_ERROR_ACCESS_LOST:
// see if we can open the desktop, if so request a reinit
// if not the secure desktop is active so just wait for it
// instead of aborting out
desktop = OpenInputDesktop(0, TRUE, GENERIC_READ);
if (desktop)
{
// open suceeded, not on the secure desktop, return to reinit
CloseDesktop(desktop);
return GRAB_STATUS_REINIT;
}
// fall through
case WAIT_ABANDONED: // this can happen also during desktop switches, not documented by MS though // this can happen during desktop switches also, not documented by MS though
{ case WAIT_ABANDONED:
// see if we can open the desktop, if not the secure desktop do
// is active so just wait for it instead of aborting out
HDESK desktop = NULL;
while(!desktop)
{ {
desktop = OpenInputDesktop(0, TRUE, GENERIC_READ); desktop = OpenInputDesktop(0, TRUE, GENERIC_READ);
if (desktop) if (desktop)
break; break;
Sleep(100); Sleep(100);
} } while (!desktop);
CloseDesktop(desktop); CloseDesktop(desktop);
return GRAB_STATUS_REINIT;
if (!ReInitialize())
{
DEBUG_ERROR("Failed to ReInitialize after lost access to desktop");
return GRAB_STATUS_ERROR;
}
continue;
}
default: default:
// unknown failure // unknown failure