none
IPC using named pipes - ERROR_ACCESS_DENIED

    Question

  • I've got two processes that need to communicate. One process is a service and the other is a user interface application. According to Microsoft's guidelines for Vista, named pipes should be a viable mechanism for this communication.

     

    The problem is when I attempt to open the pipe in the UI application, I get ERROR_ACCESS_DENIED. I'm doing my testing under Vista Ultimate Edition. The OS installation is fairly vanilla with little changes to defaults. UAC is enabled. The service is running under a user account identical to the logged in user although the problem is identical when the service is running under the system account.

     

    Here's the code I use for creating the named pipe in the service :

     

    CreateNamedPipe("\\\\.\\pipe\\MCMONITORMessSyncPipe", PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,PIPE_UNLIMITED_INSTANCES, 200, 200, NMPWAIT_USE_DEFAULT_WAIT,NULL); 

     

    Here's the code I use for opening the named pipe in the UI app :

     

    CreateFile("\\\\.\\pipe\\MCMONITORMessSyncPipe",GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);

     

    It is this CreateFile that results in the ERROR_ACCESS_DENIED.

     

    Any ideas what I'm doing wrong. It is obviously something related to UAC because if I run the UI application as an Administrator (not acceptable) or disable UAC (not acceptable) everything works fine.

     

    Thanks

    Mark Koehler

    Monday, April 09, 2007 4:20 PM

Answers

  • When you call CreateNamedPipe in the service, instead of supplying NULL for lpSecurityAttributes, try supplying one that specifies access rights that fit your scenario.

    Monday, April 09, 2007 7:23 PM