Use a safe IO_STATUS_BLOCK from the kernel stack.

svn path=/trunk/; revision=6667
This commit is contained in:
Eric Kohl 2003-11-16 21:03:59 +00:00
parent b5b0d3d61c
commit 241482601d
3 changed files with 34 additions and 22 deletions

View file

@ -1,4 +1,4 @@
/* $Id: buildirp.c,v 1.35 2003/10/12 17:05:44 hbirr Exp $
/* $Id: buildirp.c,v 1.36 2003/11/16 21:03:59 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -97,12 +97,12 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
{
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
DPRINT("IoBuildAsynchronousFsdRequest(MajorFunction %x, DeviceObject %x, "
"Buffer %x, Length %x, StartingOffset %x, "
"IoStatusBlock %x\n",MajorFunction,DeviceObject,Buffer,Length,
StartingOffset,IoStatusBlock);
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
if (Irp==NULL)
{
@ -112,7 +112,7 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
Irp->UserIosb = IoStatusBlock;
DPRINT("Irp->UserIosb %x\n", Irp->UserIosb);
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
StackPtr->MinorFunction = 0;
@ -121,7 +121,7 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = NULL;
StackPtr->CompletionRoutine = NULL;
if (Buffer != NULL)
{
IoPrepareIrpBuffer(Irp,
@ -141,10 +141,10 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
else
{
StackPtr->Parameters.Read.ByteOffset.QuadPart = 0;
}
}
}
else if (MajorFunction == IRP_MJ_WRITE)
{
{
StackPtr->Parameters.Write.Length = Length;
if (StartingOffset!=NULL)
{
@ -152,12 +152,12 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
}
else
{
StackPtr->Parameters.Write.ByteOffset.QuadPart = 0;
}
StackPtr->Parameters.Write.ByteOffset.QuadPart = 0;
}
}
Irp->UserIosb = IoStatusBlock;
return(Irp);
}

View file

@ -1,4 +1,4 @@
/* $Id: ioctrl.c,v 1.20 2003/11/08 16:43:02 ekohl Exp $
/* $Id: ioctrl.c,v 1.21 2003/11/16 21:03:59 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -37,6 +37,7 @@ NtDeviceIoControlFile (IN HANDLE DeviceHandle,
OUT PVOID OutputBuffer,
IN ULONG OutputBufferLength OPTIONAL)
{
IO_STATUS_BLOCK SafeIoStatusBlock;
NTSTATUS Status;
PFILE_OBJECT FileObject;
PDEVICE_OBJECT DeviceObject;
@ -96,7 +97,7 @@ NtDeviceIoControlFile (IN HANDLE DeviceHandle,
OutputBufferLength,
FALSE,
EventObject,
IoStatusBlock);
&SafeIoStatusBlock);
/* Trigger FileObject/Event dereferencing */
Irp->Tail.Overlay.OriginalFileObject = FileObject;
@ -127,10 +128,13 @@ NtDeviceIoControlFile (IN HANDLE DeviceHandle,
return Status;
}
Status = IoStatusBlock->Status;
Status = SafeIoStatusBlock.Status;
}
return Status;
IoStatusBlock->Status = SafeIoStatusBlock.Status;
IoStatusBlock->Information = SafeIoStatusBlock.Information;
return Status;
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: rw.c,v 1.48 2003/11/08 16:48:36 ekohl Exp $
/* $Id: rw.c,v 1.49 2003/11/16 21:03:59 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -46,6 +46,7 @@ NtReadFile (IN HANDLE FileHandle,
IN PLARGE_INTEGER ByteOffset OPTIONAL,
IN PULONG Key OPTIONAL)
{
IO_STATUS_BLOCK SafeIoStatusBlock;
NTSTATUS Status;
PFILE_OBJECT FileObject;
PIRP Irp;
@ -101,7 +102,7 @@ NtReadFile (IN HANDLE FileHandle,
Length,
ByteOffset,
EventObject,
IoStatusBlock);
&SafeIoStatusBlock);
/* Trigger FileObject/Event dereferencing */
Irp->Tail.Overlay.OriginalFileObject = FileObject;
@ -137,9 +138,12 @@ NtReadFile (IN HANDLE FileHandle,
return(Status);
}
Status = IoStatusBlock->Status;
Status = SafeIoStatusBlock.Status;
}
IoStatusBlock->Status = SafeIoStatusBlock.Status;
IoStatusBlock->Information = SafeIoStatusBlock.Information;
return Status;
}
@ -169,6 +173,7 @@ NtWriteFile (IN HANDLE FileHandle,
IN PLARGE_INTEGER ByteOffset OPTIONAL,
IN PULONG Key OPTIONAL)
{
IO_STATUS_BLOCK SafeIoStatusBlock;
NTSTATUS Status;
PFILE_OBJECT FileObject;
PIRP Irp;
@ -183,7 +188,7 @@ NtWriteFile (IN HANDLE FileHandle,
return STATUS_ACCESS_VIOLATION;
Status = ObReferenceObjectByHandle(FileHandle,
FILE_READ_DATA,
FILE_WRITE_DATA,
IoFileObjectType,
UserMode,
(PVOID*)&FileObject,
@ -224,14 +229,14 @@ NtWriteFile (IN HANDLE FileHandle,
Length,
ByteOffset,
EventObject,
IoStatusBlock);
&SafeIoStatusBlock);
/* Trigger FileObject/Event dereferencing */
Irp->Tail.Overlay.OriginalFileObject = FileObject;
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->FileObject = FileObject;
if (Key != NULL)
@ -260,9 +265,12 @@ NtWriteFile (IN HANDLE FileHandle,
return(Status);
}
Status = IoStatusBlock->Status;
Status = SafeIoStatusBlock.Status;
}
IoStatusBlock->Status = SafeIoStatusBlock.Status;
IoStatusBlock->Information = SafeIoStatusBlock.Information;
return Status;
}