Some named pipe improvements (not usable yet!).

svn path=/trunk/; revision=1902
This commit is contained in:
Eric Kohl 2001-05-10 23:38:31 +00:00
parent 4c5a154f4d
commit 7d0f1e3433
9 changed files with 502 additions and 348 deletions

View file

@ -1,99 +1,100 @@
#include <windows.h> #include <windows.h>
VOID MyErrExit(LPTSTR Message) VOID MyErrExit(LPTSTR Message)
{ {
MessageBox(NULL, Message, NULL, MB_OK); // MessageBox(NULL, Message, NULL, MB_OK);
ExitProcess(0); puts(Message);
} ExitProcess(0);
}
DWORD main(int argc, char *argv[])
{ int main(int argc, char *argv[])
HANDLE hPipe; {
LPVOID lpvMessage; HANDLE hPipe;
CHAR chBuf[512]; LPVOID lpvMessage;
BOOL fSuccess; CHAR chBuf[512];
DWORD cbRead, cbWritten, dwMode; BOOL fSuccess;
LPTSTR lpszPipename = "\\\\.\\pipe\\mynamedpipe"; DWORD cbRead, cbWritten, dwMode;
LPTSTR lpszPipename = "\\\\.\\pipe\\mynamedpipe";
// Try to open a named pipe; wait for it, if necessary.
// Try to open a named pipe; wait for it, if necessary.
while (1)
{ while (1)
hPipe = CreateFile( {
lpszPipename, // pipe name hPipe = CreateFile(
GENERIC_READ | // read and write access lpszPipename, // pipe name
GENERIC_WRITE, GENERIC_READ | // read and write access
0, // no sharing GENERIC_WRITE,
NULL, // no security attributes 0, // no sharing
OPEN_EXISTING, // opens existing pipe NULL, // no security attributes
0, // default attributes OPEN_EXISTING, // opens existing pipe
NULL); // no template file 0, // default attributes
NULL); // no template file
// Break if the pipe handle is valid.
// Break if the pipe handle is valid.
if (hPipe != INVALID_HANDLE_VALUE)
break; if (hPipe != INVALID_HANDLE_VALUE)
break;
// Exit if an error other than ERROR_PIPE_BUSY occurs.
// Exit if an error other than ERROR_PIPE_BUSY occurs.
if (GetLastError() != ERROR_PIPE_BUSY)
MyErrExit("Could not open pipe"); if (GetLastError() != ERROR_PIPE_BUSY)
MyErrExit("Could not open pipe");
// All pipe instances are busy, so wait for 20 seconds.
// All pipe instances are busy, so wait for 20 seconds.
if (! WaitNamedPipe(lpszPipename, 20000) )
MyErrExit("Could not open pipe"); if (! WaitNamedPipe(lpszPipename, 20000) )
} MyErrExit("Could not open pipe");
}
// The pipe connected; change to message-read mode.
// The pipe connected; change to message-read mode.
dwMode = PIPE_READMODE_MESSAGE;
fSuccess = SetNamedPipeHandleState( dwMode = PIPE_READMODE_MESSAGE;
hPipe, // pipe handle fSuccess = SetNamedPipeHandleState(
&dwMode, // new pipe mode hPipe, // pipe handle
NULL, // don't set maximum bytes &dwMode, // new pipe mode
NULL); // don't set maximum time NULL, // don't set maximum bytes
if (!fSuccess) NULL); // don't set maximum time
MyErrExit("SetNamedPipeHandleState"); if (!fSuccess)
MyErrExit("SetNamedPipeHandleState");
// Send a message to the pipe server.
// Send a message to the pipe server.
lpvMessage = (argc > 1) ? argv[1] : "default message";
lpvMessage = (argc > 1) ? argv[1] : "default message";
fSuccess = WriteFile(
hPipe, // pipe handle fSuccess = WriteFile(
lpvMessage, // message hPipe, // pipe handle
strlen(lpvMessage) + 1, // message length lpvMessage, // message
&cbWritten, // bytes written strlen(lpvMessage) + 1, // message length
NULL); // not overlapped &cbWritten, // bytes written
if (! fSuccess) NULL); // not overlapped
MyErrExit("WriteFile"); if (! fSuccess)
MyErrExit("WriteFile");
do
{ do
// Read from the pipe. {
// Read from the pipe.
fSuccess = ReadFile(
hPipe, // pipe handle fSuccess = ReadFile(
chBuf, // buffer to receive reply hPipe, // pipe handle
512, // size of buffer chBuf, // buffer to receive reply
&cbRead, // number of bytes read 512, // size of buffer
NULL); // not overlapped &cbRead, // number of bytes read
NULL); // not overlapped
if (! fSuccess && GetLastError() != ERROR_MORE_DATA)
break; if (! fSuccess && GetLastError() != ERROR_MORE_DATA)
break;
// Reply from the pipe is written to STDOUT.
// Reply from the pipe is written to STDOUT.
if (! WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
chBuf, cbRead, &cbWritten, NULL)) if (! WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
{ chBuf, cbRead, &cbWritten, NULL))
break; {
} break;
}
} while (! fSuccess); // repeat loop if ERROR_MORE_DATA
} while (! fSuccess); // repeat loop if ERROR_MORE_DATA
CloseHandle(hPipe);
CloseHandle(hPipe);
return 0;
} return 0;
}

View file

