[CDFS_NEW] Replace old driver with a Ms-PL licensed version straight out of the driver samples github repository.

This commit is contained in:
David Quintana 2017-11-23 21:02:16 +01:00 committed by Pierre Schweitzer
parent 87d276f05d
commit fd34548263
38 changed files with 5298 additions and 2802 deletions

View file

@ -14,7 +14,7 @@ Abstract:
--*/
#include "cdprocs.h"
#include "CdProcs.h"
//
// The Bug check file id for this module
@ -25,8 +25,8 @@ Abstract:
//
// VOID
// SafeZeroMemory (
// IN PUCHAR At,
// IN ULONG ByteCount
// _Out_ PUCHAR At,
// _In_ ULONG ByteCount
// );
//
@ -35,11 +35,12 @@ Abstract:
//
#define SafeZeroMemory(IC,AT,BYTE_COUNT) { \
_SEH2_TRY { \
try { \
RtlZeroMemory( (AT), (BYTE_COUNT) ); \
} _SEH2_EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { \
__pragma(warning(suppress: 6320)) \
} except( EXCEPTION_EXECUTE_HANDLER ) { \
CdRaiseStatus( IC, STATUS_INVALID_USER_BUFFER ); \
} _SEH2_END; \
} \
}
//
@ -53,10 +54,12 @@ Abstract:
#endif
_Requires_lock_held_(_Global_critical_region_)
NTSTATUS
CdCommonRead (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
_Inout_ PIRP_CONTEXT IrpContext,
_Inout_ PIRP Irp
)
/*++
@ -79,7 +82,7 @@ Return Value:
--*/
{
NTSTATUS Status = STATUS_SUCCESS; /* ReactOS Change: GCC Uninit var */
NTSTATUS Status = STATUS_SUCCESS;
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp );
TYPE_OF_OPEN TypeOfOpen;
@ -103,7 +106,7 @@ Return Value:
BOOLEAN ReleaseFile = TRUE;
CD_IO_CONTEXT LocalIoContext;
PAGED_CODE();
//
@ -123,6 +126,9 @@ Return Value:
TypeOfOpen = CdDecodeFileObject( IrpContext, IrpSp->FileObject, &Fcb, &Ccb );
// Internal lock object is acquired if return status is STATUS_PENDING
_Analysis_suppress_lock_checking_(Fcb->Resource);
if ((TypeOfOpen == UnopenedFileObject) ||
(TypeOfOpen == UserDirectoryOpen)) {
@ -180,7 +186,7 @@ Return Value:
// Use a try-finally to facilitate cleanup.
//
_SEH2_TRY {
try {
//
// Verify the Fcb. Allow reads if this is a DASD handle that is
@ -222,11 +228,11 @@ Return Value:
// based on the state of the file oplocks.
//
Status = FsRtlCheckOplock( &Fcb->Oplock,
Status = FsRtlCheckOplock( CdGetFcbOplock(Fcb),
Irp,
IrpContext,
(PVOID)CdOplockComplete,/* ReactOS Change: GCC "assignment from incompatible pointer type" */
(PVOID)CdPrePostIrp );/* ReactOS Change: GCC "assignment from incompatible pointer type" */
CdOplockComplete,
CdPrePostIrp );
//
// If the result is not STATUS_SUCCESS then the Irp was completed
@ -250,22 +256,31 @@ Return Value:
}
//
// Complete the request if it begins beyond the end of file.
// Check request beyond end of file if this is not a read on a volume
// handle marked for extended DASD IO.
//
if (StartingOffset >= Fcb->FileSize.QuadPart) {
if ((TypeOfOpen != UserVolumeOpen) ||
(!FlagOn( Ccb->Flags, CCB_FLAG_ALLOW_EXTENDED_DASD_IO ))) {
try_return( Status = STATUS_END_OF_FILE );
}
//
// Complete the request if it begins beyond the end of file.
//
//
// Truncate the read if it extends beyond the end of the file.
//
if (StartingOffset >= Fcb->FileSize.QuadPart) {
if (ByteRange > Fcb->FileSize.QuadPart) {
try_return( Status = STATUS_END_OF_FILE );
}
ByteCount = (ULONG) (Fcb->FileSize.QuadPart - StartingOffset);
ByteRange = Fcb->FileSize.QuadPart;
//
// Truncate the read if it extends beyond the end of the file.
//
if (ByteRange > Fcb->FileSize.QuadPart) {
ByteCount = (ULONG) (Fcb->FileSize.QuadPart - StartingOffset);
ByteRange = Fcb->FileSize.QuadPart;
}
}
//
@ -515,7 +530,7 @@ Return Value:
}
try_exit: NOTHING;
} _SEH2_FINALLY {
} finally {
//
// Release the Fcb.
@ -525,7 +540,7 @@ Return Value:
CdReleaseFile( IrpContext, Fcb );
}
} _SEH2_END;
}
//
// Post the request if we got CANT_WAIT.
@ -548,3 +563,4 @@ Return Value:
}