开发者

Is it possible to see system's user desktop? How to desktop of your user from another session?

开发者 https://www.devze.com 2023-03-26 06:49 出处:网络
I run Windows 7. I run windows service that runs a program with GUI. I cannot see the GUI of my program because it was started from another session开发者_JAVA技巧 by system or even my user.

I run Windows 7. I run windows service that runs a program with GUI. I cannot see the GUI of my program because it was started from another session开发者_JAVA技巧 by system or even my user.

Is there a way for me to see my program? Switch desktop to system user?


Use SetThreadDesktop() to change the thread's context in your service to the user's desktop.

  • SetThreadDesktop() takes a handle to the desktop as it's first parameter; to get that handle, use EnumDesktops().
  • EnumDesktops() takes a handle to the window station as it's first parameter; to get that handle, use EnumWindowStations()

To understand what's going on with Window Stations and Desktops, try reading this overview from from MSDN.

Be cautious with this technique. Higher-privileged processes (i.e., services) interacting with the user's desktop are the basis for shatter attacks. You need to write a separate application that runs in the user's context and communicates with your service via pipes or similar.

0

精彩评论

暂无评论...
验证码 换一张
取 消