@ -2,57 +2,86 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <windows.h> #include <windows.h>
#include <tchar.h>
#define BUFSIZE 1024
#define PIPE_TIMEOUT 1000
VOID InstanceThread (LPVOID); VOID InstanceThread (LPVOID);
VOID GetAnswerToRequest (LPTSTR, LPTSTR, LPDWORD) VOID
GetAnswerToRequest(LPTSTR lpRequest,
LPTSTR lpReply,
LPDWORD lpcbReplyBytes)
{ {
} }
VOID MyErrExit(LPTSTR Message)
{
// MessageBox(NULL, Message, NULL, MB_OK);
puts(Message);
ExitProcess(0);
}
int xx = 0; int xx = 0;
DWORD main (VOID) int main(int argc, char *argv[])
{ {
BOOL fConnected; BOOL fConnected;
DWORD dwThreadId; DWORD dwThreadId;
HANDLE hPipe, hThread; HANDLE hPipe, hThread;
LPTSTR lpszPipename = "\\\\.\\pipe\\mynamedpipe"; LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe");
for (;;) // for (;;)
{ // {
hPipe = CreateNamedPipe (lpszPipename, hPipe = CreateNamedPipe(lpszPipename,
PIPE_ACCESS_DUPLEX, PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE | PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE | PIPE_READMODE_MESSAGE |
PIPE_WAIT, PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES, PIPE_UNLIMITED_INSTANCES,
BUFSIZE, BUFSIZE,
BUFSIZE, BUFSIZE,
PIPE_TIMEOUT, PIPE_TIMEOUT,
NULL); NULL);
if (hPipe == INVALID_HANDLE_VALUE) if (hPipe == INVALID_HANDLE_VALUE)
MyErrExit ("CreatePipe"); {
printf("CreateNamedPipe() failed\n");
fConnected = ConnectNamedPipe (hPipe, return 0;
NULL) ? TRUE : (GetLastError () == }
fConnected = ConnectNamedPipe(hPipe,
NULL) ? TRUE : (GetLastError () ==
ERROR_PIPE_CONNECTED); ERROR_PIPE_CONNECTED);
if (fConnected) if (fConnected)
{
hThread = CreateThread (NULL,
0,
(LPTHREAD_START_ROUTINE) InstanceThread,
(LPVOID) hPipe,
0,
&dwThreadId);
if (hThread == NULL)
MyErrExit ("CreateThread");
}
else
{ {
CloseHandle (hPipe); printf("Pipe connected!\n");
DisconnectNamedPipe(hPipe);
#if 0
hThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE) InstanceThread,
(LPVOID) hPipe,
0,
&dwThreadId);
if (hThread == NULL)
MyErrExit("CreateThread");
#endif
} }
} else
return 1; {
// CloseHandle(hPipe);
}
// }
CloseHandle(hPipe);
return 0;
} }
VOID InstanceThread (LPVOID lpvParam) VOID InstanceThread (LPVOID lpvParam)
@ -63,28 +92,29 @@ VOID InstanceThread (LPVOID lpvParam)
BOOL fSuccess; BOOL fSuccess;
HANDLE hPipe; HANDLE hPipe;
hPipe = (HANDLE) lpvParam; hPipe = (HANDLE)lpvParam;
while (1) while (1)
{ {
fSuccess = ReadFile (hPipe, fSuccess = ReadFile(hPipe,
chRequest, chRequest,
BUFSIZE, BUFSIZE,
&cbBytesRead, &cbBytesRead,
NULL); NULL);
if (!fSuccess || cbBytesRead == 0) if (!fSuccess || cbBytesRead == 0)
break; break;
GetAnswerToRequest (chRequest, chReply, &cbReplyBytes);
GetAnswerToRequest(chRequest, chReply, &cbReplyBytes);
fSuccess = WriteFile (hPipe,
chReply, fSuccess = WriteFile(hPipe,
cbReplyBytes, chReply,
&cbWritten, cbReplyBytes,
NULL); &cbWritten,
if (!fSuccess || cbReplyBytes != cbWritten) NULL);
break; if (!fSuccess || cbReplyBytes != cbWritten)
break;
} }
FlushFileBuffers(hPipe); FlushFileBuffers(hPipe);
DisconnectNamedPipe (hPipe); DisconnectNamedPipe(hPipe);
CloseHandle (hPipe); CloseHandle(hPipe);
} }

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.5 2001/05/07 22:03:27 chorns Exp $ # $Id: Makefile,v 1.6 2001/05/10 23:38:31 ekohl Exp $
# #
# Named Pipes File System # Named Pipes File System
# #
@ -8,21 +8,25 @@ TARGETNAME=npfs
#BASE_CFLAGS = -I../../../include #BASE_CFLAGS = -I../../../include
OBJECTS = create.o fsctrl.o mount.o rw.o npfs.coff \ OBJECTS = create.o fsctrl.o mount.o rw.o npfs.coff
../../../ntoskrnl/ntoskrnl.a
LIBS = ../../../ntoskrnl/ntoskrnl.a
all: $(TARGETNAME).sys all: $(TARGETNAME).sys
.phony: all .phony: all
clean: clean:
- $(RM) create.o - $(RM) *.o
- $(RM) mount.o - $(RM) npfs.coff
- $(RM) junk.tmp
- $(RM) base.tmp
- $(RM) temp.exp
- $(RM) $(TARGETNAME).sys - $(RM) $(TARGETNAME).sys
.phony: clean .phony: clean
$(TARGETNAME).sys: $(OBJECTS) $(TARGETNAME).sys: $(OBJECTS) $(LIBS)
$(CC) \ $(CC) \
-specs=../../svc_specs \ -specs=../../svc_specs \
-mdll \ -mdll \
@ -31,7 +35,7 @@ $(TARGETNAME).sys: $(OBJECTS)
-Wl,--defsym,_edata=__data_end__ \ -Wl,--defsym,_edata=__data_end__ \
-Wl,--defsym,_etext=etext \ -Wl,--defsym,_etext=etext \
-Wl,--base-file,base.tmp \ -Wl,--base-file,base.tmp \
$(OBJECTS) $(OBJECTS) $(LIBS)
$(RM) junk.tmp $(RM) junk.tmp
$(DLLTOOL) \ $(DLLTOOL) \
--dllname $(TARGETNAME).sys \ --dllname $(TARGETNAME).sys \
@ -46,9 +50,10 @@ $(TARGETNAME).sys: $(OBJECTS)
-specs=../../svc_specs \ -specs=../../svc_specs \
-mdll \ -mdll \
-o $(TARGETNAME).sys \ -o $(TARGETNAME).sys \
$(OBJECTS) \ $(OBJECTS) $(LIBS) \
-Wl,temp.exp -Wl,temp.exp
$(RM) temp.exp $(RM) temp.exp
$(NM) --numeric-sort npfs.sys > npfs.sym
npfs.coff: ../../../include/reactos/buildno.h npfs.rc npfs.coff: ../../../include/reactos/buildno.h npfs.rc

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.5 2001/05/01 11:09:01 ekohl Exp $ /* $Id: create.c,v 1.6 2001/05/10 23:38:31 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -19,17 +19,9 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
static LIST_ENTRY PipeListHead;
static KMUTEX PipeListLock;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID NpfsInitPipeList(VOID)
{
InitializeListHead(&PipeListHead);
KeInitializeMutex(&PipeListLock, 0);
}
NTSTATUS STDCALL NTSTATUS STDCALL
NpfsCreate(PDEVICE_OBJECT DeviceObject, NpfsCreate(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
@ -39,7 +31,6 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
NTSTATUS Status; NTSTATUS Status;
PNPFS_PIPE Pipe; PNPFS_PIPE Pipe;
PNPFS_FCB Fcb; PNPFS_FCB Fcb;
PWSTR PipeName;
PNPFS_PIPE current; PNPFS_PIPE current;
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
PNPFS_DEVICE_EXTENSION DeviceExt; PNPFS_DEVICE_EXTENSION DeviceExt;
@ -51,8 +42,6 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
IoStack = IoGetCurrentIrpStackLocation(Irp); IoStack = IoGetCurrentIrpStackLocation(Irp);
FileObject = IoStack->FileObject; FileObject = IoStack->FileObject;
PipeName = FileObject->FileName.Buffer;
Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB)); Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
if (Fcb == NULL) if (Fcb == NULL)
{ {
@ -64,15 +53,17 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
} }
KeLockMutex(&PipeListLock); KeLockMutex(&DeviceExt->PipeListLock);
current_entry = PipeListHead.Flink; current_entry = DeviceExt->PipeListHead.Flink;
while (current_entry != &PipeListHead) while (current_entry != &DeviceExt->PipeListHead)
{ {
current = CONTAINING_RECORD(current_entry, current = CONTAINING_RECORD(current_entry,
NPFS_PIPE, NPFS_PIPE,
PipeListEntry); PipeListEntry);
if (wcscmp(Pipe->Name, current->Name) == 0) if (RtlCompareUnicodeString(&Pipe->PipeName,
&current->PipeName,
TRUE) == 0)
{ {
break; break;
} }
@ -80,10 +71,10 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
current_entry = current_entry->Flink; current_entry = current_entry->Flink;
} }
if (current_entry == &PipeListHead) if (current_entry == &DeviceExt->PipeListHead)
{ {
ExFreePool(Fcb); ExFreePool(Fcb);
KeUnlockMutex(&PipeListLock); KeUnlockMutex(&DeviceExt->PipeListLock);
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
@ -109,7 +100,10 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
Pipe->ReferenceCount++; Pipe->ReferenceCount++;
KeUnlockMutex(&PipeListLock); /* search for unconnected server fcb */
KeUnlockMutex(&DeviceExt->PipeListLock);
FileObject->FsContext = Fcb; FileObject->FsContext = Fcb;
@ -121,6 +115,7 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
return(Status); return(Status);
} }
NTSTATUS STDCALL NTSTATUS STDCALL
NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
@ -129,7 +124,6 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
PNPFS_DEVICE_EXTENSION DeviceExt; PNPFS_DEVICE_EXTENSION DeviceExt;
PWSTR PipeName;
PNPFS_PIPE Pipe; PNPFS_PIPE Pipe;
PNPFS_FCB Fcb; PNPFS_FCB Fcb;
KIRQL oldIrql; KIRQL oldIrql;
@ -143,8 +137,6 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
IoStack = IoGetCurrentIrpStackLocation(Irp); IoStack = IoGetCurrentIrpStackLocation(Irp);
FileObject = IoStack->FileObject; FileObject = IoStack->FileObject;
PipeName = FileObject->FileName.Buffer;
Buffer = (PIO_PIPE_CREATE_BUFFER)Irp->Tail.Overlay.AuxiliaryBuffer; Buffer = (PIO_PIPE_CREATE_BUFFER)Irp->Tail.Overlay.AuxiliaryBuffer;
Pipe = ExAllocatePool(NonPagedPool, sizeof(NPFS_PIPE)); Pipe = ExAllocatePool(NonPagedPool, sizeof(NPFS_PIPE));
@ -171,9 +163,7 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
} }
Pipe->Name = ExAllocatePool(NonPagedPool, if (RtlCreateUnicodeString(&Pipe->PipeName, FileObject->FileName.Buffer) == 0)
(wcslen(PipeName) + 1) * sizeof(WCHAR));
if (Pipe->Name == NULL)
{ {
ExFreePool(Pipe); ExFreePool(Pipe);
ExFreePool(Fcb); ExFreePool(Fcb);
@ -186,7 +176,6 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
} }
wcscpy(Pipe->Name, PipeName);
Pipe->ReferenceCount = 0; Pipe->ReferenceCount = 0;
InitializeListHead(&Pipe->FcbListHead); InitializeListHead(&Pipe->FcbListHead);
KeInitializeSpinLock(&Pipe->FcbListLock); KeInitializeSpinLock(&Pipe->FcbListLock);
@ -194,15 +183,15 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
Pipe->MaxInstances = Buffer->MaxInstances; Pipe->MaxInstances = Buffer->MaxInstances;
Pipe->TimeOut = Buffer->TimeOut; Pipe->TimeOut = Buffer->TimeOut;
KeLockMutex(&PipeListLock); KeLockMutex(&DeviceExt->PipeListLock);
current_entry = PipeListHead.Flink; current_entry = DeviceExt->PipeListHead.Flink;
while (current_entry != &PipeListHead) while (current_entry != &DeviceExt->PipeListHead)
{ {
current = CONTAINING_RECORD(current_entry, current = CONTAINING_RECORD(current_entry,
NPFS_PIPE, NPFS_PIPE,
PipeListEntry); PipeListEntry);
if (wcscmp(Pipe->Name, current->Name) == 0) if (RtlCompareUnicodeString(&Pipe->PipeName, &current->PipeName, TRUE) == 0)
{ {
break; break;
} }
@ -210,16 +199,16 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
current_entry = current_entry->Flink; current_entry = current_entry->Flink;
} }
if (current_entry != &PipeListHead) if (current_entry != &DeviceExt->PipeListHead)
{ {
ExFreePool(Pipe->Name); RtlFreeUnicodeString(&Pipe->PipeName);
ExFreePool(Pipe); ExFreePool(Pipe);
Pipe = current; Pipe = current;
} }
else else
{ {
InsertTailList(&PipeListHead, &Pipe->PipeListEntry); InsertTailList(&DeviceExt->PipeListHead, &Pipe->PipeListEntry);
} }
Pipe->ReferenceCount++; Pipe->ReferenceCount++;
@ -237,7 +226,11 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
Fcb->IsServer = TRUE; Fcb->IsServer = TRUE;
Fcb->OtherSide = NULL; Fcb->OtherSide = NULL;
KeUnlockMutex(&PipeListLock); KeInitializeEvent(&Fcb->ConnectEvent,
SynchronizationEvent,
FALSE);
KeUnlockMutex(&DeviceExt->PipeListLock);
FileObject->FsContext = Fcb; FileObject->FsContext = Fcb;
@ -254,27 +247,48 @@ NTSTATUS STDCALL
NpfsClose(PDEVICE_OBJECT DeviceObject, NpfsClose(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PNPFS_DEVICE_EXTENSION DeviceExt;
PIO_STACK_LOCATION IoStack; PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
PNPFS_FCB Fcb; PNPFS_FCB Fcb;
NTSTATUS Status; PNPFS_PIPE Pipe;
KIRQL oldIrql;
DPRINT1("NpfsClose(DeviceObject %p Irp %p)\n", DeviceObject, Irp); DPRINT("NpfsClose(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
IoStack = IoGetCurrentIrpStackLocation(Irp); IoStack = IoGetCurrentIrpStackLocation(Irp);
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
FileObject = IoStack->FileObject; FileObject = IoStack->FileObject;
Fcb = FileObject->FsContext; Fcb = FileObject->FsContext;
Pipe = Fcb->Pipe;
DPRINT1("Closing pipe %S\n", Fcb->Pipe->Name); DPRINT("Closing pipe %wZ\n", &Pipe->PipeName);
Status = STATUS_SUCCESS; KeLockMutex(&DeviceExt->PipeListLock);
Irp->IoStatus.Status = Status; Pipe->ReferenceCount--;
KeAcquireSpinLock(&Pipe->FcbListLock, &oldIrql);
RemoveEntryList(&Fcb->FcbListEntry);
KeReleaseSpinLock(&Pipe->FcbListLock, oldIrql);
ExFreePool(Fcb);
FileObject->FsContext = NULL;
if (Pipe->ReferenceCount == 0)
{
RtlFreeUnicodeString(&Pipe->PipeName);
RemoveEntryList(&Pipe->PipeListEntry);
ExFreePool(Pipe);
}
KeUnlockMutex(&DeviceExt->PipeListLock);
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status); return(STATUS_SUCCESS);
} }
/* EOF */ /* EOF */

