mirror of
https://github.com/reactos/reactos.git
synced 2025-07-24 17:13:51 +00:00
[NTOSKRNL]
The Ewoks concil said it's fine to dereference null pointers in the kernel, so, partly revert r70819 (by partly, I mean: revert everything excepted the comments that were fixed!). Also add asserts that exist on Windows to make it obvious we're about to kill the whole kernel To make it clear: fix the FSD! svn path=/trunk/; revision=70824
This commit is contained in:
parent
a1a070ac19
commit
5e3fd4edeb
1 changed files with 84 additions and 86 deletions
|
@ -2563,56 +2563,55 @@ NtReadFile(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
/* Perform fast read */
|
/* Perform fast read */
|
||||||
FastIoDispatch = DeviceObject->DriverObject->FastIoDispatch;
|
FastIoDispatch = DeviceObject->DriverObject->FastIoDispatch;
|
||||||
if (FastIoDispatch != NULL && FastIoDispatch->FastIoRead != NULL)
|
ASSERT(FastIoDispatch != NULL && FastIoDispatch->FastIoRead != NULL);
|
||||||
|
|
||||||
|
Success = FastIoDispatch->FastIoRead(FileObject,
|
||||||
|
&CapturedByteOffset,
|
||||||
|
Length,
|
||||||
|
TRUE,
|
||||||
|
CapturedKey,
|
||||||
|
Buffer,
|
||||||
|
&KernelIosb,
|
||||||
|
DeviceObject);
|
||||||
|
|
||||||
|
/* Only accept the result if we got a straightforward status */
|
||||||
|
if (Success &&
|
||||||
|
(KernelIosb.Status == STATUS_SUCCESS ||
|
||||||
|
KernelIosb.Status == STATUS_BUFFER_OVERFLOW ||
|
||||||
|
KernelIosb.Status == STATUS_END_OF_FILE))
|
||||||
{
|
{
|
||||||
Success = FastIoDispatch->FastIoRead(FileObject,
|
/* Fast path -- update transfer & operation counts */
|
||||||
&CapturedByteOffset,
|
IopUpdateOperationCount(IopReadTransfer);
|
||||||
Length,
|
IopUpdateTransferCount(IopReadTransfer,
|
||||||
TRUE,
|
(ULONG)KernelIosb.Information);
|
||||||
CapturedKey,
|
|
||||||
Buffer,
|
|
||||||
&KernelIosb,
|
|
||||||
DeviceObject);
|
|
||||||
|
|
||||||
/* Only accept the result if we got a straightforward status */
|
/* Enter SEH to write the IOSB back */
|
||||||
if (Success &&
|
_SEH2_TRY
|
||||||
(KernelIosb.Status == STATUS_SUCCESS ||
|
|
||||||
KernelIosb.Status == STATUS_BUFFER_OVERFLOW ||
|
|
||||||
KernelIosb.Status == STATUS_END_OF_FILE))
|
|
||||||
{
|
{
|
||||||
/* Fast path -- update transfer & operation counts */
|
/* Write it back to the caller */
|
||||||
IopUpdateOperationCount(IopReadTransfer);
|
*IoStatusBlock = KernelIosb;
|
||||||
IopUpdateTransferCount(IopReadTransfer,
|
}
|
||||||
(ULONG)KernelIosb.Information);
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
/* Enter SEH to write the IOSB back */
|
/* The caller's IOSB was invalid, so fail */
|
||||||
_SEH2_TRY
|
if (EventObject) ObDereferenceObject(EventObject);
|
||||||
{
|
|
||||||
/* Write it back to the caller */
|
|
||||||
*IoStatusBlock = KernelIosb;
|
|
||||||
}
|
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
||||||
{
|
|
||||||
/* The caller's IOSB was invalid, so fail */
|
|
||||||
if (EventObject) ObDereferenceObject(EventObject);
|
|
||||||
IopUnlockFileObject(FileObject);
|
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
|
||||||
}
|
|
||||||
_SEH2_END;
|
|
||||||
|
|
||||||
/* Signal the completion event */
|
|
||||||
if (EventObject)
|
|
||||||
{
|
|
||||||
KeSetEvent(EventObject, 0, FALSE);
|
|
||||||
ObDereferenceObject(EventObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean up */
|
|
||||||
IopUnlockFileObject(FileObject);
|
IopUnlockFileObject(FileObject);
|
||||||
ObDereferenceObject(FileObject);
|
ObDereferenceObject(FileObject);
|
||||||
return KernelIosb.Status;
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
||||||
}
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
|
||||||
|
/* Signal the completion event */
|
||||||
|
if (EventObject)
|
||||||
|
{
|
||||||
|
KeSetEvent(EventObject, 0, FALSE);
|
||||||
|
ObDereferenceObject(EventObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
|
IopUnlockFileObject(FileObject);
|
||||||
|
ObDereferenceObject(FileObject);
|
||||||
|
return KernelIosb.Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3578,54 +3577,53 @@ NtWriteFile(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
/* Perform fast write */
|
/* Perform fast write */
|
||||||
FastIoDispatch = DeviceObject->DriverObject->FastIoDispatch;
|
FastIoDispatch = DeviceObject->DriverObject->FastIoDispatch;
|
||||||
if (FastIoDispatch != NULL && FastIoDispatch->FastIoWrite != NULL)
|
ASSERT(FastIoDispatch != NULL && FastIoDispatch->FastIoWrite != NULL);
|
||||||
|
|
||||||
|
Success = FastIoDispatch->FastIoWrite(FileObject,
|
||||||
|
&CapturedByteOffset,
|
||||||
|
Length,
|
||||||
|
TRUE,
|
||||||
|
CapturedKey,
|
||||||
|
Buffer,
|
||||||
|
&KernelIosb,
|
||||||
|
DeviceObject);
|
||||||
|
|
||||||
|
/* Only accept the result if it was successful */
|
||||||
|
if (Success &&
|
||||||
|
KernelIosb.Status == STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
Success = FastIoDispatch->FastIoWrite(FileObject,
|
/* Fast path -- update transfer & operation counts */
|
||||||
&CapturedByteOffset,
|
IopUpdateOperationCount(IopWriteTransfer);
|
||||||
Length,
|
IopUpdateTransferCount(IopWriteTransfer,
|
||||||
TRUE,
|
(ULONG)KernelIosb.Information);
|
||||||
CapturedKey,
|
|
||||||
Buffer,
|
|
||||||
&KernelIosb,
|
|
||||||
DeviceObject);
|
|
||||||
|
|
||||||
/* Only accept the result if it was successful */
|
/* Enter SEH to write the IOSB back */
|
||||||
if (Success &&
|
_SEH2_TRY
|
||||||
KernelIosb.Status == STATUS_SUCCESS)
|
|
||||||
{
|
{
|
||||||
/* Fast path -- update transfer & operation counts */
|
/* Write it back to the caller */
|
||||||
IopUpdateOperationCount(IopWriteTransfer);
|
*IoStatusBlock = KernelIosb;
|
||||||
IopUpdateTransferCount(IopWriteTransfer,
|
}
|
||||||
(ULONG)KernelIosb.Information);
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
/* Enter SEH to write the IOSB back */
|
/* The caller's IOSB was invalid, so fail */
|
||||||
_SEH2_TRY
|
if (EventObject) ObDereferenceObject(EventObject);
|
||||||
{
|
|
||||||
/* Write it back to the caller */
|
|
||||||
*IoStatusBlock = KernelIosb;
|
|
||||||
}
|
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
||||||
{
|
|
||||||
/* The caller's IOSB was invalid, so fail */
|
|
||||||
if (EventObject) ObDereferenceObject(EventObject);
|
|
||||||
IopUnlockFileObject(FileObject);
|
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
|
||||||
}
|
|
||||||
_SEH2_END;
|
|
||||||
|
|
||||||
/* Signal the completion event */
|
|
||||||
if (EventObject)
|
|
||||||
{
|
|
||||||
KeSetEvent(EventObject, 0, FALSE);
|
|
||||||
ObDereferenceObject(EventObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean up */
|
|
||||||
IopUnlockFileObject(FileObject);
|
IopUnlockFileObject(FileObject);
|
||||||
ObDereferenceObject(FileObject);
|
ObDereferenceObject(FileObject);
|
||||||
return KernelIosb.Status;
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
||||||
}
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
|
||||||
|
/* Signal the completion event */
|
||||||
|
if (EventObject)
|
||||||
|
{
|
||||||
|
KeSetEvent(EventObject, 0, FALSE);
|
||||||
|
ObDereferenceObject(EventObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
|
IopUnlockFileObject(FileObject);
|
||||||
|
ObDereferenceObject(FileObject);
|
||||||
|
return KernelIosb.Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue