mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Revert 18883 and 18912, as they break named pipes
(These changes were correct per se, but another problem surfaced: see http://www.reactos.org/archives/public/ros-dev/2005-November/005958.html) svn path=/trunk/; revision=19002
This commit is contained in:
parent
923e4546ba
commit
76c3fa7451
3 changed files with 122 additions and 81 deletions
|
@ -113,6 +113,7 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
PNPFS_FCB ClientFcb;
|
PNPFS_FCB ClientFcb;
|
||||||
PNPFS_FCB ServerFcb = NULL;
|
PNPFS_FCB ServerFcb = NULL;
|
||||||
PNPFS_DEVICE_EXTENSION DeviceExt;
|
PNPFS_DEVICE_EXTENSION DeviceExt;
|
||||||
|
BOOLEAN SpecialAccess;
|
||||||
|
|
||||||
DPRINT("NpfsCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
|
DPRINT("NpfsCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
|
||||||
|
|
||||||
|
@ -124,6 +125,12 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
|
|
||||||
|
SpecialAccess = ((IoStack->Parameters.CreatePipe.ShareAccess & 3) == 3);
|
||||||
|
if (SpecialAccess)
|
||||||
|
{
|
||||||
|
DPRINT("NpfsCreate() open client end for special use!\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Step 1. Find the pipe we're trying to open.
|
* Step 1. Find the pipe we're trying to open.
|
||||||
*/
|
*/
|
||||||
|
@ -165,7 +172,7 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
ClientFcb->Pipe = Pipe;
|
ClientFcb->Pipe = Pipe;
|
||||||
ClientFcb->PipeEnd = FILE_PIPE_CLIENT_END;
|
ClientFcb->PipeEnd = FILE_PIPE_CLIENT_END;
|
||||||
ClientFcb->OtherSide = NULL;
|
ClientFcb->OtherSide = NULL;
|
||||||
ClientFcb->PipeState = FILE_PIPE_DISCONNECTED_STATE;
|
ClientFcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE;
|
||||||
InitializeListHead(&ClientFcb->ReadRequestListHead);
|
InitializeListHead(&ClientFcb->ReadRequestListHead);
|
||||||
|
|
||||||
DPRINT("Fcb: %x\n", ClientFcb);
|
DPRINT("Fcb: %x\n", ClientFcb);
|
||||||
|
@ -204,6 +211,8 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
* Step 3. Search for listening server FCB.
|
* Step 3. Search for listening server FCB.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!SpecialAccess)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* WARNING: Point of no return! Once we get the server FCB it's
|
* WARNING: Point of no return! Once we get the server FCB it's
|
||||||
* possible that we completed a wait request and so we have to
|
* possible that we completed a wait request and so we have to
|
||||||
|
@ -244,9 +253,9 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
if (ClientFcb->Data)
|
if (ClientFcb->Data)
|
||||||
ExFreePool(ClientFcb->Data);
|
ExFreePool(ClientFcb->Data);
|
||||||
KeUnlockMutex(&Pipe->FcbListLock);
|
KeUnlockMutex(&Pipe->FcbListLock);
|
||||||
Irp->IoStatus.Status = STATUS_PIPE_NOT_AVAILABLE;
|
Irp->IoStatus.Status = STATUS_PIPE_BUSY;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return STATUS_PIPE_NOT_AVAILABLE;
|
return STATUS_PIPE_BUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -255,6 +264,15 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
/* FIXME: Merge this with the NpfsFindListeningServerInstance routine. */
|
/* FIXME: Merge this with the NpfsFindListeningServerInstance routine. */
|
||||||
NpfsSignalAndRemoveListeningServerInstance(Pipe, ServerFcb);
|
NpfsSignalAndRemoveListeningServerInstance(Pipe, ServerFcb);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (IsListEmpty(&Pipe->ServerFcbListHead))
|
||||||
|
{
|
||||||
|
DPRINT("No server fcb found!\n");
|
||||||
|
KeUnlockMutex(&Pipe->FcbListLock);
|
||||||
|
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Step 4. Add the client FCB to a list and connect it if possible.
|
* Step 4. Add the client FCB to a list and connect it if possible.
|
||||||
|
|
|
@ -15,12 +15,6 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include "../include/debug.h"
|
#include "../include/debug.h"
|
||||||
|
|
||||||
/* FIXME - defined in ntifs.h */
|
|
||||||
#if !defined(FILE_PIPE_BYTE_STREAM_TYPE) && !defined(FILE_PIPE_MESSAGE_TYPE)
|
|
||||||
#define FILE_PIPE_BYTE_STREAM_TYPE 0x00000000
|
|
||||||
#define FILE_PIPE_MESSAGE_TYPE 0x00000001
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -78,6 +72,7 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
HANDLE PipeHandle;
|
HANDLE PipeHandle;
|
||||||
ACCESS_MASK DesiredAccess;
|
ACCESS_MASK DesiredAccess;
|
||||||
ULONG CreateOptions;
|
ULONG CreateOptions;
|
||||||
|
ULONG CreateDisposition;
|
||||||
ULONG WriteModeMessage;
|
ULONG WriteModeMessage;
|
||||||
ULONG ReadModeMessage;
|
ULONG ReadModeMessage;
|
||||||
ULONG NonBlocking;
|
ULONG NonBlocking;
|
||||||
|
@ -86,12 +81,6 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
LARGE_INTEGER DefaultTimeOut;
|
LARGE_INTEGER DefaultTimeOut;
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
|
PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
|
||||||
|
|
||||||
if (nMaxInstances == 0 || nMaxInstances > PIPE_UNLIMITED_INSTANCES)
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
return INVALID_HANDLE_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result = RtlDosPathNameToNtPathName_U((LPWSTR)lpName,
|
Result = RtlDosPathNameToNtPathName_U((LPWSTR)lpName,
|
||||||
&NamedPipeName,
|
&NamedPipeName,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -119,40 +108,77 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
NULL,
|
NULL,
|
||||||
SecurityDescriptor);
|
SecurityDescriptor);
|
||||||
|
|
||||||
DesiredAccess = SYNCHRONIZE | (dwOpenMode & (WRITE_DAC | WRITE_OWNER | ACCESS_SYSTEM_SECURITY));
|
DesiredAccess = 0;
|
||||||
ShareAccess = 0;
|
ShareAccess = 0;
|
||||||
|
CreateDisposition = FILE_OPEN_IF;
|
||||||
CreateOptions = 0;
|
CreateOptions = 0;
|
||||||
|
|
||||||
if (dwOpenMode & FILE_FLAG_WRITE_THROUGH)
|
if (dwOpenMode & FILE_FLAG_WRITE_THROUGH)
|
||||||
CreateOptions |= FILE_WRITE_THROUGH;
|
{
|
||||||
|
CreateOptions = CreateOptions | FILE_WRITE_THROUGH;
|
||||||
|
}
|
||||||
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED))
|
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED))
|
||||||
CreateOptions |= FILE_SYNCHRONOUS_IO_NONALERT;
|
|
||||||
|
|
||||||
if (dwOpenMode & PIPE_ACCESS_INBOUND)
|
|
||||||
{
|
{
|
||||||
ShareAccess |= FILE_SHARE_WRITE;
|
CreateOptions = CreateOptions | FILE_SYNCHRONOUS_IO_NONALERT;
|
||||||
DesiredAccess |= GENERIC_READ;
|
|
||||||
}
|
}
|
||||||
if (dwOpenMode & PIPE_ACCESS_OUTBOUND)
|
if (dwOpenMode & PIPE_ACCESS_DUPLEX)
|
||||||
{
|
{
|
||||||
ShareAccess |= FILE_SHARE_READ;
|
CreateOptions = CreateOptions | FILE_PIPE_FULL_DUPLEX;
|
||||||
DesiredAccess |= GENERIC_WRITE;
|
DesiredAccess |= (FILE_GENERIC_READ | FILE_GENERIC_WRITE);
|
||||||
|
}
|
||||||
|
else if (dwOpenMode & PIPE_ACCESS_INBOUND)
|
||||||
|
{
|
||||||
|
CreateOptions = CreateOptions | FILE_PIPE_INBOUND;
|
||||||
|
DesiredAccess |= FILE_GENERIC_READ;
|
||||||
|
}
|
||||||
|
else if (dwOpenMode & PIPE_ACCESS_OUTBOUND)
|
||||||
|
{
|
||||||
|
CreateOptions = CreateOptions | FILE_PIPE_OUTBOUND;
|
||||||
|
DesiredAccess |= FILE_GENERIC_WRITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dwPipeMode & PIPE_TYPE_MESSAGE)
|
if (dwPipeMode & PIPE_TYPE_BYTE)
|
||||||
WriteModeMessage = FILE_PIPE_MESSAGE_TYPE;
|
{
|
||||||
|
WriteModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
|
||||||
|
}
|
||||||
|
else if (dwPipeMode & PIPE_TYPE_MESSAGE)
|
||||||
|
{
|
||||||
|
WriteModeMessage = FILE_PIPE_MESSAGE_MODE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
WriteModeMessage = FILE_PIPE_BYTE_STREAM_TYPE;
|
{
|
||||||
|
WriteModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
if (dwPipeMode & PIPE_READMODE_MESSAGE)
|
if (dwPipeMode & PIPE_READMODE_BYTE)
|
||||||
ReadModeMessage = FILE_PIPE_MESSAGE_MODE;
|
{
|
||||||
else
|
|
||||||
ReadModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
|
ReadModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
|
||||||
|
}
|
||||||
if (dwPipeMode & PIPE_NOWAIT)
|
else if (dwPipeMode & PIPE_READMODE_MESSAGE)
|
||||||
NonBlocking = FILE_PIPE_COMPLETE_OPERATION;
|
{
|
||||||
|
ReadModeMessage = FILE_PIPE_MESSAGE_MODE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
ReadModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dwPipeMode & PIPE_WAIT)
|
||||||
|
{
|
||||||
NonBlocking = FILE_PIPE_QUEUE_OPERATION;
|
NonBlocking = FILE_PIPE_QUEUE_OPERATION;
|
||||||
|
}
|
||||||
|
else if (dwPipeMode & PIPE_NOWAIT)
|
||||||
|
{
|
||||||
|
NonBlocking = FILE_PIPE_COMPLETE_OPERATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NonBlocking = FILE_PIPE_QUEUE_OPERATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nMaxInstances >= PIPE_UNLIMITED_INSTANCES)
|
||||||
|
{
|
||||||
|
nMaxInstances = 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
DefaultTimeOut.QuadPart = nDefaultTimeOut * -10000LL;
|
DefaultTimeOut.QuadPart = nDefaultTimeOut * -10000LL;
|
||||||
|
|
||||||
|
@ -161,7 +187,7 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
&Iosb,
|
&Iosb,
|
||||||
ShareAccess,
|
ShareAccess,
|
||||||
FILE_OPEN_IF,
|
CreateDisposition,
|
||||||
CreateOptions,
|
CreateOptions,
|
||||||
WriteModeMessage,
|
WriteModeMessage,
|
||||||
ReadModeMessage,
|
ReadModeMessage,
|
||||||
|
|
|
@ -59,9 +59,6 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
||||||
Attributes |= OBJ_INHERIT;
|
Attributes |= OBJ_INHERIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use default buffer size if desired */
|
|
||||||
if (nSize == 0) nSize = 0x1000;
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&PipeName,
|
&PipeName,
|
||||||
Attributes,
|
Attributes,
|
||||||
|
@ -69,7 +66,7 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
||||||
SecurityDescriptor);
|
SecurityDescriptor);
|
||||||
|
|
||||||
Status = NtCreateNamedPipeFile(&ReadPipeHandle,
|
Status = NtCreateNamedPipeFile(&ReadPipeHandle,
|
||||||
FILE_GENERIC_READ | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
|
FILE_GENERIC_READ,
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
&StatusBlock,
|
&StatusBlock,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
@ -89,10 +86,10 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = NtOpenFile(&WritePipeHandle,
|
Status = NtOpenFile(&WritePipeHandle,
|
||||||
FILE_GENERIC_WRITE | SYNCHRONIZE,
|
FILE_GENERIC_WRITE,
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
&StatusBlock,
|
&StatusBlock,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
0,
|
||||||
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
|
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue