如何将 Windows 服务连接到控制台会话

发布于 2024-10-06 03:05:32 字数 103 浏览 0 评论 0原文

我一直在开发一个作为 Windows 服务运行的远程桌面应用程序,我想知道如何将该应用程序连接到特定会话,并允许它以位图形式检索用户的桌面,设置光标位置,发送鼠标单击以及控制台会话的键盘输入。

I've been developing a remote desktop application which runs as a Windows service, and I was wondering how I could connect the application to a specific session, and allow it to retrieve the user's desktop as a bitmap, set the cursor position, send mouse clicks, and keyboard input to the console session.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

能否归途做我良人 2024-10-13 03:05:32

您需要使用 SetThreadDesktop() 将服务中的线程上下文更改为用户桌面。

  • SetThreadDesktop() 将桌面句柄作为第一个参数;要获取该句柄,请使用 EnumDesktops()< /代码>
  • EnumDesktops() 将窗口站的句柄作为第一个参数;要获取该句柄,请使用 EnumWindowStations( )

要了解 Window Station 和桌面的情况,请尝试阅读 此概述来自 MSDN。

最后,请谨慎使用此技术。与用户桌面交互的较高权限进程(即服务)是粉碎攻击的基础。

You need to 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.

Finally, be cautious with this technique. Higher-privileged processes (i.e., services) interacting with the user's desktop are the basis for shatter attacks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文