会话 0 隔离

发布于 2024-07-12 10:00:44 字数 468 浏览 13 评论 0原文

Vista 推出了新的安全措施,阻止会话 0 访问视频卡等硬件,并且用户不再登录会话 0。我知道这意味着我无法向用户显示 GUI,但这是否也意味着我不能到底显示一个吗? 按照我现在的代码设置方式,仅使用命令行会需要更多工作,但是如果我可以使用现有代码并仅以编程方式管理 GUI,则需要的代码会少得多。

这可能吗?

MSDN 的文章是这样说的:

• 服务尝试在会话 0 中创建用户界面 (UI),例如对话框。由于用户不在会话 0 中运行,因此他或她永远看不到 UI,因此无法提供以下输入:该服务正在寻找。 该服务似乎停止运行,因为它正在等待未发生的用户响应。

这让我认为有可能拥有一个自动化的 UI,但有人告诉我你不能将 SendKeys 与服务一起使用,因为它在会话 0 中被禁用。

编辑:我实际上不需要向用户显示 GUI

Vista puts out a new security preventing Session 0 from accessing hardware like the video card, and the user no longer logs into session 0. I know this means that I cannot show the user a GUI, however, does that also mean I can't show one at all? The way my code is set up right now, it would be more work to make it command line only, however if I can use my existing code and just programmatically manage the GUI it would take a lot less code.

Is this possible?

The article from MSDN says this:

• A service attempts to create a user interface (UI), such as a dialog box, in Session 0. Because the user is not running in Session 0, he or she never sees the UI and therefore cannot provide the input that the service is looking for. The service appears to stop functioning because it is waiting for a user response that does not occur.

Which makes me think it is possible to have an automated UI, but someone told me that you couldn't use SendKeys with a service because it was disabled in Session 0.

EDIT: I don't actually need to show the user the GUI

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

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

发布评论

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

评论(3

烟花肆意 2024-07-19 10:00:44

你可以展示一个; 它只是不显示。

任务栏中有一个关于 GUI 窗口和切换到它的方法的小通知。

不管怎样,实际上有一个 TerminalServices API 命令来切换活动会话,如果您确实需要它显示,您可以调用它。

You can show one; it just doesn't show up.

There is a little notification in the taskbar about there being a GUI window and a way to switch to it.

Anyway, there actually is a TerminalServices API command to switch active session that you could call if you really needed it to show up.

始于初秋 2024-07-19 10:00:44

您可以编写一个单独的进程来为您的服务进程提供 UI。 UI 和服务进程之间的通信可以通过多种方式完成(在网络上搜索“进程间通信”或“IPC”)。

You can write a separate process which provides the UI for your service process. The communication between your UI and service process can be done in various ways (search the web for "inter process communication" or "IPC").

孤千羽 2024-07-19 10:00:44

您的服务可以有一个 GUI。 只是没有人会看到它。 正如 MSDN 引用所暗示的那样,服务可以显示一个对话框。 对 MessageBox 的调用不会失败; 它只是永远不会回来——不会有人按下它的按钮。

我不确定你所说的“管理 GUI”是什么意思。 您实际上的意思是假装将输入发送到控件,就像 SendInput 一样? 我认为这没有任何理由是不可能的; 毕竟,您会将输入注入到自己的程序队列中,并且 SendInput 的 Vista 特定警告 对此没有任何说明。 但我认为你会让事情变得比他们需要的更加复杂。 重新审视将程序更改为完全没有 UI 的想法。 (这与控制台程序不同。控制台是 UI。)

例如,不要模拟单击按钮所需的鼠标消息,而是消除中间人并直接调用按钮单击事件将具有的函数叫。

Your service can have a GUI. It's simply that no human will ever see it. As the MSDN quote suggests, a service can display a dialog box. The call to MessageBox won't fail; it just won't ever return — there won't be anyone to press its buttons.

I'm not sure what you mean by wanting to "manage the GUI." Do you actually mean pretending to send input to the controls, as with SendInput? I see no reason that it wouldn't be possible; you'd be injecting input into your own program's queue, after all, and SendInput's Vista-specific warnings don't say anything about that. But I think you'd be making things much more complicated than they need to be. Revisit the idea to alter your program to have no UI at all. (That's not the same as having a console program. Consoles are UI.)

Instead of simulating the mouse messages necessary to click a button, for instance, eliminate the middle-man and simply call directly the function that the button-click event would have called.

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