locked
Access Denied (5) Error when trying to connect to named pipe from C++ client to C# application RRS feed

  • Question

  • Hi,

    I am running a c# application under my account which has Administrator priviliges. I am trying to have a c++ low integrity application connect to the named pipe. I keep getting Access Denied when I call CreateFile in the c++ code. When I change the C++ client to not be low integrity app anymore it works just fine. How do I Create my named pipe in C# to allow the low integrity apps to connect to it.

    Here is my c# code:

    SafeFileHandle

     

    handle = Win32Wrapper.CreateNamedPipe("\\\\.\\pipe\\newpipename",

     

    Win32Wrapper.DUPLEX,

     

    if (handle.IsInvalid)

     

    Thread.Sleep(100);

     

    continue;

     

    int result = Win32Wrapper.ConnectNamedPipe(handle, IntPtr.Zero);

    The CreateNamePipe call is just a wrapper for the c++ one.

    Then in C++ I try to do this:

    "\\\\.\\pipe\\newpipename", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ,

     

    char buffer[2];

     

    'M';

     

    '\0';

     

     

    DWORD bytesWritten = 0;

    WriteFile(handle, buffer, 1, &bytesWritten, NULL);

    But I am always getting access denied on the create file cause of it being a low integrity app.

    Any help would be appreciated.

    Thanks

     

     

    buffer[1] =

    buffer[0] =

    HANDLE handle = CreateFile(

     

     

    Friday, February 26, 2010 4:47 AM

Answers

All replies