Session Isolation 0

Vista provides a new protection that prevents session 0, access to hardware, such as a video card, and the user is no longer logged in to session 0. I know this means that I can’t show the user the GUI, however it also means that I don’t can show it at all? As my code is set up right now, it would work harder to make it just a command line, however, if I can use my existing code and just programmatically manage the GUI, it will require much less code.

Is it possible?

The MSDN article says the following:

β€’ The service attempts to create a user interface (UI), such as a dialog box, in session 0. Because the user does not work in session 0, he or she never sees the user interface and therefore cannot provide the input that the service is looking for. The service stops functioning because it expects a user response that does not occur.

Which makes me think that it is possible to have an automated interface, but someone told me that you cannot use SendKeys with the service because it was disconnected in session 0.

EDIT: I do not need to show the user a graphical interface

0
source share
3 answers

You can show it; he just does not appear.

There is a small notification in the taskbar that there is a GUI window and a way to switch to it.

Anyway, there really is a TerminalServices API command to switch the active session, which you could call if you really need it to display.

+1
source

You can write a separate process that provides a user interface for your service process. The connection between your user interface and the service process can be done in various ways (Internet search for "inter process communication" or "IPC").

0
source

Your service may have a graphical interface. It is just that no one will ever see this. As the MSDN suggestion suggests, a service may display a dialog box. The MessageBox call will not end; he just never comes back - he won’t press any buttons.

I'm not sure what you mean by the desire to "manage the GUI." Do you really mean the pretense of sending input to controls, for example using SendInput ? I see no reason for this to be impossible; you will enter input into your own program queue, after all, and SendInput Vista-specific warnings do not say anything about this, but I think that you make things a lot more complicated than they should be. Repeat the idea to change your program to have no interface at all. (This is not the same as with the console program. Consoles are the user interface.)

Instead of simulating the mouse messages needed to press a button, for example, remove the intermediary and simply call directly the function that the button event would trigger.

0
source

Source: https://habr.com/ru/post/893302/


All Articles