View file

@ -1,10 +1,11 @@
/* $Id: fsctrl.c,v 1.2 2001/05/01 11:09:01 ekohl Exp $ /* $Id: fsctrl.c,v 1.3 2001/05/10 23:38:31 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: services/fs/np/fsctrl.c * FILE: services/fs/np/fsctrl.c
* PURPOSE: Named pipe filesystem * PURPOSE: Named pipe filesystem
* PROGRAMMER: David Welch <welch@cwcom.net> * PROGRAMMER: David Welch <welch@cwcom.net>
* Eric Kohl <ekohl@rz-online.de>
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES ******************************************************************/
@ -18,6 +19,31 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
static NTSTATUS
NpfsConnectPipe(PNPFS_FCB Fcb)
{
NTSTATUS Status;
Status = KeWaitForSingleObject(&Fcb->ConnectEvent,
UserRequest,
KernelMode,
FALSE,
NULL);
DPRINT("Finished waiting! Status: %x\n", Status);
return STATUS_SUCCESS;
}
static NTSTATUS
NpfsDisconnectPipe(PNPFS_FCB Fcb)
{
return STATUS_SUCCESS;
}
NTSTATUS STDCALL NTSTATUS STDCALL
NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject, NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
@ -29,6 +55,8 @@ NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
PNPFS_PIPE Pipe; PNPFS_PIPE Pipe;
PNPFS_FCB Fcb; PNPFS_FCB Fcb;
DPRINT("NpfsFileSystemContol(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension; DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
IoStack = IoGetCurrentIrpStackLocation(Irp); IoStack = IoGetCurrentIrpStackLocation(Irp);
FileObject = IoStack->FileObject; FileObject = IoStack->FileObject;
@ -37,10 +65,18 @@ NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
switch (IoStack->Parameters.FileSystemControl.IoControlCode) switch (IoStack->Parameters.FileSystemControl.IoControlCode)
{ {
case FSCTL_WAIT_PIPE: case FSCTL_PIPE_LISTEN:
DPRINT("Connecting pipe %wZ\n", &Pipe->PipeName);
Status = NpfsConnectPipe(Fcb);
break; break;
case FSCTL_LISTEN: case FSCTL_PIPE_DISCONNECT:
DPRINT("Disconnecting pipe %wZ\n", &Pipe->PipeName);
Status = NpfsDisconnectPipe(Fcb);
break;
#if 0
case FSCTL_WAIT_PIPE:
break; break;
case FSCTL_SET_STATE: case FSCTL_SET_STATE:
@ -53,9 +89,18 @@ NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
break; break;
} }
#endif
default: default:
DPRINT("IoControlCode: %x\n", IoStack->Parameters.FileSystemControl.IoControlCode)
Status = STATUS_UNSUCCESSFUL;
} }
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
} }
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: mount.c,v 1.6 2001/05/07 22:03:27 chorns Exp $ /* $Id: mount.c,v 1.7 2001/05/10 23:38:31 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -16,42 +16,19 @@
#include <debug.h> #include <debug.h>
/* GLOBALS *******************************************************************/
//static PDRIVER_OBJECT DriverObject;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT DriverObject, NTSTATUS STDCALL
PUNICODE_STRING RegistryPath) DriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
{ {
PNPFS_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT DeviceObject; PDEVICE_OBJECT DeviceObject;
NTSTATUS Status;
UNICODE_STRING DeviceName; UNICODE_STRING DeviceName;
UNICODE_STRING LinkName; UNICODE_STRING LinkName;
NTSTATUS Status;
DbgPrint("Named Pipe Filesystem\n"); DbgPrint("Named Pipe FSD 0.0.2\n");
// DriverObject = _DriverObject;
#if 0
RtlInitUnicodeString(&DeviceName, L"\\Device\\Npfs");
Status = IoCreateDevice(DriverObject,
0,
&DeviceName,
FILE_DEVICE_NAMED_PIPE,
0,
FALSE,
&DeviceObject);
if (!NT_SUCCESS(Status))
{
return(Status);
}
RtlInitUnicodeString(&LinkName, L"\\??\\Pipe");
Status = IoCreateSymbolicLink(&LinkName,
&DeviceName);
#endif
DeviceObject->Flags = 0; DeviceObject->Flags = 0;
DriverObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate; DriverObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate;
@ -68,7 +45,6 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT DriverObject,
// NpfsSetInformation; // NpfsSetInformation;
// DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers; // DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers;
// DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = NpfsShutdown; // DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = NpfsShutdown;
// DriverObject->MajorFunction[IRP_MJ_CLEANUP] = NpfsCleanup;
// DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] = // DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] =
// NpfsQuerySecurity; // NpfsQuerySecurity;
// DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] = // DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] =
@ -78,9 +54,9 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT DriverObject,
DriverObject->DriverUnload = NULL; DriverObject->DriverUnload = NULL;
RtlInitUnicodeString(&DeviceName, L"\\Device\\Npfs"); RtlInitUnicodeString(&DeviceName, L"\\Device\\NamedPipe");
Status = IoCreateDevice(DriverObject, Status = IoCreateDevice(DriverObject,
0, sizeof(NPFS_DEVICE_EXTENSION),
&DeviceName, &DeviceName,
FILE_DEVICE_NAMED_PIPE, FILE_DEVICE_NAMED_PIPE,
0, 0,
@ -88,25 +64,30 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT DriverObject,
&DeviceObject); &DeviceObject);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Failed to create named pipe device! (Status %x)\n", Status); DPRINT("Failed to create named pipe device! (Status %x)\n", Status);
return(Status); return(Status);
} }
RtlInitUnicodeString(&LinkName, L"\\??\\Pipe"); #if 0
/* FIXME: this should really be done by SMSS!! */
RtlInitUnicodeString(&LinkName, L"\\??\\PIPE");
Status = IoCreateSymbolicLink(&LinkName, Status = IoCreateSymbolicLink(&LinkName,
&DeviceName); &DeviceName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Failed to create named pipe symbolic link! (Status %x)\n", Status); DPRINT("Failed to create named pipe symbolic link! (Status %x)\n", Status);
// IoDeleteDevice(); // IoDeleteDevice();
return(Status); return(Status);
} }
#endif
NpfsInitPipeList(); /* initialize the device extension */
DeviceExtension = DeviceObject->DeviceExtension;
InitializeListHead(&DeviceExtension->PipeListHead);
KeInitializeMutex(&DeviceExtension->PipeListLock,
0);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
/* EOF */ /* EOF */

