mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Use the share disposition to detect the direction of a pipe.
svn path=/trunk/; revision=19021
This commit is contained in:
parent
4af01faa3c
commit
e087024bb5
3 changed files with 38 additions and 30 deletions
|
@ -329,6 +329,14 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
if (!(IoStack->Parameters.CreatePipe.ShareAccess & (FILE_SHARE_READ|FILE_SHARE_WRITE)) ||
|
||||
(IoStack->Parameters.CreatePipe.ShareAccess & ~(FILE_SHARE_READ|FILE_SHARE_WRITE)))
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
|
||||
if (Fcb == NULL)
|
||||
{
|
||||
|
@ -411,12 +419,23 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
|
|||
Pipe->WriteMode = Buffer->ReadMode;
|
||||
Pipe->ReadMode = Buffer->ReadMode;
|
||||
Pipe->CompletionMode = Buffer->CompletionMode;
|
||||
Pipe->PipeConfiguration = IoStack->Parameters.CreatePipe.Options & 0x3;
|
||||
switch (IoStack->Parameters.CreatePipe.ShareAccess & (FILE_SHARE_READ|FILE_SHARE_WRITE))
|
||||
{
|
||||
case FILE_SHARE_READ:
|
||||
Pipe->PipeConfiguration = FILE_PIPE_OUTBOUND;
|
||||
break;
|
||||
case FILE_SHARE_WRITE:
|
||||
Pipe->PipeConfiguration = FILE_PIPE_INBOUND;
|
||||
break;
|
||||
case FILE_SHARE_READ|FILE_SHARE_WRITE:
|
||||
Pipe->PipeConfiguration = FILE_PIPE_FULL_DUPLEX;
|
||||
break;
|
||||
}
|
||||
Pipe->MaximumInstances = Buffer->MaximumInstances;
|
||||
Pipe->CurrentInstances = 0;
|
||||
Pipe->TimeOut = Buffer->DefaultTimeout;
|
||||
if (!(IoStack->Parameters.CreatePipe.Options & FILE_PIPE_OUTBOUND) ||
|
||||
IoStack->Parameters.CreatePipe.Options & FILE_PIPE_FULL_DUPLEX)
|
||||
if (!(Pipe->PipeConfiguration & FILE_PIPE_OUTBOUND) ||
|
||||
Pipe->PipeConfiguration & FILE_PIPE_FULL_DUPLEX)
|
||||
{
|
||||
if (Buffer->InboundQuota == 0)
|
||||
{
|
||||
|
@ -440,7 +459,7 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
|
|||
Pipe->InboundQuota = 0;
|
||||
}
|
||||
|
||||
if (IoStack->Parameters.CreatePipe.Options & (FILE_PIPE_FULL_DUPLEX|FILE_PIPE_OUTBOUND))
|
||||
if (Pipe->PipeConfiguration & (FILE_PIPE_FULL_DUPLEX|FILE_PIPE_OUTBOUND))
|
||||
{
|
||||
if (Buffer->OutboundQuota == 0)
|
||||
{
|
||||
|
|
|
@ -123,27 +123,16 @@ CreateNamedPipeW(LPCWSTR lpName,
|
|||
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED))
|
||||
CreateOptions = CreateOptions | FILE_SYNCHRONOUS_IO_NONALERT;
|
||||
|
||||
switch (dwOpenMode & PIPE_ACCESS_DUPLEX)
|
||||
if (dwOpenMode & PIPE_ACCESS_OUTBOUND)
|
||||
{
|
||||
case PIPE_ACCESS_INBOUND:
|
||||
CreateOptions |= FILE_PIPE_INBOUND;
|
||||
ShareAccess |= FILE_SHARE_WRITE;
|
||||
DesiredAccess |= GENERIC_READ;
|
||||
break;
|
||||
|
||||
case PIPE_ACCESS_OUTBOUND:
|
||||
CreateOptions |= FILE_PIPE_OUTBOUND;
|
||||
ShareAccess |= FILE_SHARE_READ;
|
||||
DesiredAccess |= GENERIC_WRITE;
|
||||
break;
|
||||
|
||||
case PIPE_ACCESS_DUPLEX:
|
||||
CreateOptions |= FILE_PIPE_FULL_DUPLEX;
|
||||
ShareAccess |= (FILE_SHARE_READ | FILE_SHARE_WRITE);
|
||||
DesiredAccess |= (GENERIC_READ | GENERIC_WRITE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (dwOpenMode & PIPE_ACCESS_INBOUND)
|
||||
{
|
||||
ShareAccess |= FILE_SHARE_WRITE;
|
||||
DesiredAccess |= GENERIC_READ;
|
||||
}
|
||||
if (dwPipeMode & PIPE_TYPE_MESSAGE)
|
||||
WriteModeMessage = FILE_PIPE_MESSAGE_MODE;
|
||||
else
|
||||
|
|
|
@ -41,11 +41,11 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
|||
ULONG Attributes;
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
|
||||
|
||||
DefaultTimeout.QuadPart = 300000000; /* 30 seconds */
|
||||
DefaultTimeout.QuadPart = -300000000; /* 30 seconds */
|
||||
|
||||
PipeId = (ULONG)InterlockedIncrement((LONG*)&ProcessPipeId);
|
||||
swprintf(Buffer,
|
||||
L"\\Device\\NamedPipe\\Win32Pipes.%08x.%08x",
|
||||
L"\\\\.\\PIPE\\Win32Pipes.%08x.%08x",
|
||||
NtCurrentTeb()->Cid.UniqueProcess,
|
||||
PipeId);
|
||||
RtlInitUnicodeString (&PipeName,
|
||||
|
@ -73,7 +73,7 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
|||
FILE_GENERIC_READ |FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
&StatusBlock,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
FILE_SHARE_WRITE,
|
||||
FILE_CREATE,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT,
|
||||
FALSE,
|
||||
|
@ -93,8 +93,8 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
|||
FILE_GENERIC_WRITE | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
&StatusBlock,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
|
||||
FILE_SHARE_READ,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
NtClose(ReadPipeHandle);
|
||||
|
|
Loading…
Reference in a new issue