Overlapped problem with CreateNamedPipe in NT Service

L

Lewap

Hi!

I have a problem:
Function CreateNamedPipe (a piece of source below) called in a NT service I
get an error 997 - Overlapped I/O operation is in progress.

When I run the same code as oridinal application (not NT service) everything
works properly.

Service is develop in Managed/Unmanaged C++ (.NET Environment). And is
runing on LocalSystem account so I think it is not problem with privileges

<code>
LPTSTR lpszPipename = (LPTSTR) \\\\.\\pipe\\testpipe;

hPipe = CreateNamedPipe(

lpszPipename, // pipe name

PIPE_ACCESS_DUPLEX | // read/write access

FILE_FLAG_OVERLAPPED,

PIPE_TYPE_MESSAGE | // message type pipe

PIPE_READMODE_MESSAGE | // message-read mode

PIPE_WAIT, // blocking mode

1, // number of instances (max. instances - PIPE_UNLIMITED_INSTANCES)

BUFSIZE, // output buffer size

BUFSIZE, // input buffer size

PIPE_TIMEOUT, // client time-out

NULL);

if (hPipe == INVALID_HANDLE_VALUE) {

log->WriteEntry("Error creating pipe!", EventLogEntryType::Error);

err = __box(GetLastError());

logEntry = String::Format("Last error: {0}", err);

log->WriteEntry(logEntry);

}

else {

log->WriteEntry("Success creating pipe!");

}

CloseHandle(hPipe);

<code>

Thanks in advance for any help or suggestions

Best regards
Pawel.
 
W

William DePalo [MVP VC++]

Lewap said:
I have a problem:
Function CreateNamedPipe (a piece of source below) called in a NT service
I
get an error 997 - Overlapped I/O operation is in progress.

Instead of this

if (hPipe == INVALID_HANDLE_VALUE) {
log->WriteEntry("Error creating pipe!", EventLogEntryType::Error);
err = __box(GetLastError());

try this

if (hPipe == INVALID_HANDLE_VALUE) {
err = __box(GetLastError());
log->WriteEntry("Error creating pipe!", EventLogEntryType::Error);

Note that a thread saves only its _last_ error.

Regards,
Will
 
L

Lewap

U¿ytkownik "William DePalo said:
Instead of this

if (hPipe == INVALID_HANDLE_VALUE) {
log->WriteEntry("Error creating pipe!", EventLogEntryType::Error);
err = __box(GetLastError());

try this

if (hPipe == INVALID_HANDLE_VALUE) {
err = __box(GetLastError());
log->WriteEntry("Error creating pipe!", EventLogEntryType::Error);

Note that a thread saves only its _last_ error.

Thank's a lot! In fact that error was caused by another error appear
earlier - 123 "The file name, directory name, or volume label syntax is
incorrect." So, name of named pipe is wrong, I suppose.

Best regards
Pawel.
 
W

William DePalo [MVP VC++]

Lewap said:
Thank's a lot!

You are welcome.
In fact that error was caused by another error appear
earlier - 123 "The file name, directory name, or volume
label syntax is incorrect." So, name of named pipe is
wrong, I suppose.

This is from the docs on pipe names:

<quote>
The pipename part of the name can include any character
other than a backslash, including numbers and special
characters. The entire pipe name string can be up to 256
characters long. Pipe names are not case sensitive.

Windows Me/98/95: Pipe names cannot include a colon.
Therefore, if this pipe will be used from a Windows Me/98/95
client, do not include a colon in the name.
</quote>

Please post any follow-up in the kernel group.

Regards,
Will
 
L

Lewap

The problem was that I've used wrong conversion for name of pipe. I wrote:

LPTSTR lpszPipename = (LPTSTR) "\\\\.\\pipe\\testpipe";

and should be:

LPTSTR lpszPipename = _T("\\\\.\\pipe\\testpipe");

and now everything works fine.

Thanks again!

Best regards,
Pawel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top