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?