I came to this place because I am looking for some help with system service and as vnc does (probably) similar thing as I am looking for I hope I might get some help or hints here. Basically from windows vista and up system services run in session0 and therefore cant see user's desktop and other windows. I myself are developing simple service that needs to run under SYSTEM and that has to list user's windows. The problem is that when I run it (program I wrote) as service it wont have access to user's windows anymore (see image). And when it creates screenshot it simply gets solid black image. Now what is interesting for me is that uvnc actually runs under SYSTEM and it does not even have type=interact set for it's service and it still works. I would like to know how vnc is able to see screen of currently logged in user when it runs under SYSTEM. How is it possible that vnc isn't trapped in that session 0 which is default for all system services.
I had to use following algorithm:
1)Get token of current process
3)Set token session