Hi @Okan Murat SÖNMEZ ,
Your test results are consistent with the documented DXGI Desktop Duplication behavior:
-
DXGI_ERROR_ACCESS_LOSTcan occur on a desktop switch, after which the duplication interface must be recreated, as documented for IDXGIOutputDuplication::AcquireNextFrame. - IDXGIOutput1::DuplicateOutput can then return
E_ACCESSDENIEDif the process cannot access the current desktop image. The documentation specifically states that only an application running asLOCAL_SYSTEMcan access the secure desktop.
However, a LocalSystem service in Session 0 is not the same as having a suitable capture process on the interactive/secure desktop. Windows isolates Session 0 from interactive user sessions. Microsoft's service guidance recommends using a separate process in the interactive user's context, but WTSQueryUserToken only provides the token of a logged-on user.
For your two scenarios:
- After Win+L: Desktop Duplication is supported for desktop capture/remote-access scenarios, but the switch to the secure desktop can invalidate the existing duplication interface. Capturing the secure desktop then has the additional
LOCAL_SYSTEMaccess requirement documented byDuplicateOutput. - After restart, before sign-in: there is no logged-on user token for the usual
WTSQueryUserToken+CreateProcessAsUserarchitecture. I could not find a publicly documented Win32 API or Microsoft sample that provides a general third-party service with the requiredpre-logon/secure-desktop process contextfor DXGI capture.
So, while Microsoft documents Desktop Duplication as an API for ISV desktop collaboration and remote-access applications, the public documentation does not describe an end-to-end supported mechanism for a Session 0 third-party service to capture the physical secure sign-in desktop in these scenarios.
I would avoid undocumented Winlogon/token/desktop manipulation. If secure sign-in capture is a product requirement, Microsoft Support for Business would be the appropriate channel to confirm whether a specific architecture beyond the publicly documented APIs is supported.
I hope this helps clarifying your requirements and answering your questions. If you find my response helpful, I would greatly appreciate it if you could follow the guide here so others experiencing similar behavior can benefit from it as well.