View file

@ -3,12 +3,13 @@
typedef struct typedef struct
{ {
PDEVICE_OBJECT StorageDevice; LIST_ENTRY PipeListHead;
KMUTEX PipeListLock;
} NPFS_DEVICE_EXTENSION, *PNPFS_DEVICE_EXTENSION; } NPFS_DEVICE_EXTENSION, *PNPFS_DEVICE_EXTENSION;
typedef struct typedef struct
{ {
PWCHAR Name; UNICODE_STRING PipeName;
LIST_ENTRY PipeListEntry; LIST_ENTRY PipeListEntry;
KSPIN_LOCK FcbListLock; KSPIN_LOCK FcbListLock;
LIST_ENTRY FcbListHead; LIST_ENTRY FcbListHead;
@ -28,9 +29,9 @@ typedef struct _NPFS_FCB
PNPFS_PIPE Pipe; PNPFS_PIPE Pipe;
struct _NPFS_FCB* OtherSide; struct _NPFS_FCB* OtherSide;
BOOLEAN IsServer; BOOLEAN IsServer;
KEVENT ConnectEvent;
} NPFS_FCB, *PNPFS_FCB; } NPFS_FCB, *PNPFS_FCB;
VOID NpfsPipeList(VOID);
#define KeLockMutex(x) KeWaitForSingleObject(x, \ #define KeLockMutex(x) KeWaitForSingleObject(x, \
UserRequest, \ UserRequest, \

