[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
@ -26,41 +26,43 @@ Abstract:
// Local support routines
//
_Requires_lock_held_(_Global_critical_region_)
NTSTATUS
CdQueryDirectory (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN PIO_STACK_LOCATION IrpSp,
IN PFCB Fcb,
IN PCCB Ccb
_Inout_ PIRP_CONTEXT IrpContext,
_Inout_ PIRP Irp,
_In_ PIO_STACK_LOCATION IrpSp,
_In_ PFCB Fcb,
_In_ PCCB Ccb
);
_Requires_lock_held_(_Global_critical_region_)
NTSTATUS
CdNotifyChangeDirectory (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN PIO_STACK_LOCATION IrpSp,
IN PCCB Ccb
_Inout_ PIRP_CONTEXT IrpContext,
_Inout_ PIRP Irp,
_In_ PIO_STACK_LOCATION IrpSp,
_In_ PCCB Ccb
);
VOID
CdInitializeEnumeration (
IN PIRP_CONTEXT IrpContext,
IN PIO_STACK_LOCATION IrpSp,
IN PFCB Fcb,
IN OUT PCCB Ccb,
IN OUT PFILE_ENUM_CONTEXT FileContext,
OUT PBOOLEAN ReturnNextEntry,
OUT PBOOLEAN ReturnSingleEntry,
OUT PBOOLEAN InitialQuery
_In_ PIRP_CONTEXT IrpContext,
_In_ PIO_STACK_LOCATION IrpSp,
_In_ PFCB Fcb,
_Inout_ PCCB Ccb,
_Inout_ PFILE_ENUM_CONTEXT FileContext,
_Out_ PBOOLEAN ReturnNextEntry,
_Out_ PBOOLEAN ReturnSingleEntry,
_Out_ PBOOLEAN InitialQuery
);
BOOLEAN
CdEnumerateIndex (
IN PIRP_CONTEXT IrpContext,
IN PCCB Ccb,
IN OUT PFILE_ENUM_CONTEXT FileContext,
IN BOOLEAN ReturnNextEntry
_In_ PIRP_CONTEXT IrpContext,
_In_ PCCB Ccb,
_Inout_ PFILE_ENUM_CONTEXT FileContext,
_In_ BOOLEAN ReturnNextEntry
);
#ifdef ALLOC_PRAGMA
@ -72,10 +74,12 @@ CdEnumerateIndex (
#endif
_Requires_lock_held_(_Global_critical_region_)
NTSTATUS
CdCommonDirControl (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
_Inout_ PIRP_CONTEXT IrpContext,
_Inout_ PIRP Irp
)
/*++
@ -152,13 +156,14 @@ Return Value:
// Local support routines
//
_Requires_lock_held_(_Global_critical_region_)
NTSTATUS
CdQueryDirectory (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN PIO_STACK_LOCATION IrpSp,
IN PFCB Fcb,
IN PCCB Ccb
_Inout_ PIRP_CONTEXT IrpContext,
_Inout_ PIRP Irp,
_In_ PIO_STACK_LOCATION IrpSp,
_In_ PFCB Fcb,
_In_ PCCB Ccb
)
/*++
@ -197,9 +202,9 @@ Return Value:
ULONG VersionStringBytes;
FILE_ENUM_CONTEXT FileContext;
PDIRENT ThisDirent;
PDIRENT ThisDirent = NULL;
BOOLEAN InitialQuery;
BOOLEAN ReturnNextEntry;
BOOLEAN ReturnNextEntry = FALSE;
BOOLEAN ReturnSingleEntry;
BOOLEAN Found;
BOOLEAN DoCcbUpdate = FALSE;
@ -209,7 +214,7 @@ Return Value:
ULONG BaseLength;
PFILE_BOTH_DIR_INFORMATION DirInfo = NULL; /* ReactOS Change: GCC Uninit var */
PFILE_BOTH_DIR_INFORMATION DirInfo = NULL;
PFILE_NAMES_INFORMATION NamesInfo;
PFILE_ID_FULL_DIR_INFORMATION IdFullDirInfo;
PFILE_ID_BOTH_DIR_INFORMATION IdBothDirInfo;
@ -287,7 +292,7 @@ Return Value:
// Use a try-finally to facilitate cleanup.
//
_SEH2_TRY {
try {
//
// Verify the Fcb is still good.
@ -387,7 +392,7 @@ Return Value:
//
// Here are the rules concerning filling up the buffer:
//
// 1. The Io system guarantees that there will always be
// 1. The Io system garentees that there will always be
// enough room for at least one base record.
//
// 2. If the full first record (including file name) cannot
@ -499,7 +504,7 @@ Return Value:
// such trickery.
//
_SEH2_TRY {
try {
//
// Zero and initialize the base part of the current entry.
@ -543,21 +548,16 @@ Return Value:
DirInfo->EndOfFile.QuadPart = DirInfo->AllocationSize.QuadPart = 0;
SetFlag( DirInfo->FileAttributes, FILE_ATTRIBUTE_DIRECTORY );
SetFlag( DirInfo->FileAttributes, FILE_ATTRIBUTE_DIRECTORY);
} else {
DirInfo->EndOfFile.QuadPart = FileContext.FileSize;
DirInfo->AllocationSize.QuadPart = LlSectorAlign( FileContext.FileSize );
SetFlag( DirInfo->FileAttributes, FILE_ATTRIBUTE_READONLY);
}
//
// All Cdrom files are readonly. We also copy the existence
// bit to the hidden attribute.
//
SetFlag( DirInfo->FileAttributes, FILE_ATTRIBUTE_READONLY );
if (FlagOn( ThisDirent->DirentFlags,
CD_ATTRIBUTE_HIDDEN )) {
@ -579,9 +579,6 @@ Return Value:
NamesInfo->FileNameLength = FileNameBytes + SeparatorBytes + VersionStringBytes;
break;
/* ReactOS Change: GCC "enumeration value not handled in switch" */
default: break;
}
//
@ -715,7 +712,8 @@ Return Value:
LastEntry = NextEntry;
NextEntry = QuadAlign( Information );
} _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) {
#pragma warning(suppress: 6320)
} except (EXCEPTION_EXECUTE_HANDLER) {
//
// We had a problem filling in the user's buffer, so stop and
@ -724,16 +722,16 @@ Return Value:
//
Information = 0;
try_leave( Status = _SEH2_GetExceptionCode());
} _SEH2_END;
try_leave( Status = GetExceptionCode());
}
}
DoCcbUpdate = TRUE;
} _SEH2_FINALLY {
} finally {
//
// Cleanup our search context - *before* acquiring the FCB mutex exclusive,
// Cleanup our search context - *before* aquiring the FCB mutex exclusive,
// else can block on threads in cdcreateinternalstream/purge which
// hold the FCB but are waiting for all maps in this stream to be released.
//
@ -741,7 +739,7 @@ Return Value:
CdCleanupFileContext( IrpContext, &FileContext );
//
// Now we can safely acquire the FCB mutex if we need to.
// Now we can safely aqure the FCB mutex if we need to.
//
if (DoCcbUpdate && !NT_ERROR( Status )) {
@ -769,7 +767,7 @@ Return Value:
//
CdReleaseFile( IrpContext, Fcb );
} _SEH2_END;
}
//
// Complete the request here.
@ -786,12 +784,13 @@ Return Value:
// Local support routines
//
_Requires_lock_held_(_Global_critical_region_)
NTSTATUS
CdNotifyChangeDirectory (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN PIO_STACK_LOCATION IrpSp,
IN PCCB Ccb
_Inout_ PIRP_CONTEXT IrpContext,
_Inout_ PIRP Irp,
_In_ PIO_STACK_LOCATION IrpSp,
_In_ PCCB Ccb
)
/*++
@ -837,7 +836,7 @@ Return Value:
// Use a try-finally to facilitate cleanup.
//
_SEH2_TRY {
try {
//
// Verify the Vcb.
@ -862,14 +861,14 @@ Return Value:
NULL,
NULL );
} _SEH2_FINALLY {
} finally {
//
// Release the Vcb.
//
CdReleaseVcb( IrpContext, IrpContext->Vcb );
} _SEH2_END;
}
//
// Cleanup the IrpContext.
@ -887,14 +886,14 @@ Return Value:
VOID
CdInitializeEnumeration (
IN PIRP_CONTEXT IrpContext,
IN PIO_STACK_LOCATION IrpSp,
IN PFCB Fcb,
IN OUT PCCB Ccb,
IN OUT PFILE_ENUM_CONTEXT FileContext,
OUT PBOOLEAN ReturnNextEntry,
OUT PBOOLEAN ReturnSingleEntry,
OUT PBOOLEAN InitialQuery
_In_ PIRP_CONTEXT IrpContext,
_In_ PIO_STACK_LOCATION IrpSp,
_In_ PFCB Fcb,
_Inout_ PCCB Ccb,
_Inout_ PFILE_ENUM_CONTEXT FileContext,
_Out_ PBOOLEAN ReturnNextEntry,
_Out_ PBOOLEAN ReturnSingleEntry,
_Out_ PBOOLEAN InitialQuery
)
/*++
@ -949,6 +948,31 @@ Return Value:
PAGED_CODE();
//
// If the user has specified that the scan be restarted, and has specicified
// a new query pattern, reinitialize the CCB.
//
if (FlagOn( IrpSp->Flags, SL_RESTART_SCAN )) {
CdLockFcb( IrpContext, Fcb );
FileName = (PUNICODE_STRING) IrpSp->Parameters.QueryDirectory.FileName;
if (FileName && FileName->Length > 0) {
if (!FlagOn( Ccb->Flags, CCB_FLAG_ENUM_MATCH_ALL )) {
CdFreePool( &Ccb->SearchExpression.FileName.Buffer );
}
ClearFlag(Ccb->Flags, CCB_FLAG_ENUM_MATCH_ALL);
ClearFlag(Ccb->Flags, CCB_FLAG_ENUM_INITIALIZED);
ClearFlag(Ccb->Flags, CCB_FLAG_ENUM_NAME_EXP_HAS_WILD);
}
CdUnlockFcb( IrpContext, Fcb );
}
//
// If this is the initial query then build a search expression from the input
// file name.
@ -1049,8 +1073,8 @@ Return Value:
//
// This should never fail.
//
ASSERT( Status == STATUS_SUCCESS );
__analysis_assert( Status == STATUS_SUCCESS );
NT_ASSERT( Status == STATUS_SUCCESS );
} else {
@ -1189,10 +1213,7 @@ Return Value:
// If there is no file object then create it now.
//
if (Fcb->FileObject == NULL) {
CdCreateInternalStream( IrpContext, Fcb->Vcb, Fcb );
}
CdVerifyOrCreateDirStreamFile( IrpContext, Fcb);
//
// Determine the offset in the stream to position the FileContext and
@ -1330,10 +1351,10 @@ Return Value:
BOOLEAN
CdEnumerateIndex (
IN PIRP_CONTEXT IrpContext,
IN PCCB Ccb,
IN OUT PFILE_ENUM_CONTEXT FileContext,
IN BOOLEAN ReturnNextEntry
_In_ PIRP_CONTEXT IrpContext,
_In_ PCCB Ccb,
_Inout_ PFILE_ENUM_CONTEXT FileContext,
_In_ BOOLEAN ReturnNextEntry
)
/*++
@ -1371,7 +1392,7 @@ Return Value:
PAGED_CODE();
//
// Loop until we find a match or exhaust the directory.
// Loop until we find a match or exaust the directory.
//
while (TRUE) {