0

Tried https://stackoverflow.com/a/30138664/533237 and able to capture screen.

But I want to capture screen from an application running in session 0 or another user.Introduced a 10 sec sleep before capturing and switched to another user. Also tried PsExec.exe -h -s E:\sc.exe. Both throws error

C:\Users\unity\Documents\Visual Studio 2015\Projects\ConsoleApplication2\Debug>sc.exe
FAILURE 0x8876086C (-2005530516)
    line: 60 file: 'c:\users\unity\documents\visual studio 2015\projects\consoleapplication2\consoleapplication2\consoleapplication2.cpp'
    expr: 'd3d->GetAdapterDisplayMode(adapter, &mode)'

C:\Users\unity\Documents\Visual Studio 2015\Projects\ConsoleApplication2\Debug>PsExec.exe -h -s  E:\sc.exe -w E:\
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com


FAILURE 0x8876086C (-2005530516)
    line: 60 file: 'c:\users\unity\documents\visual studio 2015\projects\consoleapplication2\consoleapplication2\consoleapplication2.cpp'
    expr: 'd3d->GetAdapterDisplayMode(adapter, &mode)'

Commented out GetAdapterDisplayMode and hardcoded height and width but CreateDevice failed

FAILURE 0x8876086A (-2005530518)
    line: 76 file: 'c:\users\unity\documents\visual studio 2015\projects\consoleapplication2\consoleapplication2\consoleapplication2.cpp'
    expr: 'd3d->CreateDevice(adapter, D3DDEVTYPE_HAL, NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &parameters, &device)'

Edited: Idea is to have a single app running in background and capture anything getting displayed irrespective of the user logged in or even if no one is logged in (lock/login screen)

Community
  • 1
  • 1
yodhevauhe
  • 765
  • 3
  • 11
  • 33

1 Answers1

1

There are two levels of problems with this.

On one level, while a lot of GDI will work, session 0 is not linked to a functional display device, certainly not one that is capable of D3D.

On another level, while things like the DWM have been introduced, the Windows API has always presented a display model where invisible screen pixels simply don't exist. The entire windows display model is built around getting windows to co-operative paint to a shared display surface, and any parts of a window that are uncovered are repainted on demand by the desktop composition system.

This means, in a very fundamental way, you cannot screen capture anything from session 0 as, in order to do so, session 0 would have to be attached to the active display device.

Harry Johnston
  • 35,639
  • 6
  • 68
  • 158
Chris Becke
  • 750
  • 4
  • 10
  • 1
    This is not entirely correct - as of Win8 / Server 2012, you can use [D3D in session 0](https://msdn.microsoft.com/en-us/library/windows/desktop/hh404562(v=vs.85).aspx#use_direct3d_in_session_0_processes), including display adapter related APIs, however *output* and *window* related APIs are still invalid, and therefore there is nothing to "capture" there. – MooseBoys Oct 30 '15 at 20:43