mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 20:23:34 +00:00
- npfs.h: The member named WriteMode is meaningless for pipes, as the write mode is the PipeType for both client and server. Change names to something more descriptive,ServerReadMode and ClientReadMode, for the members new use.
- create.c: Use new members. - finfo.c: Check whether the pipe side is server or client and change/return appropriate ReadMode. - fsctrl.c: Opps. Previous implementation was pretty much correct. - rw.c: Silence debug message and use new members. Add multiple checks on whether pipe side is server or client and use appropriate ReadMode. If handling the next Irp in NpfsRead, remove the cancel routine before continuing the loop. Fixes BugCheck when running ntdll_winetest for file. Thank Christoph von Wittich for pointing this out. svn path=/trunk/; revision=38986
This commit is contained in:
parent
2e3d23a37d
commit
d5823b702a
5 changed files with 60 additions and 36 deletions
|
@ -420,10 +420,9 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
|
||||||
KeInitializeMutex(&Fcb->CcbListLock, 0);
|
KeInitializeMutex(&Fcb->CcbListLock, 0);
|
||||||
|
|
||||||
Fcb->PipeType = Buffer->NamedPipeType;
|
Fcb->PipeType = Buffer->NamedPipeType;
|
||||||
/* FIXME: Verify which is correct */
|
Fcb->ServerReadMode = Buffer->ReadMode;
|
||||||
Fcb->WriteMode = Buffer->ReadMode;//Buffer->NamedPipeType;
|
|
||||||
/* MSDN documentation reads that clients always start off in byte mode */
|
/* MSDN documentation reads that clients always start off in byte mode */
|
||||||
Fcb->ReadMode = FILE_PIPE_BYTE_STREAM_MODE;
|
Fcb->ClientReadMode = FILE_PIPE_BYTE_STREAM_MODE;
|
||||||
|
|
||||||
Fcb->CompletionMode = Buffer->CompletionMode;
|
Fcb->CompletionMode = Buffer->CompletionMode;
|
||||||
switch (IoStack->Parameters.CreatePipe.ShareAccess & (FILE_SHARE_READ|FILE_SHARE_WRITE))
|
switch (IoStack->Parameters.CreatePipe.ShareAccess & (FILE_SHARE_READ|FILE_SHARE_WRITE))
|
||||||
|
|
|
@ -35,9 +35,17 @@ NpfsSetPipeInformation(PDEVICE_OBJECT DeviceObject,
|
||||||
DPRINT("Cannot change readmode to message type on a byte type pipe!\n");
|
DPRINT("Cannot change readmode to message type on a byte type pipe!\n");
|
||||||
return STATUS_ACCESS_DENIED;
|
return STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set Pipe Data */
|
/* Set Pipe Data */
|
||||||
Fcb->ReadMode = Request->ReadMode;
|
if (Ccb->PipeEnd == FILE_PIPE_CLIENT_END)
|
||||||
|
{
|
||||||
|
Fcb->ClientReadMode = Request->ReadMode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Fcb->ServerReadMode = Request->ReadMode;
|
||||||
|
}
|
||||||
|
|
||||||
Fcb->CompletionMode = Request->CompletionMode;
|
Fcb->CompletionMode = Request->CompletionMode;
|
||||||
|
|
||||||
/* Return Success */
|
/* Return Success */
|
||||||
|
@ -75,6 +83,7 @@ NpfsQueryPipeInformation(PDEVICE_OBJECT DeviceObject,
|
||||||
PULONG BufferLength)
|
PULONG BufferLength)
|
||||||
{
|
{
|
||||||
PNPFS_FCB Fcb;
|
PNPFS_FCB Fcb;
|
||||||
|
ULONG ConnectionSideReadMode;
|
||||||
DPRINT("NpfsQueryPipeInformation()\n");
|
DPRINT("NpfsQueryPipeInformation()\n");
|
||||||
|
|
||||||
/* Get the Pipe */
|
/* Get the Pipe */
|
||||||
|
@ -82,10 +91,14 @@ NpfsQueryPipeInformation(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
/* Clear Info */
|
/* Clear Info */
|
||||||
RtlZeroMemory(Info, sizeof(FILE_PIPE_INFORMATION));
|
RtlZeroMemory(Info, sizeof(FILE_PIPE_INFORMATION));
|
||||||
|
|
||||||
|
|
||||||
|
if (Ccb->PipeEnd == FILE_PIPE_CLIENT_END) ConnectionSideReadMode=Ccb->Fcb->ClientReadMode;
|
||||||
|
else ConnectionSideReadMode = Ccb->Fcb->ServerReadMode;
|
||||||
|
|
||||||
/* Return Info */
|
/* Return Info */
|
||||||
Info->CompletionMode = Fcb->CompletionMode;
|
Info->CompletionMode = Fcb->CompletionMode;
|
||||||
Info->ReadMode = Fcb->ReadMode;
|
Info->ReadMode = ConnectionSideReadMode;
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
*BufferLength -= sizeof(FILE_PIPE_INFORMATION);
|
*BufferLength -= sizeof(FILE_PIPE_INFORMATION);
|
||||||
|
|
|
@ -432,28 +432,14 @@ NpfsPeekPipe(PIRP Irp,
|
||||||
ReadDataAvailable -= MessageLength;
|
ReadDataAvailable -= MessageLength;
|
||||||
MessageCount++;
|
MessageCount++;
|
||||||
|
|
||||||
if (Ccb->Fcb->ReadMode == FILE_PIPE_BYTE_STREAM_MODE)
|
/* If its the first message, copy the Message if the size of buffer is large enough */
|
||||||
{
|
if (MessageCount==1)
|
||||||
|
{
|
||||||
if ((Reply->Data[0])
|
if ((Reply->Data[0])
|
||||||
&& (OutputBufferLength >= (MessageLength + ReturnLength + FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))))
|
&& (OutputBufferLength >= (MessageLength + FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))))
|
||||||
{
|
{
|
||||||
memcpy((PVOID)((ULONG_PTR)&Reply->Data[0] + ReturnLength),
|
memcpy(&Reply->Data[0], (PVOID)((ULONG)BufferPtr + sizeof(MessageLength)), MessageLength);
|
||||||
(PVOID)((ULONG)BufferPtr + sizeof(MessageLength)),
|
ReturnLength = MessageLength;
|
||||||
MessageLength);
|
|
||||||
ReturnLength += MessageLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* If its the first message, copy the Message if the size of buffer is large enough */
|
|
||||||
if (MessageCount==1)
|
|
||||||
{
|
|
||||||
if ((Reply->Data[0])
|
|
||||||
&& (OutputBufferLength >= (MessageLength + FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))))
|
|
||||||
{
|
|
||||||
memcpy(&Reply->Data[0], (PVOID)((ULONG)BufferPtr + sizeof(MessageLength)), MessageLength);
|
|
||||||
ReturnLength = MessageLength;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ typedef struct _NPFS_FCB
|
||||||
LIST_ENTRY WaiterListHead;
|
LIST_ENTRY WaiterListHead;
|
||||||
LIST_ENTRY EmptyBufferListHead;
|
LIST_ENTRY EmptyBufferListHead;
|
||||||
ULONG PipeType;
|
ULONG PipeType;
|
||||||
ULONG ReadMode;
|
ULONG ClientReadMode;
|
||||||
ULONG WriteMode;
|
ULONG ServerReadMode;
|
||||||
ULONG CompletionMode;
|
ULONG CompletionMode;
|
||||||
ULONG PipeConfiguration;
|
ULONG PipeConfiguration;
|
||||||
ULONG MaximumInstances;
|
ULONG MaximumInstances;
|
||||||
|
|
|
@ -346,7 +346,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
if (Ccb->Data == NULL)
|
if (Ccb->Data == NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("Pipe is NOT readable!\n");
|
DPRINT("Pipe is NOT readable!\n");
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -426,13 +426,18 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
||||||
{
|
{
|
||||||
if (Ccb->ReadDataAvailable == 0)
|
if (Ccb->ReadDataAvailable == 0)
|
||||||
{
|
{
|
||||||
|
ULONG ConnectionSideReadMode;
|
||||||
|
|
||||||
|
if (Ccb->PipeEnd == FILE_PIPE_CLIENT_END) ConnectionSideReadMode=Ccb->Fcb->ClientReadMode;
|
||||||
|
else ConnectionSideReadMode = Ccb->Fcb->ServerReadMode;
|
||||||
|
|
||||||
if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE)
|
if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE)
|
||||||
{
|
{
|
||||||
ASSERT(Ccb->OtherSide != NULL);
|
ASSERT(Ccb->OtherSide != NULL);
|
||||||
KeSetEvent(&Ccb->OtherSide->WriteEvent, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(&Ccb->OtherSide->WriteEvent, IO_NO_INCREMENT, FALSE);
|
||||||
}
|
}
|
||||||
if (Information > 0 &&
|
if (Information > 0 &&
|
||||||
(Ccb->Fcb->ReadMode != FILE_PIPE_BYTE_STREAM_MODE ||
|
(ConnectionSideReadMode != FILE_PIPE_BYTE_STREAM_MODE ||
|
||||||
Ccb->PipeState != FILE_PIPE_CONNECTED_STATE))
|
Ccb->PipeState != FILE_PIPE_CONNECTED_STATE))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -473,7 +478,6 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
||||||
Context = (PNPFS_CONTEXT)&Irp->Tail.Overlay.DriverContext;
|
Context = (PNPFS_CONTEXT)&Irp->Tail.Overlay.DriverContext;
|
||||||
|
|
||||||
Context->WaitEvent = &Ccb->ReadEvent;
|
Context->WaitEvent = &Ccb->ReadEvent;
|
||||||
|
|
||||||
Status = NpfsAddWaitingReadWriteRequest(DeviceObject, Irp);
|
Status = NpfsAddWaitingReadWriteRequest(DeviceObject, Irp);
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
|
@ -488,7 +492,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
||||||
ASSERT(IoGetCurrentIrpStackLocation(Irp)->FileObject != NULL);
|
ASSERT(IoGetCurrentIrpStackLocation(Irp)->FileObject != NULL);
|
||||||
|
|
||||||
/* If the pipe type and read mode are both byte stream */
|
/* If the pipe type and read mode are both byte stream */
|
||||||
if ((Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE) && (Ccb->Fcb->ReadMode == FILE_PIPE_BYTE_STREAM_MODE))
|
if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE)
|
||||||
{
|
{
|
||||||
DPRINT("Byte stream mode: Ccb->Data %x\n", Ccb->Data);
|
DPRINT("Byte stream mode: Ccb->Data %x\n", Ccb->Data);
|
||||||
/* Byte stream mode */
|
/* Byte stream mode */
|
||||||
|
@ -613,7 +617,12 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
if (Information > 0)
|
if (Information > 0)
|
||||||
{
|
{
|
||||||
if ((Ccb->Fcb->ReadMode == FILE_PIPE_BYTE_STREAM_MODE) && (Ccb->ReadDataAvailable) && (Length > CopyLength))
|
ULONG ConnectionSideReadMode;
|
||||||
|
|
||||||
|
if (Ccb->PipeEnd == FILE_PIPE_CLIENT_END) ConnectionSideReadMode=Ccb->Fcb->ClientReadMode;
|
||||||
|
else ConnectionSideReadMode = Ccb->Fcb->ServerReadMode;
|
||||||
|
|
||||||
|
if ((ConnectionSideReadMode == FILE_PIPE_BYTE_STREAM_MODE) && (Ccb->ReadDataAvailable) && (Length > CopyLength))
|
||||||
{
|
{
|
||||||
Buffer = (PVOID)((ULONG_PTR)Buffer + CopyLength);
|
Buffer = (PVOID)((ULONG_PTR)Buffer + CopyLength);
|
||||||
Length -= CopyLength;
|
Length -= CopyLength;
|
||||||
|
@ -660,6 +669,8 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
KIRQL oldIrql;
|
||||||
|
|
||||||
if (IsOriginalRequest)
|
if (IsOriginalRequest)
|
||||||
{
|
{
|
||||||
IsOriginalRequest = FALSE;
|
IsOriginalRequest = FALSE;
|
||||||
|
@ -679,8 +690,23 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
||||||
DPRINT("NpfsRead done (Status %lx)\n", OriginalStatus);
|
DPRINT("NpfsRead done (Status %lx)\n", OriginalStatus);
|
||||||
return OriginalStatus;
|
return OriginalStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IoAcquireCancelSpinLock(&oldIrql);
|
||||||
Context = CONTAINING_RECORD(Ccb->ReadRequestListHead.Flink, NPFS_CONTEXT, ListEntry);
|
Context = CONTAINING_RECORD(Ccb->ReadRequestListHead.Flink, NPFS_CONTEXT, ListEntry);
|
||||||
|
|
||||||
Irp = CONTAINING_RECORD(Context, IRP, Tail.Overlay.DriverContext);
|
Irp = CONTAINING_RECORD(Context, IRP, Tail.Overlay.DriverContext);
|
||||||
|
/* Verify the Irp wasnt cancelled */
|
||||||
|
if (Irp->Cancel)
|
||||||
|
{
|
||||||
|
IoReleaseCancelSpinLock(oldIrql);
|
||||||
|
RemoveEntryList(&Context->ListEntry);
|
||||||
|
ExReleaseFastMutex(&Ccb->DataListLock);
|
||||||
|
Status = STATUS_CANCELLED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
/* The Irp will now be handled, so remove the CancelRoutine */
|
||||||
|
(void)IoSetCancelRoutine(Irp, NULL);
|
||||||
|
IoReleaseCancelSpinLock(oldIrql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,7 +836,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
ExAcquireFastMutex(&ReaderCcb->DataListLock);
|
ExAcquireFastMutex(&ReaderCcb->DataListLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE) && (Ccb->Fcb->WriteMode == FILE_PIPE_BYTE_STREAM_MODE))
|
if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE)
|
||||||
{
|
{
|
||||||
DPRINT("Byte stream mode: Ccb->Data %x, Ccb->WritePtr %x\n", ReaderCcb->Data, ReaderCcb->WritePtr);
|
DPRINT("Byte stream mode: Ccb->Data %x, Ccb->WritePtr %x\n", ReaderCcb->Data, ReaderCcb->WritePtr);
|
||||||
|
|
||||||
|
@ -853,7 +879,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((Ccb->Fcb->PipeType == FILE_PIPE_MESSAGE_TYPE) && (Ccb->Fcb->WriteMode == FILE_PIPE_MESSAGE_MODE))
|
else if (Ccb->Fcb->PipeType == FILE_PIPE_MESSAGE_TYPE)
|
||||||
{
|
{
|
||||||
/* For Message Type Pipe, the Pipes memory will be used to store the size of each message */
|
/* For Message Type Pipe, the Pipes memory will be used to store the size of each message */
|
||||||
DPRINT("Message mode: Ccb->Data %x, Ccb->WritePtr %x\n",ReaderCcb->Data, ReaderCcb->WritePtr);
|
DPRINT("Message mode: Ccb->Data %x, Ccb->WritePtr %x\n",ReaderCcb->Data, ReaderCcb->WritePtr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue