我写使用WCF NetNamedPipeBinding一个进程间的交际。
I am writing a inter-process comunication using WCF NetNamedPipeBinding.
我的目标是让服务在net.pipe://本地主机/服务的运行,所以我跑了简单的主机:
My goal is to have service running at "net.pipe://localhost/service", so I running the simplest host:
host = new ServiceHost(contract, new Uri[] { "net.pipe://localhost" });
host.AddServiceEndpoint(typeof (IContract),
new NetNamedPipeBinding(), "service");
host.Open();
据http://blogs.msdn.com/b/rodneyviana/archive/2011/03/22/named-pipes-in-wcf-are-named-but-not-by-you-and-how-to-find-the-actual-windows-object-name.aspx 这个名字是隐藏的系统生成的GUID后面。
According to http://blogs.msdn.com/b/rodneyviana/archive/2011/03/22/named-pipes-in-wcf-are-named-but-not-by-you-and-how-to-find-the-actual-windows-object-name.aspx the name is hidden behind system-generated guid.
在这里,问题来了。
有任何可能的方式来获得由系统(GUID)我的程序中生成的名字,这样我就可以得到\设备\ NamedPipe \ GUID的路径,像在procexp,所以这将是更容易嗅出它? (除单独的进程中运行SYS内部可执行文件并分析它的输出?)
Is there any possible way to get the name generated by system (guid) inside my program, so I could get path like "\Device\NamedPipe\GUID", like in the procexp, so it will be easier to sniff it? (Except running sys internals executables in separate process and parsing its output?)
当你链接到显示的文章,WCF存储在内存映射文件的命名管道名称。要访问它,你需要做到以下几点:
As the article you link to shows, WCF stores the named pipe name in a memory mapped file. To access it, you need to do the following:
端点:net.pipe://本地主机/ TradeService /服务1 标准化端点:net.pipe:// + / TRADESERVICE /服务1 / 在基地64重新presentation:bmV0LnBpcGU6Ly8rL1RSQURFU0VSVklDRS9TRVJWSUNFMS8 = 在最后的内存映射文件:net.pipe:EbmV0LnBpcGU6Ly8rL1RSQURFU0VSVklDRS9TRVJWSUNFMS8 = Endpoint: net.pipe://localhost/TradeService/Service1 Normalized Endpoint: net.pipe://+/TRADESERVICE/SERVICE1/ Base 64 representation: bmV0LnBpcGU6Ly8rL1RSQURFU0VSVklDRS9TRVJWSUNFMS8= Final memory mapped file: net.pipe:EbmV0LnBpcGU6Ly8rL1RSQURFU0VSVklDRS9TRVJWSUNFMS8=现在你把最后的MMF的名字,并打开它。下面是使用货币市场基金MSDN上的一篇文章:的https:/ /msdn.microsoft.com/en-us/library/dd267590(v=vs.110).aspx
Now you take the final MMF name and open it. Here's an article on using MMFs on MSDN: https://msdn.microsoft.com/en-us/library/dd267590(v=vs.110).aspx
// Open the MMF.
using (var mmf = MemoryMappedFile.OpenExisting(namedPipeMMFName))
{
// Create an accessor for 16 bytes (Size of GUID) starting at
// offset 5 (as the article states)
using (var accessor = mmf.CreateViewAccessor(5, 16))
{
Guid pipeGuid;
accessor.Read<Guid>(0, out pipeGuid);
Console.WriteLine("This should be the pipe name: " + pipeGuid);
}
}