如何使WCF命名管道地址等于WinApi地址?

发布于 2024-09-25 10:50:39 字数 189 浏览 0 评论 0 原文

我注意到 WCF 的命名管道地址

net.pipe://localhost/mynamedpipe

和 Windows API

\\.\pipe\mynamedpipe

不会发生冲突。这是为什么?我怎样才能让它们指向同一个管道?

I noticed that WCF's named pipe address

net.pipe://localhost/mynamedpipe

and Windows API's

\\.\pipe\mynamedpipe

don't collide. Why is that? How can I make them point to the same pipe?

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

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

发布评论

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

评论(3

心在旅行 2024-10-02 10:50:39

没有记录的方法可以做到这一点。经过几次测试,我得出以下结论:

如果您有一个 WCF 服务器和一个 Win32 C++ 客户端,最后一个客户端会将第一个地址视为 UUID,格式如下:

12345678-1234-1234-1234-123456789abc

和这个 UUID 看起来是随机的,因为每次服务器启动时它都会针对相同的 WCF 地址进行更改。

我不知道具有 GUID 格式地址的 Win32 C++ 命名管道服务器是否对 WCF 客户端可见,但我确信如果是这样,服务器将必须实现 WCF 使用的记录不完善的协议。

此类协议的文档作为对 我之前关于这个主题的问题。

编辑进一步的研究表明管道地址存储在 FileMapping 中。该条目地址又是 NetNamedPipe 地址规范化版本的 Base64 编码哈希值。

There is no documented way of doing that. After a few tests I came to the following conclusions:

If you have a WCF server and a Win32 C++ client, the last one will see the first one address as a UUID in the following format:

12345678-1234-1234-1234-123456789abc

And this UUID seems random, since it changes for the same WCF address every time the server is started.

I don't know if a Win32 C++ named pipe server with a GUID format address will be visible from a WCF client, but I'm sure that if it does, the server will have to implement the poorly documented protocol used by WCF.

The documentation for such protocol is provided as an answer to my previous question on this subject.

EDIT Further research revealed that the pipe address is stored in the FileMapping. This entry address in its turn is a base64 encoded hash of a normalized version of the NetNamedPipe address.

生生漫 2024-10-02 10:50:39

根据 这来自斯蒂芬·克利里。考虑到 WCF 和 Win32 的不相交管道命名空间的上下文,这是有道理的。

所有以“Net”开头的 WCF 绑定都是
.NET 特定的。他们使用某种协议
(据我所知,这是无证的)将来可能会改变。

如果您只需要知道管道名称,您可以使用 来自 Sysinternals 的管道列表。我想象在 WCF 的覆盖下潜伏着一个本地命名管道......

Linking native and WCF pipes is not possible according to this from Stephen Cleary. This makes sense, given the context of disjoint pipe namespaces for WCF and Win32.

All the WCF bindings that start with "Net" are
.NET-specific. They use a certain protocol
(which is undocumented AFAIK) that may change in the future.

If you just need to know the pipename, you may be able to work this out (by elimination?) using pipelist from Sysinternals. I imagine that under the WCF covers there lurks a native named pipe...

过去的过去 2024-10-02 10:50:39

请参阅此处< /a> 有关我在尝试做类似事情时发现的一些细节。

您无法控制管道的 WCF 端(当然,不能不丢弃 netNamedPipeBinding 并创建您自己的命名管道传输)...但是如果您准备好工作,则可以从本机代码找到并打开 WCF 管道在它。

See here for some detail I discovered on this while trying to do something similar.

You can't control the WCF end of the pipe (well, not without throwing away netNamedPipeBinding and creating your own named pipe transport instead)... but you can locate and open the WCF pipe from native code if you're prepared to work at it.

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