屏幕截图安全桌面
Screenshot secure desktop
我正在使用屏幕共享 project.I 我正在使用以下 function.it 捕获桌面屏幕,效果很好。但是每当 secure desktop prompting for elevation.it returns black/empty image.
但是当我 turn off secured desktop 来自本地安全 policy.It 时工作正常。
有什么方法可以在不禁用本地安全策略的情况下捕获安全桌面。
static Bitmap CaptureDesktop()
{
SIZE size;
Bitmap printscreen = null;
size.cx = Win32Stuff.GetSystemMetrics
(Win32Stuff.SM_CXSCREEN);
size.cy = Win32Stuff.GetSystemMetrics
(Win32Stuff.SM_CYSCREEN);
int width = size.cx; int height = size.cy;
IntPtr hWnd = Win32Stuff.GetDesktopWindow();
IntPtr hDC = Win32Stuff.GetDC(hWnd);
if (hDC != IntPtr.Zero)
{
IntPtr hMemDC = GDIStuff.CreateCompatibleDC(hDC);
if (hMemDC != IntPtr.Zero)
{
IntPtr m_HBitmap = GDIStuff.CreateCompatibleBitmap(hDC, width, height);
if (m_HBitmap != IntPtr.Zero)
{
IntPtr hOld = (IntPtr)GDIStuff.SelectObject(hMemDC, m_HBitmap);
GDIStuff.BitBlt(hMemDC, 0, 0, width, height, hDC, 0, 0, GDIStuff.SRCCOPY);
GDIStuff.SelectObject(hMemDC, hOld);
GDIStuff.DeleteDC(hMemDC);
printscreen = System.Drawing.Image.FromHbitmap(m_HBitmap);
GDIStuff.DeleteObject(m_HBitmap);
}
}
}
Win32Stuff.ReleaseDC(hWnd, hDC);
return printscreen;
}
编辑:
- Exe 安装在安全位置
- Exe 已进行数字签名
为了获取安全桌面的屏幕内容,您的应用程序需要满足一些特殊条件:
- 它必须运行在SYSTEM账户下,而不是登录用户账户
- 它必须 运行 在 Winlogon 桌面上,而不是在用户桌面上
- 它应该运行作为一项服务
要测试它,您可以例如在该模式下使用 SysInternals PsExec tool 到 运行 您的应用程序:
PsExec /h /x /d /s "path_to\your_application.exe"
/x
和 /s
开关很重要:它们 运行 在 SYSTEM 帐户下和 Winlogon 桌面上的进程。
如果您想避免使用第三方工具,您需要创建自己的 Windows 服务来执行 Secure Desktop 的屏幕捕获。
没有可用的 PsExec
源代码,但您可以查看 PAExec
工具的 source code - 它是一个开源替代品。
我正在使用屏幕共享 project.I 我正在使用以下 function.it 捕获桌面屏幕,效果很好。但是每当 secure desktop prompting for elevation.it returns black/empty image.
但是当我 turn off secured desktop 来自本地安全 policy.It 时工作正常。
有什么方法可以在不禁用本地安全策略的情况下捕获安全桌面。
static Bitmap CaptureDesktop()
{
SIZE size;
Bitmap printscreen = null;
size.cx = Win32Stuff.GetSystemMetrics
(Win32Stuff.SM_CXSCREEN);
size.cy = Win32Stuff.GetSystemMetrics
(Win32Stuff.SM_CYSCREEN);
int width = size.cx; int height = size.cy;
IntPtr hWnd = Win32Stuff.GetDesktopWindow();
IntPtr hDC = Win32Stuff.GetDC(hWnd);
if (hDC != IntPtr.Zero)
{
IntPtr hMemDC = GDIStuff.CreateCompatibleDC(hDC);
if (hMemDC != IntPtr.Zero)
{
IntPtr m_HBitmap = GDIStuff.CreateCompatibleBitmap(hDC, width, height);
if (m_HBitmap != IntPtr.Zero)
{
IntPtr hOld = (IntPtr)GDIStuff.SelectObject(hMemDC, m_HBitmap);
GDIStuff.BitBlt(hMemDC, 0, 0, width, height, hDC, 0, 0, GDIStuff.SRCCOPY);
GDIStuff.SelectObject(hMemDC, hOld);
GDIStuff.DeleteDC(hMemDC);
printscreen = System.Drawing.Image.FromHbitmap(m_HBitmap);
GDIStuff.DeleteObject(m_HBitmap);
}
}
}
Win32Stuff.ReleaseDC(hWnd, hDC);
return printscreen;
}
编辑:
- Exe 安装在安全位置
- Exe 已进行数字签名
为了获取安全桌面的屏幕内容,您的应用程序需要满足一些特殊条件:
- 它必须运行在SYSTEM账户下,而不是登录用户账户
- 它必须 运行 在 Winlogon 桌面上,而不是在用户桌面上
- 它应该运行作为一项服务
要测试它,您可以例如在该模式下使用 SysInternals PsExec tool 到 运行 您的应用程序:
PsExec /h /x /d /s "path_to\your_application.exe"
/x
和 /s
开关很重要:它们 运行 在 SYSTEM 帐户下和 Winlogon 桌面上的进程。
如果您想避免使用第三方工具,您需要创建自己的 Windows 服务来执行 Secure Desktop 的屏幕捕获。
没有可用的 PsExec
源代码,但您可以查看 PAExec
工具的 source code - 它是一个开源替代品。