屏幕截图安全桌面 [英] Screenshot secure desktop

查看:97
本文介绍了屏幕截图安全桌面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理屏幕共享项目.我正在使用以下功能捕获桌面屏幕.它工作正常.但是每当 安全桌面提示海拔.它返回黑色/空图像.

I am working with screen sharing project.I am capturing desktop screen using below function.it works fine. But whenever secure desktop prompting for elevation.it returns black/empty image.

但是当我 关闭安全桌面来自本地安全策略.它工作正常.

But when i turn off secured desktop from local security policy.It works fine.

有没有办法在不禁用本地安全策略的情况下捕获安全桌面.

Is there any way to capture secure desktop without disabling Local Security Policy.

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;
}

编辑:

  1. 安装在安全位置的 Exe
  2. Exe 已经过数字签名

推荐答案

为了获得 Secure Desktop 的屏幕内容,您的应用程序需要满足一些特殊条件:

In order to get the screen contents of the Secure Desktop, your application needs to fulfill some special criteria:

  • 它必须在 SYSTEM 帐户下运行,而不是在登录的用户帐户下运行
  • 它必须在 Winlogon 桌面上运行,而不是在用户桌面上运行
  • 它应该作为服务运行

要测试它,您可以例如使用 SysInternals PsExec 工具 在该模式下运行您的应用程序:

To test it, you could e.g. use the SysInternals PsExec tool to run your application in that mode:

PsExec /h /x /d /s "path_to\your_application.exe"

/x/s 开关很重要:它们在 SYSTEM 帐户下和 Winlogon 桌面上运行进程.

The /x and /s switches are important: they run the process under the SYSTEM account and on the Winlogon desktop.

如果您想避免使用第三方工具,您需要创建自己的 Windows 服务来执行安全桌面的屏幕截图.

If you want to avoid using third-party tools, you need to create your own Windows service which will perform the screen captures of the Secure Desktop.

没有可用的PsExec 源代码,但你可以查看PAExec 工具的源代码 - 它是一个开源替代品.

There is no source code of PsExec available, but you can look at the PAExec tool's source code - it's an open source alternative.

这篇关于屏幕截图安全桌面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