From d3836d4548a4e888ad74ab7ee8699486cc90399c Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 12 Apr 2020 13:35:40 +1000 Subject: [PATCH] [c-host] Enable secure desktop capture using SetThreadDesktop Closes #263 - Credit to https://github.com/DataBeaver for this gem! --- VERSION | 2 +- .../platform/Windows/capture/DXGI/src/dxgi.c | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c200b53b..fdcb6fa2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-166-g1222fd40b7+1 \ No newline at end of file +B1-167-gdbd7db7787+1 \ No newline at end of file diff --git a/c-host/platform/Windows/capture/DXGI/src/dxgi.c b/c-host/platform/Windows/capture/DXGI/src/dxgi.c index 897f80a2..2ac62271 100644 --- a/c-host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/c-host/platform/Windows/capture/DXGI/src/dxgi.c @@ -56,6 +56,7 @@ struct iface LARGE_INTEGER perfFreq; LARGE_INTEGER frameTime; bool stop; + HDESK desktop; IDXGIFactory1 * factory; IDXGIAdapter1 * adapter; IDXGIOutput * output; @@ -172,6 +173,27 @@ static bool dxgi_init() { assert(this); + this->desktop = OpenInputDesktop(0, FALSE, GENERIC_READ); + if (!this->desktop) + DEBUG_WINERROR("Failed to open the desktop", GetLastError()); + else + { + if (!SetThreadDesktop(this->desktop)) + { + DEBUG_WINERROR("Failed to set thread desktop", GetLastError()); + CloseDesktop(this->desktop); + this->desktop = NULL; + } + } + + if (!this->desktop) + { + DEBUG_INFO("The above error(s) will prevent LG from being able to capture the secure desktop (UAC dialogs)"); + DEBUG_INFO("This is not a failure, please do not report this as an issue."); + DEBUG_INFO("To fix this run LG using the PsExec SysInternals tool from Microsoft."); + DEBUG_INFO("https://docs.microsoft.com/en-us/sysinternals/downloads/psexec"); + } + // this is required for DXGI 1.5 support to function if (!dpiDone) {