Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7519681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:56:36+00:00 2026-05-30T01:56:36+00:00

i am creating a pipe in c++ and when i try to write to

  • 0

i am creating a pipe in c++ and when i try to write to that pipe using php code it gives me access denied error when i try to get a handle to that pipe.
Basically the php code calls another c++ exe which writes to the pipe but it fails.I think its die to some security or access rights that the user does not have (php user).
Any ideas??

Code c++

     hPipe = CreateNamedPipe( 
        wcPipeName,             // pipe name 
        PIPE_ACCESS_DUPLEX,       // read/write access 
         PIPE_TYPE_MESSAGE |       // message type pipe 
         PIPE_READMODE_MESSAGE |   // message-read mode 
            PIPE_WAIT,                // blocking mode 
         PIPE_UNLIMITED_INSTANCES, // max. instances  
        1024,                  // output buffer size 
        1024,                  // input buffer size 
         NMPWAIT_USE_DEFAULT_WAIT, // client time-out 
         NULL); 

Code client for writing called from php

hPipe = CreateFile( 
        lpszPipename,   // pipe name 
        GENERIC_READ,   // read and write access 
        0,              // no sharing 
        NULL,           // default security attributes
        OPEN_EXISTING,  // opens existing pipe 
        0,              // default attributes 
        NULL);          // no template file 

    if (hPipe == INVALID_HANDLE_VALUE) 
    {
        printf("\nCreatePipe failed\n %d \n",GetLastError()); 

        return FALSE;
    }

    //Sleep(1000);

    // Write the reply to the pipe. 
    fSuccess = WriteFile( 
        hPipe,        // handle to pipe 
        Buffer,      // buffer to write from 
        BufferSize-1,       // number of bytes to write 
        &cbWritten,   // number of bytes written 
        NULL);        // not overlapped I/O 

    FlushFileBuffers(hPipe); 
    CloseHandle(hPipe);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:56:38+00:00Added an answer on May 30, 2026 at 1:56 am

    As the server and client processes are running under two different user accounts and the server side pipe is created with a default security descriptor suggest setting a security descriptor that would allow Everyone access:

    // Create a security descriptor that has an an empty DACL to
    // grant access to 'Everyone'
    //
    SECURITY_DESCRIPTOR sd;
    if (0 == InitializeSecurityDescriptor(&sd,
                                          SECURITY_DESCRIPTOR_REVISION) ||
        0 == SetSecurityDescriptorDacl(&sd,
                                       TRUE,
                                       static_cast<PACL>(0),
                                       FALSE))
    {
        std::cerr << "Failed: " << GetLastError() << "\n";
    }
    else
    {
    
        SECURITY_ATTRIBUTES sa;
        sa.nLength              = sizeof(sa);
        sa.lpSecurityDescriptor = &sd;
        sa.bInheritHandle       = FALSE;
    
        hPipe = CreateNamedPipe( 
            wcPipeName,             // pipe name 
            PIPE_ACCESS_DUPLEX,       // read/write access 
             PIPE_TYPE_MESSAGE |       // message type pipe 
             PIPE_READMODE_MESSAGE |   // message-read mode 
             PIPE_WAIT,                // blocking mode 
            PIPE_UNLIMITED_INSTANCES, // max. instances  
            1024,                  // output buffer size 
            1024,                  // input buffer size 
            NMPWAIT_USE_DEFAULT_WAIT, // client time-out 
            &sa); 
    }
    

    Also, the client side opens the pipe with GENERIC_READ and then attempts to WriteFile() to the handle: this needs to be either GENERIC_WRITE or GENERIC_READ | GENERIC_WRITE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried creating a named pipe but getting GLE 5 (access denied Error)
I'm creating a pipe that basically needs to follow the work flow as follows:
I'm creating a python script that runs rsync using subprocess and then gets the
I am creating a python module that is implemented in C++. I am using
I am creating a named pipe using JNI by calling the mkfifo() command. I
I have a Named Pipe and It Works Fine While I access it using
Does anyone have any good suggestions for creating a Pipe object in Java which
I am creating a Yahoo! Pipe to a news site but the feedless source
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
I am having trouble in creating named pipe in Android and the example below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.