mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:52:54 +00:00
[NPFS]
- Do not access ThreadContext after freeing it in NpfsWaiterThread - Correctly update Vcb->EmptyWaiterCount when terminating in NpfsWaiterThread - Fix more MSVC warnings, lots of DPRINTs svn path=/trunk/; revision=57421
This commit is contained in:
parent
9234c97b19
commit
ce7b66fc69
3 changed files with 20 additions and 18 deletions
|
@ -361,7 +361,7 @@ NpfsWaitPipe(PIRP Irp,
|
||||||
/* Fail if not pipe was found */
|
/* Fail if not pipe was found */
|
||||||
if (Fcb == NULL)
|
if (Fcb == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("No pipe found!\n", Fcb);
|
DPRINT("No pipe found!\n");
|
||||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ NpfsWaitPipe2(PIRP Irp,
|
||||||
/* Fail if not pipe was found */
|
/* Fail if not pipe was found */
|
||||||
if (Fcb == NULL)
|
if (Fcb == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("No pipe found!\n", Fcb);
|
DPRINT("No pipe found!\n");
|
||||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@ NpfsPeekPipe(PIRP Irp,
|
||||||
DPRINT("OutputBufferLength: %lu\n", OutputBufferLength);
|
DPRINT("OutputBufferLength: %lu\n", OutputBufferLength);
|
||||||
|
|
||||||
/* Validate parameters */
|
/* Validate parameters */
|
||||||
if (OutputBufferLength < FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))
|
if (OutputBufferLength < (ULONG)FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))
|
||||||
{
|
{
|
||||||
DPRINT1("Buffer too small\n");
|
DPRINT1("Buffer too small\n");
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
@ -601,7 +601,7 @@ NpfsPeekPipe(PIRP Irp,
|
||||||
|
|
||||||
ExAcquireFastMutex(&Ccb->DataListLock);
|
ExAcquireFastMutex(&Ccb->DataListLock);
|
||||||
BufferPtr = Ccb->ReadPtr;
|
BufferPtr = Ccb->ReadPtr;
|
||||||
DPRINT("BufferPtr = %x\n", BufferPtr);
|
DPRINT("BufferPtr = %p\n", BufferPtr);
|
||||||
if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE)
|
if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE)
|
||||||
{
|
{
|
||||||
DPRINT("Byte Stream Mode\n");
|
DPRINT("Byte Stream Mode\n");
|
||||||
|
@ -609,7 +609,7 @@ NpfsPeekPipe(PIRP Irp,
|
||||||
DPRINT("Reply->MessageLength %lu\n", Reply->MessageLength);
|
DPRINT("Reply->MessageLength %lu\n", Reply->MessageLength);
|
||||||
MessageCount = 1;
|
MessageCount = 1;
|
||||||
|
|
||||||
if (OutputBufferLength >= FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[Ccb->ReadDataAvailable]))
|
if (OutputBufferLength >= (ULONG)FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[Ccb->ReadDataAvailable]))
|
||||||
{
|
{
|
||||||
RtlCopyMemory(Reply->Data, BufferPtr, Ccb->ReadDataAvailable);
|
RtlCopyMemory(Reply->Data, BufferPtr, Ccb->ReadDataAvailable);
|
||||||
ReturnLength = Ccb->ReadDataAvailable;
|
ReturnLength = Ccb->ReadDataAvailable;
|
||||||
|
@ -639,7 +639,7 @@ NpfsPeekPipe(PIRP Irp,
|
||||||
/* If its the first message, copy the Message if the size of buffer is large enough */
|
/* If its the first message, copy the Message if the size of buffer is large enough */
|
||||||
if (MessageCount == 1)
|
if (MessageCount == 1)
|
||||||
{
|
{
|
||||||
if (OutputBufferLength >= FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[MessageLength]))
|
if (OutputBufferLength >= (ULONG)FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[MessageLength]))
|
||||||
{
|
{
|
||||||
RtlCopyMemory(Reply->Data,
|
RtlCopyMemory(Reply->Data,
|
||||||
(PVOID)((ULONG_PTR)BufferPtr + sizeof(MessageLength)),
|
(PVOID)((ULONG_PTR)BufferPtr + sizeof(MessageLength)),
|
||||||
|
@ -649,7 +649,7 @@ NpfsPeekPipe(PIRP Irp,
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferPtr = (PVOID)((ULONG_PTR)BufferPtr + sizeof(MessageLength) + MessageLength);
|
BufferPtr = (PVOID)((ULONG_PTR)BufferPtr + sizeof(MessageLength) + MessageLength);
|
||||||
DPRINT("BufferPtr = %x\n", BufferPtr);
|
DPRINT("BufferPtr = %p\n", BufferPtr);
|
||||||
DPRINT("ReadDataAvailable: %lu\n", ReadDataAvailable);
|
DPRINT("ReadDataAvailable: %lu\n", ReadDataAvailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
||||||
&DeviceObject);
|
&DeviceObject);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Failed to create named pipe device! (Status %x)\n", Status);
|
DPRINT1("Failed to create named pipe device! (Status %lx)\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ static KSTART_ROUTINE NpfsWaiterThread;
|
||||||
static VOID NTAPI
|
static VOID NTAPI
|
||||||
NpfsWaiterThread(PVOID InitContext)
|
NpfsWaiterThread(PVOID InitContext)
|
||||||
{
|
{
|
||||||
PNPFS_THREAD_CONTEXT ThreadContext = (PNPFS_THREAD_CONTEXT) InitContext;
|
PNPFS_THREAD_CONTEXT ThreadContext = InitContext;
|
||||||
ULONG CurrentCount;
|
ULONG CurrentCount;
|
||||||
ULONG Count = 0, i;
|
ULONG Count = 0, i;
|
||||||
PIRP Irp = NULL;
|
PIRP Irp = NULL;
|
||||||
|
@ -194,9 +194,11 @@ NpfsWaiterThread(PVOID InitContext)
|
||||||
if (ThreadContext->Count == 1 && ThreadContext->Vcb->EmptyWaiterCount >= MAXIMUM_WAIT_OBJECTS)
|
if (ThreadContext->Count == 1 && ThreadContext->Vcb->EmptyWaiterCount >= MAXIMUM_WAIT_OBJECTS)
|
||||||
{
|
{
|
||||||
/* there is another thread with empty wait slots, we can remove our thread from the list */
|
/* there is another thread with empty wait slots, we can remove our thread from the list */
|
||||||
|
ASSERT(Irp == NULL);
|
||||||
|
ThreadContext->Vcb->EmptyWaiterCount -= MAXIMUM_WAIT_OBJECTS - 1;
|
||||||
RemoveEntryList(&ThreadContext->ListEntry);
|
RemoveEntryList(&ThreadContext->ListEntry);
|
||||||
ExFreePoolWithTag(ThreadContext, TAG_NPFS_THREAD_CONTEXT);
|
|
||||||
KeUnlockMutex(&ThreadContext->Vcb->PipeListLock);
|
KeUnlockMutex(&ThreadContext->Vcb->PipeListLock);
|
||||||
|
ExFreePoolWithTag(ThreadContext, TAG_NPFS_THREAD_CONTEXT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,7 +501,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
||||||
/* 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)
|
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 %p\n", Ccb->Data);
|
||||||
/* Byte stream mode */
|
/* Byte stream mode */
|
||||||
while (Length > 0 && Ccb->ReadDataAvailable > 0)
|
while (Length > 0 && Ccb->ReadDataAvailable > 0)
|
||||||
{
|
{
|
||||||
|
@ -541,7 +543,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
else if (Ccb->Fcb->PipeType == FILE_PIPE_MESSAGE_TYPE)
|
else if (Ccb->Fcb->PipeType == FILE_PIPE_MESSAGE_TYPE)
|
||||||
{
|
{
|
||||||
DPRINT("Message mode: Ccb>Data %x\n", Ccb->Data);
|
DPRINT("Message mode: Ccb>Data %p\n", Ccb->Data);
|
||||||
|
|
||||||
/* Check if buffer is full and the read pointer is not at the start of the buffer */
|
/* Check if buffer is full and the read pointer is not at the start of the buffer */
|
||||||
if ((Ccb->WriteQuotaAvailable == 0) && (Ccb->ReadPtr > Ccb->Data))
|
if ((Ccb->WriteQuotaAvailable == 0) && (Ccb->ReadPtr > Ccb->Data))
|
||||||
|
@ -812,7 +814,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
ExAcquireFastMutex(&ReaderCcb->DataListLock);
|
ExAcquireFastMutex(&ReaderCcb->DataListLock);
|
||||||
|
|
||||||
DPRINT("Length %d Buffer %x Offset %x\n",Length,Buffer,Offset);
|
DPRINT("Length %lu Buffer %p Offset %lu\n", Length, Buffer, Offset);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
HexDump(Buffer, Length);
|
HexDump(Buffer, Length);
|
||||||
|
@ -854,7 +856,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
*/
|
*/
|
||||||
if (Ccb->PipeState != FILE_PIPE_CONNECTED_STATE || !Ccb->OtherSide)
|
if (Ccb->PipeState != FILE_PIPE_CONNECTED_STATE || !Ccb->OtherSide)
|
||||||
{
|
{
|
||||||
DPRINT("PipeState: %x\n", Ccb->PipeState);
|
DPRINT("PipeState: %lx\n", Ccb->PipeState);
|
||||||
Status = STATUS_PIPE_BROKEN;
|
Status = STATUS_PIPE_BROKEN;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -869,7 +871,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE)
|
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 %p, Ccb->WritePtr %p\n", ReaderCcb->Data, ReaderCcb->WritePtr);
|
||||||
|
|
||||||
while (Length > 0 && ReaderCcb->WriteQuotaAvailable > 0)
|
while (Length > 0 && ReaderCcb->WriteQuotaAvailable > 0)
|
||||||
{
|
{
|
||||||
|
@ -913,7 +915,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
else if (Ccb->Fcb->PipeType == FILE_PIPE_MESSAGE_TYPE)
|
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 %p, Ccb->WritePtr %p\n", ReaderCcb->Data, ReaderCcb->WritePtr);
|
||||||
if (Length > 0)
|
if (Length > 0)
|
||||||
{
|
{
|
||||||
/* Verify the WritePtr is still inside the buffer */
|
/* Verify the WritePtr is still inside the buffer */
|
||||||
|
@ -921,7 +923,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
((ULONG_PTR)ReaderCcb->WritePtr < (ULONG_PTR)ReaderCcb->Data))
|
((ULONG_PTR)ReaderCcb->WritePtr < (ULONG_PTR)ReaderCcb->Data))
|
||||||
{
|
{
|
||||||
DPRINT1("NPFS is writing out of its buffer. Report to developer!\n");
|
DPRINT1("NPFS is writing out of its buffer. Report to developer!\n");
|
||||||
DPRINT1("ReaderCcb->WritePtr %x, ReaderCcb->Data %x, ReaderCcb->MaxDataLength %lu\n",
|
DPRINT1("ReaderCcb->WritePtr %p, ReaderCcb->Data %p, ReaderCcb->MaxDataLength %lu\n",
|
||||||
ReaderCcb->WritePtr, ReaderCcb->Data, ReaderCcb->MaxDataLength);
|
ReaderCcb->WritePtr, ReaderCcb->Data, ReaderCcb->MaxDataLength);
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue