打开没有Windows权限的管道

时间:2016-12-09 19:41:45

标签: c windows pipe privileges

是否可以从没有SeChangeNotifyPrivilege权限的进程中打开管道?

我使用CreateNamedPipe控制管道的创建,并希望在CreateFile的另一个进程中打开管道。我删除SeChangeNotifyPrivilege后立即收到访问被拒绝错误。是否可以以某种方式创建管道,以便其他进程不需要此权限?

编辑:示例

在流程A中创建管道:

hPipe = CreateNamedPipeW(
    name,                      // pipe name 
    PIPE_ACCESS_INBOUND,       // read/write access 
    PIPE_TYPE_MESSAGE |       // message type pipe 
    PIPE_READMODE_MESSAGE |   // message-read mode 
    PIPE_WAIT,                // blocking mode 
    PIPE_UNLIMITED_INSTANCES, // max. instances  
    buf_size,                  // output buffer size 
    buf_size,                  // input buffer size 
    0,                        // client time-out 
    &attr);                   // security attribute 

选择安全属性以允许访问所有人(NULL ACL)。

访问流程B中的管道:

HANDLE hPipe = CreateFileW(
    name,     // pipe name 
    GENERIC_WRITE,  // write access 
    0,              // no sharing 
    NULL,           // default security attributes
    OPEN_EXISTING,  // opens existing pipe 
    0,              // default attributes 
    NULL);          // no template file 

进程B具有禁用SeChangeNotifyPrivilege权限的受限访问令牌。 CreateFileW返回拒绝访问权限。启用权限时,打开管道可以正常工作。请注意,在我的应用程序中,由于要求,我无法将此权限赋予进程B.

0 个答案:

没有答案