The SECURITY_ATTRIBUTES struct and CreateNamedPipe()

后端 未结 3 2060
故里飘歌
故里飘歌 2021-02-10 17:47

My scenario is the following: the process that creates the named pipe object with CreateNamedPipe() has administrator privileges, but the client process \"connectin

3条回答
  •  滥情空心
    2021-02-10 18:08

    Here's your problem:

    ea[0].grfAccessPermissions = STANDARD_RIGHTS_ALL;
    

    STANDARD_RIGHTS_ALL is not all rights, only all standard rights, i.e., delete, read control, synchronize, write DAC, and write owner. In particular it does not grant FILE_READ_DATA or FILE_WRITE_DATA, which a client needs in order to read and/or write data to the pipe.

    I'd recommend

    ea[0].grfAccessPermissions = GENERIC_READ | FILE_WRITE_DATA;
    

    and have the client request the same access rights when opening the pipe. (Obviously, you can leave out the FILE_WRITE_DATA right if this is an outbound pipe, although in that case the default permissions should be OK.)

提交回复
热议问题