问题描述
我有一个以管理员身份运行并充当命名管道服务器的 VB.NET 进程(非服务)。 DLL 被注入到某些进程中,并且 DLL 尝试连接到服务器进程。这一切都在同一台主机上。
我收到来自客户端的 ACCESS_DENIED (5) 错误,但仅在前两个客户端成功连接到服务器后才会发生。因此,至少有两个可以成功连接,然后所有其他尝试都被拒绝。
在我的测试 VM 中,至少创建了 4 个管道服务器实例,因此它似乎不是管道繁忙的简单情况(无论如何我假设返回 STATUS_PIPE_BUSY 而不是 ACCESS_DENIED)。我还添加了最宽松的管道安全性 (WorldSid/FullControl),但它仍然失败。
这是服务器管道代码:
tidyr::separate
在 DLLMain() 期间,使用以下调用进行连接尝试,这是连接失败并显示 ACCESS_DENIED 的地方。
Private Sub PipeSetup()
For x = 1 To Environment.ProcessorCount '4 in my test VM
t = New Thread(AddressOf PipeSetupProc)
t.IsBackground = True
t.Start()
Next
End Sub
Private Sub PipeSetupProc()
Dim s As NamedPipeServerStream = Nothing
Dim x As PipeSecurity = Nothing
While True
Try
'I've made the access rule the most permissive possible
'and I'm still getting ACCESS_DENIED from the client.
x = New PipeSecurity()
x.AddAccessRule(New PipeAccessRule(New SecurityIdentifier(WellKnownSidType.WorldSid,Nothing),PipeAccessRights.FullControl,Security.AccessControl.AccessControlType.Allow))
s = New NamedPipeServerStream(MY_PIPE_NAME,PipeDirection.InOut,NamedPipeServerStream.MaxAllowedServerInstances,PipeTransmissionMode.Message,PipeOptions.Asynchronous,4096,x)
s.WaitForConnection()
'Do stuff here...
s.Close()
s = Nothing
Catch ex As Exception
'logerror()
End Try
End While
End Sub
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)