Windows 服务和 LSP DLL 之间的 IPC
我正在编写一个需要与 Windows 服务通信的 Winsock LSP(分层服务提供程序)DLL。
通信是使用内存映射文件和事件进行同步来完成的。如果应用程序没有作为服务运行,则一切正常,但如果它运行,则无法找到任何事件或文件映射(我在 OpenEvent 上收到 ERROR_FILE_NOT_FOUND 错误)。
我怀疑发生这种情况是因为当作为服务运行时,应用程序以系统用户身份运行,并且 LSP 由以本地用户身份运行的应用程序加载。
我认为这可以通过使用适当的 SECURITY_DESCRIPTOR 来解决,但我不知道应该将其设置为什么。
关于如何实现这项工作有什么想法吗?
谢谢,
I'm writing a Winsock LSP (Layered Service Provider) DLL that needs to communicate with a windows service.
The communication is done using memory mapped files and events for synchronization. Everything works fine if the application is not running as a service but if it does it cannot find any events or file mappings (I get ERROR_FILE_NOT_FOUND error on OpenEvent).
I suspect this happens because when running as a service, the application runs as SYSTEM user and LSP is loaded by applications that run as local user.
I think that this could be solved by using a proper SECURITY_DESCRIPTOR but I don't know what should it be set to.
Any ideas on how to make this work?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据操作系统的不同,这可能是会话问题。如果您再看一下 CreateEvent、CreateMemoryMapping 等的文档,您会注意到对象名称的 GLOBAL\ 前缀。此前缀(与 SESSION\x\ 前缀一起)定义对象的可见性范围。全局前缀在整个系统中可见,而名称中没有前缀的对象是特定会话的本地对象(如果省略 \SESSION 前缀则为当前会话)。会话出现在 Windows XP 的终端服务中,然后进入 Windows 2003 Server 及更高版本的操作系统中。
Depending on the OS, it might be a problem of sessions. If you take another look at documentation for CreateEvent, CreateMemoryMapping etc., you will notice GLOBAL\ prefix to object name. This prefix (among with SESSION\x\ prefix) define visibility scope of the object. GLOBAL prefixes are seen across the whole system, while objects without prefix in the name are local to specific (current if the \SESSION prefix is omitted) session. Sessions appeared in Terminal Services for Windows XP, then got themselves into the OS in Windows 2003 Server and later.