View file

@ -81,18 +81,48 @@ NTSTATUS STDCALL ZwCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
IN ULONG OutBufferSize, IN ULONG OutBufferSize,
IN PLARGE_INTEGER DefaultTimeOut); IN PLARGE_INTEGER DefaultTimeOut);
#define FSCTL_PIPE_ASSIGN_EVENT \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define FSCTL_WAIT_PIPE \ #define FSCTL_PIPE_DISCONNECT \
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS) CTL_CODE(FILE_DEVICE_NAMED_PIPE, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define FSCTL_LISTEN \ #define FSCTL_PIPE_LISTEN \
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS) CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define FSCTL_SET_STATE \ #define FSCTL_PIPE_PEEK \
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS) CTL_CODE(FILE_DEVICE_NAMED_PIPE, 3, METHOD_BUFFERED, FILE_READ_DATA)
#define FSCTL_PIPE_QUERY_EVENT \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define FSCTL_PIPE_TRANSCEIVE \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 5, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
#define FSCTL_PIPE_WAIT \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define FSCTL_PIPE_IMPERSONATE \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define FSCTL_PIPE_SET_CLIENT_PROCESS \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define FSCTL_PIPE_QUERY_CLIENT_PROCESS \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define FSCTL_PIPE_INTERNAL_READ \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2045, METHOD_BUFFERED, FILE_READ_DATA)
#define FSCTL_PIPE_INTERNAL_WRITE \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2046, METHOD_BUFFERED, FILE_WRITE_DATA)
#define FSCTL_PIPE_INTERNAL_TRANSCEIVE \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2047, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
#define FSCTL_PIPE_INTERNAL_READ_OVFLOW \
CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2048, METHOD_BUFFERED, FILE_READ_DATA)
#define FSCTL_GET_STATE \
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
typedef struct _NPFS_WAIT_PIPE typedef struct _NPFS_WAIT_PIPE
{ {

View file

@ -1,4 +1,4 @@
/* $Id: npipe.c,v 1.4 2001/03/31 01:17:29 dwelch Exp $ /* $Id: npipe.c,v 1.5 2001/05/10 23:37:06 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -11,24 +11,25 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <windows.h>
#include <wchar.h>
#include <string.h>
#include <ntdll/rtl.h> #include <ntdll/rtl.h>
#include <windows.h>
//#include <wchar.h>
//#include <string.h>
#include <kernel32/kernel32.h> #include <kernel32/kernel32.h>
#include <kernel32/error.h> #include <kernel32/error.h>
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
HANDLE STDCALL CreateNamedPipeA(LPCSTR lpName, HANDLE STDCALL
DWORD dwOpenMode, CreateNamedPipeA(LPCSTR lpName,
DWORD dwPipeMode, DWORD dwOpenMode,
DWORD nMaxInstances, DWORD dwPipeMode,
DWORD nOutBufferSize, DWORD nMaxInstances,
DWORD nInBufferSize, DWORD nOutBufferSize,
DWORD nDefaultTimeOut, DWORD nInBufferSize,
LPSECURITY_ATTRIBUTES lpSecurityAttributes) DWORD nDefaultTimeOut,
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{ {
HANDLE NamedPipeHandle; HANDLE NamedPipeHandle;
UNICODE_STRING NameU; UNICODE_STRING NameU;
@ -51,14 +52,15 @@ HANDLE STDCALL CreateNamedPipeA(LPCSTR lpName,
return(NamedPipeHandle); return(NamedPipeHandle);
} }
HANDLE STDCALL CreateNamedPipeW(LPCWSTR lpName, HANDLE STDCALL
DWORD dwOpenMode, CreateNamedPipeW(LPCWSTR lpName,
DWORD dwPipeMode, DWORD dwOpenMode,
DWORD nMaxInstances, DWORD dwPipeMode,
DWORD nOutBufferSize, DWORD nMaxInstances,
DWORD nInBufferSize, DWORD nOutBufferSize,
DWORD nDefaultTimeOut, DWORD nInBufferSize,
LPSECURITY_ATTRIBUTES lpSecurityAttributes) DWORD nDefaultTimeOut,
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{ {
UNICODE_STRING NamedPipeName; UNICODE_STRING NamedPipeName;
BOOL Result; BOOL Result;
@ -79,15 +81,17 @@ HANDLE STDCALL CreateNamedPipeW(LPCWSTR lpName,
&NamedPipeName, &NamedPipeName,
NULL, NULL,
NULL); NULL);
if (!Result) if (!Result)
{ {
SetLastError(ERROR_PATH_NOT_FOUND);
return(INVALID_HANDLE_VALUE); return(INVALID_HANDLE_VALUE);
} }
DPRINT("Pipe name: %wZ\n", &NamedPipeName);
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&NamedPipeName, &NamedPipeName,
0, OBJ_CASE_INSENSITIVE,
NULL, NULL,
NULL); NULL);
@ -97,10 +101,10 @@ HANDLE STDCALL CreateNamedPipeW(LPCWSTR lpName,
CreateDisposition = FILE_OPEN_IF; CreateDisposition = FILE_OPEN_IF;
CreateOptions = 0; CreateOptions = 0;
if (dwOpenMode & FILE_FLAG_WRITE_THROUGH) if (dwOpenMode & FILE_FLAG_WRITE_THROUGH)
{ {
CreateOptions = CreateOptions | FILE_FLAG_WRITE_THROUGH; CreateOptions = CreateOptions | FILE_WRITE_THROUGH;
} }
if (dwOpenMode & FILE_FLAG_OVERLAPPED) if (dwOpenMode & FILE_FLAG_OVERLAPPED)
{ {
@ -146,8 +150,8 @@ HANDLE STDCALL CreateNamedPipeW(LPCWSTR lpName,
NonBlocking = FALSE; NonBlocking = FALSE;
} }
DefaultTimeOut.QuadPart = nDefaultTimeOut * 1000 * 1000; DefaultTimeOut.QuadPart = nDefaultTimeOut * 10000;
Status = NtCreateNamedPipeFile(&PipeHandle, Status = NtCreateNamedPipeFile(&PipeHandle,
DesiredAccess, DesiredAccess,
&ObjectAttributes, &ObjectAttributes,
@ -162,22 +166,28 @@ HANDLE STDCALL CreateNamedPipeW(LPCWSTR lpName,
nInBufferSize, nInBufferSize,
nOutBufferSize, nOutBufferSize,
&DefaultTimeOut); &DefaultTimeOut);
RtlFreeUnicodeString(&NamedPipeName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("NtCreateNamedPipe failed (Status %x)!\n", Status);
SetLastErrorByStatus (Status); SetLastErrorByStatus (Status);
return(INVALID_HANDLE_VALUE); return(INVALID_HANDLE_VALUE);
} }
return(PipeHandle); return(PipeHandle);
} }
BOOL STDCALL WaitNamedPipeA(LPCSTR lpNamedPipeName, BOOL STDCALL
DWORD nTimeOut) WaitNamedPipeA(LPCSTR lpNamedPipeName,
DWORD nTimeOut)
{ {
BOOL r; BOOL r;
UNICODE_STRING NameU; UNICODE_STRING NameU;
ANSI_STRING NameA; ANSI_STRING NameA;
RtlInitAnsiString(&NameA, lpNamedPipeName); RtlInitAnsiString(&NameA, (LPSTR)lpNamedPipeName);
RtlAnsiStringToUnicodeString(&NameU, &NameA, TRUE); RtlAnsiStringToUnicodeString(&NameU, &NameA, TRUE);
r = WaitNamedPipeW(NameU.Buffer, nTimeOut); r = WaitNamedPipeW(NameU.Buffer, nTimeOut);
@ -187,8 +197,9 @@ BOOL STDCALL WaitNamedPipeA(LPCSTR lpNamedPipeName,
return(r); return(r);
} }
BOOL STDCALL WaitNamedPipeW(LPCWSTR lpNamedPipeName, BOOL STDCALL
DWORD nTimeOut) WaitNamedPipeW(LPCWSTR lpNamedPipeName,
DWORD nTimeOut)
{ {
UNICODE_STRING NamedPipeName; UNICODE_STRING NamedPipeName;
BOOL r; BOOL r;
@ -198,7 +209,7 @@ BOOL STDCALL WaitNamedPipeW(LPCWSTR lpNamedPipeName,
HANDLE FileHandle; HANDLE FileHandle;
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
r = RtlDosPathNameToNtPathName_U(lpNamedPipeName, r = RtlDosPathNameToNtPathName_U((LPWSTR)lpNamedPipeName,
&NamedPipeName, &NamedPipeName,
NULL, NULL,
NULL); NULL);
@ -225,8 +236,9 @@ BOOL STDCALL WaitNamedPipeW(LPCWSTR lpNamedPipeName,
return(FALSE); return(FALSE);
} }
WaitPipe.Timeout.QuadPart = nTimeOut * 1000 * 1000; WaitPipe.Timeout.QuadPart = nTimeOut * 10000;
#if 0
Status = NtFsControlFile(FileHandle, Status = NtFsControlFile(FileHandle,
NULL, NULL,
NULL, NULL,
@ -242,27 +254,28 @@ BOOL STDCALL WaitNamedPipeW(LPCWSTR lpNamedPipeName,
SetLastErrorByStatus (Status); SetLastErrorByStatus (Status);
return(FALSE); return(FALSE);
} }
#endif
NtClose(FileHandle); NtClose(FileHandle);
return(TRUE); return(TRUE);
} }
BOOL STDCALL ConnectNamedPipe(HANDLE hNamedPipe, BOOL STDCALL
LPOVERLAPPED lpOverLapped) ConnectNamedPipe(HANDLE hNamedPipe,
LPOVERLAPPED lpOverlapped)
{ {
NPFS_LISTEN ListenPipe;
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
HANDLE hEvent; HANDLE hEvent;
PIO_STATUS_BLOCK IoStatusBlock; PIO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status; NTSTATUS Status;
if (lpOverLapped != NULL) if (lpOverlapped != NULL)
{ {
lpOverLapped->Internal = STATUS_PENDING; lpOverlapped->Internal = STATUS_PENDING;
hEvent = lpOverLapped->hEvent; hEvent = lpOverlapped->hEvent;
IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped; IoStatusBlock = (PIO_STATUS_BLOCK)lpOverlapped;
} }
else else
{ {
IoStatusBlock = &Iosb; IoStatusBlock = &Iosb;
hEvent = NULL; hEvent = NULL;
@ -273,12 +286,24 @@ BOOL STDCALL ConnectNamedPipe(HANDLE hNamedPipe,
NULL, NULL,
NULL, NULL,
IoStatusBlock, IoStatusBlock,
FSCTL_LISTEN, FSCTL_PIPE_LISTEN,
&ListenPipe, NULL,
sizeof(ListenPipe), 0,
NULL, NULL,
0); 0);
if (!NT_SUCCESS(Status)) if ((lpOverlapped == NULL) && (Status == STATUS_PENDING))
{
Status = NtWaitForSingleObject(hNamedPipe,
FALSE,
NULL);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return(FALSE);
}
Status = Iosb.Status;
}
if (!NT_SUCCESS(Status) || (Status == STATUS_PENDING))
{ {
SetLastErrorByStatus (Status); SetLastErrorByStatus (Status);
return(FALSE); return(FALSE);
@ -286,16 +311,18 @@ BOOL STDCALL ConnectNamedPipe(HANDLE hNamedPipe,
return(TRUE); return(TRUE);
} }
BOOL STDCALL SetNamedPipeHandleState(HANDLE hNamedPipe, BOOL STDCALL
LPDWORD lpMode, SetNamedPipeHandleState(HANDLE hNamedPipe,
LPDWORD lpMaxCollectionCount, LPDWORD lpMode,
LPDWORD lpCollectDataTimeout) LPDWORD lpMaxCollectionCount,
LPDWORD lpCollectDataTimeout)
{ {
NPFS_GET_STATE GetState; NPFS_GET_STATE GetState;
NPFS_SET_STATE SetState; NPFS_SET_STATE SetState;
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
NTSTATUS Status; NTSTATUS Status;
#if 0
Status = NtFsControlFile(hNamedPipe, Status = NtFsControlFile(hNamedPipe,
NULL, NULL,
NULL, NULL,
@ -311,6 +338,7 @@ BOOL STDCALL SetNamedPipeHandleState(HANDLE hNamedPipe,
SetLastErrorByStatus (Status); SetLastErrorByStatus (Status);
return(FALSE); return(FALSE);
} }
#endif
if (lpMode != NULL) if (lpMode != NULL)
{ {
@ -359,6 +387,7 @@ BOOL STDCALL SetNamedPipeHandleState(HANDLE hNamedPipe,
SetState.Timeout = GetState.Timeout; SetState.Timeout = GetState.Timeout;
} }
#if 0
Status = NtFsControlFile(hNamedPipe, Status = NtFsControlFile(hNamedPipe,
NULL, NULL,
NULL, NULL,
@ -374,6 +403,7 @@ BOOL STDCALL SetNamedPipeHandleState(HANDLE hNamedPipe,
SetLastErrorByStatus (Status); SetLastErrorByStatus (Status);
return(FALSE); return(FALSE);
} }
#endif
return(TRUE); return(TRUE);
} }
@ -394,8 +424,7 @@ CallNamedPipeA (
} }
WINBOOL WINBOOL STDCALL
STDCALL
CallNamedPipeW ( CallNamedPipeW (
LPCWSTR lpNamedPipeName, LPCWSTR lpNamedPipeName,
LPVOID lpInBuffer, LPVOID lpInBuffer,
@ -410,18 +439,45 @@ CallNamedPipeW (
return FALSE; return FALSE;
} }
WINBOOL
STDCALL WINBOOL STDCALL
DisconnectNamedPipe ( DisconnectNamedPipe(HANDLE hNamedPipe)
HANDLE hNamedPipe
)
{ {
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); IO_STATUS_BLOCK Iosb;
return FALSE; NTSTATUS Status;
Status = NtFsControlFile(hNamedPipe,
NULL,
NULL,
NULL,
&Iosb,
FSCTL_PIPE_DISCONNECT,
NULL,
0,
NULL,
0);
if (Status == STATUS_PENDING)
{
Status = NtWaitForSingleObject(hNamedPipe,
FALSE,
NULL);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return(FALSE);
}
}
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return(FALSE);
}
return(TRUE);
} }
WINBOOL
STDCALL WINBOOL STDCALL
GetNamedPipeHandleStateW ( GetNamedPipeHandleStateW (
HANDLE hNamedPipe, HANDLE hNamedPipe,
LPDWORD lpState, LPDWORD lpState,
@ -437,8 +493,7 @@ GetNamedPipeHandleStateW (
} }
WINBOOL WINBOOL STDCALL
STDCALL
GetNamedPipeHandleStateA ( GetNamedPipeHandleStateA (
HANDLE hNamedPipe, HANDLE hNamedPipe,
LPDWORD lpState, LPDWORD lpState,
@ -454,50 +509,42 @@ GetNamedPipeHandleStateA (
} }
WINBOOL WINBOOL STDCALL
STDCALL GetNamedPipeInfo(HANDLE hNamedPipe,
GetNamedPipeInfo ( LPDWORD lpFlags,
HANDLE hNamedPipe, LPDWORD lpOutBufferSize,
LPDWORD lpFlags, LPDWORD lpInBufferSize,
LPDWORD lpOutBufferSize, LPDWORD lpMaxInstances)
LPDWORD lpInBufferSize,
LPDWORD lpMaxInstances
)
{ {
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE; return FALSE;
} }
WINBOOL
STDCALL WINBOOL STDCALL
PeekNamedPipe ( PeekNamedPipe(HANDLE hNamedPipe,
HANDLE hNamedPipe, LPVOID lpBuffer,
LPVOID lpBuffer, DWORD nBufferSize,
DWORD nBufferSize, LPDWORD lpBytesRead,
LPDWORD lpBytesRead, LPDWORD lpTotalBytesAvail,
LPDWORD lpTotalBytesAvail, LPDWORD lpBytesLeftThisMessage)
LPDWORD lpBytesLeftThisMessage
)
{ {
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE; return FALSE;
} }
WINBOOL
STDCALL WINBOOL STDCALL
TransactNamedPipe ( TransactNamedPipe(HANDLE hNamedPipe,
HANDLE hNamedPipe, LPVOID lpInBuffer,
LPVOID lpInBuffer, DWORD nInBufferSize,
DWORD nInBufferSize, LPVOID lpOutBuffer,
LPVOID lpOutBuffer, DWORD nOutBufferSize,
DWORD nOutBufferSize, LPDWORD lpBytesRead,
LPDWORD lpBytesRead, LPOVERLAPPED lpOverlapped)
LPOVERLAPPED lpOverlapped
)
{ {
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE; return FALSE;
} }
/* EOF */ /* EOF */