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 6069457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:49:29+00:00 2026-05-23T09:49:29+00:00

I have written a windows service that catches a UDP message, creates a process

  • 0

I have written a windows service that catches a UDP message, creates a process as user, sends the message to the process via named pipes, and repeats. Service works great in XP but terminates unexpectedly in windows 7 after one iteration. Event Viewer shows that after I pass my message to the service there is an application error followed by the unexpected termination of my service. Application error says faulting module is ntdll.dll. Debugging my service shows where the code stops.

Here is my work loop.

do
{
     DebugLog("Waiting For UDP message");
    if(recvfrom(socketId, buffer, buffSize, 0, &clientAddrCast, &size) >= 0)
    {
         DebugLog("Create Named Pipe");
        hPipe = CreateNamedPipe(lpszPipename,       // pipe name
                PIPE_ACCESS_DUPLEX,     // read/write access
                PIPE_TYPE_MESSAGE |     // message pipe
                PIPE_READMODE_MESSAGE,  // message read mode
                1,                      // maximum Instaces
                buffSize,               // output buffer size
                buffSize,               // input buffer size
                5000,                   // client time-out
                &pSecAttrib);           // security attributes

        if (hPipe == INVALID_HANDLE_VALUE)
            ErrorLog("CreateNamedPipe");


         DebugLog("Create User Process");
        if(!CreateProcessAsUser(hTokenDupe, "C:\\Services\\UDPClient_UserApp.exe", NULL, NULL, NULL, false, dwCreationFlags, NULL, NULL, &si, &pi))  
        {

            // if client app fails use SendMessage as failsafe
            //WTSSendMessage(WTS_CURRENT_SERVER_HANDLE, sessionID, pTitle, sizeof(pTitle), 
                //buffer, sizeof(buffer), MB_OK, 30, &resp, false);
                ErrorLog("CreateProcess");
        }
        else
        {
             DebugLog("Writing to User Process");
            // Open pipe to client
            if(cSuccess = ConnectNamedPipe(hPipe, NULL) == 0)
                ErrorLog("ConnectNamedPipe");
            else
            {
                Sleep(2000);

                cbToWrite = (lstrlen(buffer)+1)*sizeof(TCHAR);

                if(!WriteFile( 
                  hPipe,                  // pipe handle 
                  buffer,                 // message 
                  cbToWrite,              // message length 
                  &cbWritten,             // bytes written 
                  NULL))                  // not overlapped 
                  ErrorLog("WriteFile");
            }
        }

    }

    DebugLog("Cleanup");
    DestroyEnvironmentBlock(&pEnv);
    DisconnectNamedPipe(hPipe);
    CloseHandle(hPipe);
    ErrorLog("test");     

}while(gServiceStatus.dwCurrentState == SERVICE_RUNNING); 

My debug logs in XP show that after DebugLog("Cleanup") it loops back to DebugLog("Waiting For UDP message"). In windows 7 it stops after DebugLog("Cleanup"). I am looking into problems my code may create. Any other suggestions would be greatly appreciated.

Thanks,
Joseph G.

  • 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-23T09:49:29+00:00Added an answer on May 23, 2026 at 9:49 am

    My guess would be tighter security in Win7 is getting you.

    There’s missing code here, what’s in pSecAttrib for example? Beef up your error handling so (for example) you don’t execute the rest of the loop body if pipe creation fails, and you know exactly which API failed and why.

    CreateProcessAsUser – what user are you running the service as? Does that user have the right permissions – they may be different on Win7 versus WinXP.

    Log GetLastError() value after all Win32 failures. Make your own life easier, this could be in Production in a remote site one day and how will you troubleshoot it then?

    What’s that Sleep(2000); for? Suspicious. If the pipe is open why not just send the data and avoid this delay. Is the Named Pipe server code this slow to post a read request on the pipe?

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

Sidebar

Related Questions

I have written a Windows service that spawns a separate process. This process creates
I have written a code that sends out Email from Windows Service. Now when
I have a windows service written in C# that creates a truck load of
I have written a Windows service that allows me to remotely run and stop
I have a windows service that loads multiple handlers written by different developers. The
I have a windows service written in C# that acts as a proxy for
I have a Windows Service written in C# that handles all of our external
We have a Windows Service written in C#. The service spawns a thread that
Scenario I have a windows service written in C# that performs some processing based
I have a server written in Java that runs as a Windows service (thanks

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.