-1

ネイティブ アプリケーションとマネージド アプリケーションの間で通信しようとしています。NamedPipe を使用しています。私は最初にC ++でnamedpipeを作成して開いてみましたが、セキュリティのエラーが発生しています

SECURITY_ATTRIBUTES sa;
sa.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR)malloc(SECURITY_DESCRIPTOR_MIN_LENGTH);
if (!InitializeSecurityDescriptor(sa.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION))
{
    DWORD er = ::GetLastError();
}
if (!SetSecurityDescriptorDacl(sa.lpSecurityDescriptor, TRUE, (PACL)0, FALSE))
{
    DWORD er = ::GetLastError();
}
sa.nLength = sizeof sa;
sa.bInheritHandle = TRUE;
// To know the maximal size of the received data for reading from the      // pipe buffer

union maxSize
{
    UINT   _1;
};

_pipe = ::CreateNamedPipe(pipeName.c_str(), PIPE_ACCESS_INBOUND, 
                            PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 
                            PIPE_UNLIMITED_INSTANCES, 
                            sizeof maxSize, 
                            sizeof maxSize,
                            NMPWAIT_USE_DEFAULT_WAIT,
                            &sa);

if (_pipe == INVALID_HANDLE_VALUE)
{
    DWORD dwError = ::GetLastError();
}

cout<<"Connected to Pipe"<<endl;

auto pipe = CreateFile( 
     pipeName.c_str(),   // pipe name 
     GENERIC_READ | GENERIC_WRITE ,  // read and write access 
     0,              // no sharing 
     &sa,           // default security attributes
     OPEN_EXISTING,  // opens existing pipe 
     0,              // default attributes 
     NULL);          // no template file 


if (pipe == INVALID_HANDLE_VALUE)
{
    DWORD dwError = ::GetLastError();
    cout<<"Failed to open Pipe "<<dwError<<endl;
}
4

1 に答える 1