Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screenshot secure desktop

Tags:

c#

screenshot

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

Edit:

  1. Exe Installed in Secured location
  2. Exe is digitally signed
like image 954
Azar Shaikh Avatar asked Sep 29 '18 06:09

Azar Shaikh


People also ask

How do you take a screenshot of a secure browser?

Ctrl-Shift-I, Ctrl-Shift-P, "screenshot." Say it, sing it, commit it to memory — and forever change the way you capture screenshots from your Chrome desktop browser.

How do I take a screenshot of my desktop?

Most Android devices should be able to take screen grabs by holding down the power and volume down buttons, though holding the power and home buttons (if your device has a physical button) may also work. Several Android devices have a screenshot button in the pull-down shade.

Why can't I take a screenshot on my desktop?

This key is the Function (Fn) key, usually located near your Windows key. Try pressing the Fn and Print Screen keys at the same time to see if a screenshot is successfully taken with this shortcut. You may also try the Fn + Windows key + Print Screen combination.


Video Answer


1 Answers

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

  • it must run under the SYSTEM account, not the logged-on user account
  • it must run on the Winlogon desktop, not on the user desktop
  • it should run as a service

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"

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

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.

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.

like image 131
dymanoid Avatar answered Oct 02 '22 12:10

dymanoid