- 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:
Thomas Faber 2012-09-29 09:05:18 +00:00
parent 9234c97b19
commit ce7b66fc69
3 changed files with 20 additions and 18 deletions

View file

@ -361,7 +361,7 @@ NpfsWaitPipe(PIRP Irp,
/* Fail if not pipe was found */
if (Fcb == NULL)
{
DPRINT("No pipe found!\n", Fcb);
DPRINT("No pipe found!\n");
return STATUS_OBJECT_NAME_NOT_FOUND;
}
@ -483,7 +483,7 @@ NpfsWaitPipe2(PIRP Irp,
/* Fail if not pipe was found */
if (Fcb == NULL)
{
DPRINT("No pipe found!\n", Fcb);
DPRINT("No pipe found!\n");
return STATUS_OBJECT_NAME_NOT_FOUND;
}
@ -583,7 +583,7 @@ NpfsPeekPipe(PIRP Irp,
DPRINT("OutputBufferLength: %lu\n", OutputBufferLength);
/* 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");
return STATUS_INVALID_PARAMETER;
@ -601,7 +601,7 @@ NpfsPeekPipe(PIRP Irp,
ExAcquireFastMutex(&Ccb->DataListLock);
BufferPtr = Ccb->ReadPtr;
DPRINT("BufferPtr = %x\n", BufferPtr);
DPRINT("BufferPtr = %p\n", BufferPtr);
if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE)
{
DPRINT("Byte Stream Mode\n");
@ -609,7 +609,7 @@ NpfsPeekPipe(PIRP Irp,
DPRINT("Reply->MessageLength %lu\n", Reply->MessageLength);
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);
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 (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,
(PVOID)((ULONG_PTR)BufferPtr + sizeof(MessageLength)),
@ -649,7 +649,7 @@ NpfsPeekPipe(PIRP Irp,
}
BufferPtr = (PVOID)((ULONG_PTR)BufferPtr + sizeof(MessageLength) + MessageLength);
DPRINT("BufferPtr = %x\n", BufferPtr);
DPRINT("BufferPtr = %p\n", BufferPtr);
DPRINT("ReadDataAvailable: %lu\n", ReadDataAvailable);
}

View file

@ -67,7 +67,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
&DeviceObject);
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;
}

View file

@ -119,7 +119,7 @@ static KSTART_ROUTINE NpfsWaiterThread;
static VOID NTAPI
NpfsWaiterThread(PVOID InitContext)
{
PNPFS_THREAD_CONTEXT ThreadContext = (PNPFS_THREAD_CONTEXT) InitContext;
PNPFS_THREAD_CONTEXT ThreadContext = InitContext;
ULONG CurrentCount;
ULONG Count = 0, i;
PIRP Irp = NULL;
@ -194,9 +194,11 @@ NpfsWaiterThread(PVOID InitContext)
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 */
ASSERT(Irp == NULL);
ThreadContext->Vcb->EmptyWaiterCount -= MAXIMUM_WAIT_OBJECTS - 1;
RemoveEntryList(&ThreadContext->ListEntry);
ExFreePoolWithTag(ThreadContext, TAG_NPFS_THREAD_CONTEXT);
KeUnlockMutex(&ThreadContext->Vcb->PipeListLock);
ExFreePoolWithTag(ThreadContext, TAG_NPFS_THREAD_CONTEXT);
break;
}
}
@ -499,7 +501,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
/* If the pipe type and read mode are both byte stream */
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 */
while (Length > 0 && Ccb->ReadDataAvailable > 0)
{
@ -541,7 +543,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
}
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 */
if ((Ccb->WriteQuotaAvailable == 0) && (Ccb->ReadPtr > Ccb->Data))
@ -611,7 +613,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
Ccb->ReadPtr = Ccb->Data;
}
#ifndef NDEBUG
DPRINT("Length %d Buffer %x\n",CopyLength,Buffer);
DPRINT("Length %d Buffer %x\n", CopyLength, Buffer);
HexDump((PUCHAR)Buffer, CopyLength);
#endif
@ -812,7 +814,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
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
HexDump(Buffer, Length);
@ -854,7 +856,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
*/
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;
goto done;
}
@ -869,7 +871,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
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)
{
@ -913,7 +915,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
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 */
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)
{
/* Verify the WritePtr is still inside the buffer */
@ -921,7 +923,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
((ULONG_PTR)ReaderCcb->WritePtr < (ULONG_PTR)ReaderCcb->Data))
{
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);
ASSERT(FALSE);
}