Author: pschweitzer Date: Mon Feb 29 21:45:44 2016 New Revision: 70824
URL: http://svn.reactos.org/svn/reactos?rev=70824&view=rev Log: [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!
Modified: trunk/reactos/ntoskrnl/io/iomgr/iofunc.c
Modified: trunk/reactos/ntoskrnl/io/iomgr/iofunc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iofunc.c?... ============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/iofunc.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/iofunc.c [iso-8859-1] Mon Feb 29 21:45:44 2016 @@ -2563,56 +2563,55 @@ { /* Perform fast read */ FastIoDispatch = DeviceObject->DriverObject->FastIoDispatch; - if (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)) + 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)) + { + /* Fast path -- update transfer & operation counts */ + IopUpdateOperationCount(IopReadTransfer); + IopUpdateTransferCount(IopReadTransfer, + (ULONG)KernelIosb.Information); + + /* Enter SEH to write the IOSB back */ + _SEH2_TRY { - /* Fast path -- update transfer & operation counts */ - IopUpdateOperationCount(IopReadTransfer); - IopUpdateTransferCount(IopReadTransfer, - (ULONG)KernelIosb.Information); - - /* Enter SEH to write the IOSB back */ - _SEH2_TRY - { - /* 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 */ + /* 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); - 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 @@ { /* Perform fast write */ FastIoDispatch = DeviceObject->DriverObject->FastIoDispatch; - if (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) + 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) + { + /* Fast path -- update transfer & operation counts */ + IopUpdateOperationCount(IopWriteTransfer); + IopUpdateTransferCount(IopWriteTransfer, + (ULONG)KernelIosb.Information); + + /* Enter SEH to write the IOSB back */ + _SEH2_TRY { - /* Fast path -- update transfer & operation counts */ - IopUpdateOperationCount(IopWriteTransfer); - IopUpdateTransferCount(IopWriteTransfer, - (ULONG)KernelIosb.Information); - - /* Enter SEH to write the IOSB back */ - _SEH2_TRY - { - /* 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 */ + /* 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); - 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; } }