UWP pipe client and C++ Fulltrustprocess pipe server - Access to the path is denied

DotNET Fan 271 Reputation points
2024-11-19T04:13:17.18+00:00

Hello UWP experts,

I get "Access to the path is denied" when connecting a UWP namedpipeclient to C++ Fulltrust process namedpipe server in packaged (WAPP) and non packaged mode. Its a simple piece of code to see how the namedpipe works betweek UWP and C++ fulltrustprocess.

The UWP app starts the fulltrustprocess with the FullTrustProcessLauncher and the fulltrustprocess is launched properly. In the fulltrustprocess we have the below C++ code to create the namedpipeserver and pipe is created successfully and it waits for the client to connect. That can be verified through the

pipelist64 tool.

HANDLE hPipe;
 std::wstring pipeName = L"\\\\.\\pipe\\TitleChangePipe";
 SECURITY_ATTRIBUTES sa;
 SECURITY_DESCRIPTOR sd;
 // Initialize a security descriptor that allows all access
 InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
 SetSecurityDescriptorDacl(&sd, TRUE, nullptr, FALSE);
 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
 sa.lpSecurityDescriptor = &sd;
 sa.bInheritHandle = FALSE;
 hPipe = CreateNamedPipeW(
     pipeName.c_str(),                  // Pipe name
     PIPE_ACCESS_DUPLEX,                 // Read/Write access
     PIPE_TYPE_MESSAGE |                 // Message-type pipe
                  
     PIPE_WAIT,                          // Blocking mode
     1,           // Maximum instances
     1024,                                // Output buffer size
     1024,                                // Input buffer size
     200000,                                  // Default timeout
     &sa);                              // Default security attributes
 if (hPipe == INVALID_HANDLE_VALUE) {
    
     return false;
 }

Once the server starts it waits for client to connect

bool NamedPipeServer::WaitForClient() {

BOOL connected = ConnectNamedPipe(hPipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);

if (!connected) {

CloseHandle(hPipe_);

hPipe = INVALID_HANDLE_VALUE;

return false;

}

From the UWP client once the fulltrust process is launched , it tries to connect to the server , but pipeclient.connectAsync throws the exception "Access to the path is denied"

NamedPipeClientStream pipeClient;

pipeClient = new NamedPipeClientStream(".", "TitleChangePipe", PipeDirection.InOut);

await Task.Delay(2000);

await pipeClient.ConnectAsync(60000);

if (pipeClient.IsConnected)

{

}

Capabilities in package.manifest

<rescap:Capability Name="runFullTrust" />

<Capability Name="internetClient" />

Any idea why it throws the access denied in packaged and non packaged mode?

Universal Windows Platform (UWP)
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,666 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,053 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,774 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Junjie Zhu - MSFT 19,216 Reputation points Microsoft Vendor
    2024-11-19T07:45:06.19+00:00

    Hello @DotNET Fan ,

    Welcome to Microsoft Q&A!

    According to the official document,

    Pipes are only supported within an app-container; ie, from one UWP process to another UWP process that's part of the same app.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.