2015-09-11 04:02:21 +00:00
|
|
|
|
/*++
|
|
|
|
|
|
|
|
|
|
Copyright (c) 1989-2000 Microsoft Corporation
|
|
|
|
|
|
|
|
|
|
Module Name:
|
|
|
|
|
|
|
|
|
|
CdInit.c
|
|
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
|
|
|
|
|
|
This module implements the DRIVER_INITIALIZATION routine for Cdfs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#include "cdprocs.h"
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// The Bug check file id for this module
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#define BugCheckFileId (CDFS_BUG_CHECK_CDINIT)
|
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
// Tell prefast the function type.
|
|
|
|
|
DRIVER_INITIALIZE DriverEntry;
|
|
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
|
NTSTATUS
|
2017-11-23 20:05:28 +00:00
|
|
|
|
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
|
2015-09-11 04:02:21 +00:00
|
|
|
|
DriverEntry(
|
2017-11-23 20:02:16 +00:00
|
|
|
|
_In_ PDRIVER_OBJECT DriverObject,
|
|
|
|
|
_In_ PUNICODE_STRING RegistryPath
|
2015-09-11 04:02:21 +00:00
|
|
|
|
);
|
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
|
|
|
|
|
// tell prefast this is a driver unload function
|
|
|
|
|
DRIVER_UNLOAD CdUnload;
|
|
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
|
VOID
|
2017-11-23 20:05:28 +00:00
|
|
|
|
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
|
2015-09-11 04:02:21 +00:00
|
|
|
|
CdUnload(
|
2017-11-23 20:02:16 +00:00
|
|
|
|
_In_ PDRIVER_OBJECT DriverObject
|
2015-09-11 04:02:21 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
|
CdInitializeGlobalData (
|
2017-11-23 20:02:16 +00:00
|
|
|
|
_In_ PDRIVER_OBJECT DriverObject,
|
|
|
|
|
_In_ PDEVICE_OBJECT FileSystemDeviceObject
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
,
|
|
|
|
|
IN PDEVICE_OBJECT HddFileSystemDeviceObject
|
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
#ifdef ALLOC_PRAGMA
|
|
|
|
|
#pragma alloc_text(INIT, DriverEntry)
|
|
|
|
|
#pragma alloc_text(PAGE, CdUnload)
|
|
|
|
|
#pragma alloc_text(INIT, CdInitializeGlobalData)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Local support routine
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-11-23 20:05:28 +00:00
|
|
|
|
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
|
2015-09-11 04:02:21 +00:00
|
|
|
|
DriverEntry(
|
2017-11-23 20:02:16 +00:00
|
|
|
|
_In_ PDRIVER_OBJECT DriverObject,
|
|
|
|
|
_In_ PUNICODE_STRING RegistryPath
|
2015-09-11 04:02:21 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
/*++
|
|
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
|
|
This is the initialization routine for the Cdrom file system
|
|
|
|
|
device driver. This routine creates the device object for the FileSystem
|
|
|
|
|
device and performs all other driver initialization.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
DriverObject - Pointer to driver object created by the system.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
|
NTSTATUS - The function value is the final status from the initialization
|
|
|
|
|
operation.
|
|
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
UNICODE_STRING UnicodeString;
|
|
|
|
|
PDEVICE_OBJECT CdfsFileSystemDeviceObject;
|
2017-11-23 20:02:16 +00:00
|
|
|
|
FS_FILTER_CALLBACKS FilterCallbacks;
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
PDEVICE_OBJECT HddFileSystemDeviceObject;
|
|
|
|
|
#endif
|
2017-11-23 20:02:16 +00:00
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER( RegistryPath );
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Create the device object.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString( &UnicodeString, L"\\Cdfs" );
|
|
|
|
|
|
|
|
|
|
Status = IoCreateDevice( DriverObject,
|
|
|
|
|
0,
|
|
|
|
|
&UnicodeString,
|
|
|
|
|
FILE_DEVICE_CD_ROM_FILE_SYSTEM,
|
|
|
|
|
0,
|
|
|
|
|
FALSE,
|
|
|
|
|
&CdfsFileSystemDeviceObject );
|
|
|
|
|
|
|
|
|
|
if (!NT_SUCCESS( Status )) {
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
2017-11-12 17:36:20 +00:00
|
|
|
|
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
//
|
|
|
|
|
// Create the HDD device object.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString( &UnicodeString, L"\\CdfsHdd" );
|
|
|
|
|
|
|
|
|
|
Status = IoCreateDevice( DriverObject,
|
|
|
|
|
0,
|
|
|
|
|
&UnicodeString,
|
|
|
|
|
FILE_DEVICE_DISK_FILE_SYSTEM,
|
|
|
|
|
0,
|
|
|
|
|
FALSE,
|
|
|
|
|
&HddFileSystemDeviceObject );
|
|
|
|
|
|
|
|
|
|
if (!NT_SUCCESS( Status )) {
|
|
|
|
|
IoDeleteDevice (CdfsFileSystemDeviceObject);
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
2017-11-23 20:02:16 +00:00
|
|
|
|
#pragma prefast(push)
|
|
|
|
|
#pragma prefast(disable: 28155, "the dispatch routine has the correct type, prefast is just being paranoid.")
|
|
|
|
|
#pragma prefast(disable: 28168, "the dispatch routine has the correct type, prefast is just being paranoid.")
|
|
|
|
|
#pragma prefast(disable: 28169, "the dispatch routine has the correct type, prefast is just being paranoid.")
|
|
|
|
|
#pragma prefast(disable: 28175, "we're allowed to change these.")
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#endif
|
2017-11-12 17:36:20 +00:00
|
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
|
DriverObject->DriverUnload = CdUnload;
|
2017-11-23 20:02:16 +00:00
|
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
|
//
|
|
|
|
|
// Note that because of the way data caching is done, we set neither
|
|
|
|
|
// the Direct I/O or Buffered I/O bit in DeviceObject->Flags. If
|
|
|
|
|
// data is not in the cache, or the request is not buffered, we may,
|
|
|
|
|
// set up for Direct I/O by hand.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Initialize the driver object with this driver's entry points.
|
|
|
|
|
//
|
|
|
|
|
// NOTE - Each entry in the dispatch table must have an entry in
|
|
|
|
|
// the Fsp/Fsd dispatch switch statements.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CREATE] =
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] =
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_READ] =
|
2017-11-23 20:02:16 +00:00
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_WRITE] =
|
2015-09-11 04:02:21 +00:00
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION]=
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_LOCK_CONTROL] =
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CLEANUP] =
|
2017-11-23 20:02:16 +00:00
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_PNP] =
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = (PDRIVER_DISPATCH) CdFsdDispatch;
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef _MSC_VER
|
2017-11-23 20:02:16 +00:00
|
|
|
|
#pragma prefast(pop)
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
#pragma prefast(suppress: 28175, "this is a file system driver, we're allowed to touch FastIoDispatch.")
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
DriverObject->FastIoDispatch = &CdFastIoDispatch;
|
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
//
|
|
|
|
|
// Initialize the filter callbacks we use.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
RtlZeroMemory( &FilterCallbacks,
|
|
|
|
|
sizeof(FS_FILTER_CALLBACKS) );
|
|
|
|
|
|
|
|
|
|
FilterCallbacks.SizeOfFsFilterCallbacks = sizeof(FS_FILTER_CALLBACKS);
|
|
|
|
|
FilterCallbacks.PreAcquireForSectionSynchronization = CdFilterCallbackAcquireForCreateSection;
|
|
|
|
|
|
|
|
|
|
Status = FsRtlRegisterFileSystemFilterCallbacks( DriverObject,
|
|
|
|
|
&FilterCallbacks );
|
|
|
|
|
|
|
|
|
|
if (!NT_SUCCESS( Status )) {
|
|
|
|
|
|
|
|
|
|
IoDeleteDevice( CdfsFileSystemDeviceObject );
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
IoDeleteDevice (HddFileSystemDeviceObject);
|
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Initialize the global data structures
|
|
|
|
|
//
|
|
|
|
|
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifndef __REACTOS__
|
2015-09-11 04:02:21 +00:00
|
|
|
|
Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject );
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#else
|
|
|
|
|
Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject, HddFileSystemDeviceObject );
|
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
if (!NT_SUCCESS (Status)) {
|
|
|
|
|
IoDeleteDevice (CdfsFileSystemDeviceObject);
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
IoDeleteDevice (HddFileSystemDeviceObject);
|
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Register the file system as low priority with the I/O system. This will cause
|
|
|
|
|
// CDFS to receive mount requests after a) other filesystems currently registered
|
|
|
|
|
// and b) other normal priority filesystems that may be registered later.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
CdfsFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM;
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
HddFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM;
|
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
|
|
|
|
IoRegisterFileSystem( CdfsFileSystemDeviceObject );
|
|
|
|
|
ObReferenceObject (CdfsFileSystemDeviceObject);
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
IoRegisterFileSystem( HddFileSystemDeviceObject );
|
|
|
|
|
ObReferenceObject (HddFileSystemDeviceObject);
|
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
#ifdef CDFS_TELEMETRY_DATA
|
2015-09-11 04:02:21 +00:00
|
|
|
|
//
|
2017-11-23 20:02:16 +00:00
|
|
|
|
// Initialize Telemetry
|
2015-09-11 04:02:21 +00:00
|
|
|
|
//
|
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
CdInitializeTelemetry();
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
2017-11-12 17:57:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
//
|
|
|
|
|
// And return to our caller
|
|
|
|
|
//
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
return( STATUS_SUCCESS );
|
2015-09-11 04:02:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
2017-11-23 20:05:28 +00:00
|
|
|
|
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
|
2015-09-11 04:02:21 +00:00
|
|
|
|
CdUnload(
|
2017-11-23 20:02:16 +00:00
|
|
|
|
_In_ PDRIVER_OBJECT DriverObject
|
2015-09-11 04:02:21 +00:00
|
|
|
|
)
|
|
|
|
|
/*++
|
|
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
|
|
This routine unload routine for CDFS.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
DriverObject - Supplies the driver object for CDFS.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
{
|
|
|
|
|
PIRP_CONTEXT IrpContext;
|
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER( DriverObject );
|
|
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
|
//
|
|
|
|
|
// Free any IRP contexts
|
|
|
|
|
//
|
|
|
|
|
while (1) {
|
|
|
|
|
IrpContext = (PIRP_CONTEXT) PopEntryList( &CdData.IrpContextList) ;
|
|
|
|
|
if (IrpContext == NULL) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
CdFreePool(&IrpContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IoFreeWorkItem (CdData.CloseItem);
|
|
|
|
|
ExDeleteResourceLite( &CdData.DataResource );
|
|
|
|
|
ObDereferenceObject (CdData.FileSystemDeviceObject);
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
ObDereferenceObject (CdData.HddFileSystemDeviceObject);
|
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Local support routine
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
|
CdInitializeGlobalData (
|
2017-11-23 20:02:16 +00:00
|
|
|
|
_In_ PDRIVER_OBJECT DriverObject,
|
|
|
|
|
_In_ PDEVICE_OBJECT FileSystemDeviceObject
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
,
|
|
|
|
|
IN PDEVICE_OBJECT HddFileSystemDeviceObject
|
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
/*++
|
|
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
|
|
This routine initializes the global cdfs data structures.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
DriverObject - Supplies the driver object for CDFS.
|
|
|
|
|
|
|
|
|
|
FileSystemDeviceObject - Supplies the device object for CDFS.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// Start by initializing the FastIoDispatch Table.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
RtlZeroMemory( &CdFastIoDispatch, sizeof( FAST_IO_DISPATCH ));
|
|
|
|
|
|
|
|
|
|
CdFastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
|
2017-11-23 20:02:16 +00:00
|
|
|
|
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef _MSC_VER
|
2017-11-23 20:02:16 +00:00
|
|
|
|
#pragma prefast(push)
|
|
|
|
|
#pragma prefast(disable:28155, "these are all correct")
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#endif
|
2017-11-23 20:02:16 +00:00
|
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
|
CdFastIoDispatch.FastIoCheckIfPossible = CdFastIoCheckIfPossible; // CheckForFastIo
|
|
|
|
|
CdFastIoDispatch.FastIoRead = FsRtlCopyRead; // Read
|
|
|
|
|
CdFastIoDispatch.FastIoQueryBasicInfo = CdFastQueryBasicInfo; // QueryBasicInfo
|
|
|
|
|
CdFastIoDispatch.FastIoQueryStandardInfo = CdFastQueryStdInfo; // QueryStandardInfo
|
|
|
|
|
CdFastIoDispatch.FastIoLock = CdFastLock; // Lock
|
|
|
|
|
CdFastIoDispatch.FastIoUnlockSingle = CdFastUnlockSingle; // UnlockSingle
|
|
|
|
|
CdFastIoDispatch.FastIoUnlockAll = CdFastUnlockAll; // UnlockAll
|
|
|
|
|
CdFastIoDispatch.FastIoUnlockAllByKey = CdFastUnlockAllByKey; // UnlockAllByKey
|
2017-11-23 20:02:16 +00:00
|
|
|
|
//
|
|
|
|
|
// This callback has been replaced by CdFilterCallbackAcquireForCreateSection.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
CdFastIoDispatch.AcquireFileForNtCreateSection = NULL;
|
2015-09-11 04:02:21 +00:00
|
|
|
|
CdFastIoDispatch.ReleaseFileForNtCreateSection = CdReleaseForCreateSection;
|
|
|
|
|
CdFastIoDispatch.FastIoQueryNetworkOpenInfo = CdFastQueryNetworkInfo; // QueryNetworkInfo
|
|
|
|
|
|
|
|
|
|
CdFastIoDispatch.MdlRead = FsRtlMdlReadDev;
|
|
|
|
|
CdFastIoDispatch.MdlReadComplete = FsRtlMdlReadCompleteDev;
|
|
|
|
|
CdFastIoDispatch.PrepareMdlWrite = FsRtlPrepareMdlWriteDev;
|
|
|
|
|
CdFastIoDispatch.MdlWriteComplete = FsRtlMdlWriteCompleteDev;
|
|
|
|
|
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef _MSC_VER
|
2017-11-23 20:02:16 +00:00
|
|
|
|
#pragma prefast(pop)
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#endif
|
2017-11-23 20:02:16 +00:00
|
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
|
//
|
|
|
|
|
// Initialize the CdData structure.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
RtlZeroMemory( &CdData, sizeof( CD_DATA ));
|
|
|
|
|
|
|
|
|
|
CdData.NodeTypeCode = CDFS_NTC_DATA_HEADER;
|
|
|
|
|
CdData.NodeByteSize = sizeof( CD_DATA );
|
|
|
|
|
|
|
|
|
|
CdData.DriverObject = DriverObject;
|
|
|
|
|
CdData.FileSystemDeviceObject = FileSystemDeviceObject;
|
2017-11-23 20:05:28 +00:00
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
CdData.HddFileSystemDeviceObject = HddFileSystemDeviceObject;
|
|
|
|
|
#endif
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
|
|
|
|
InitializeListHead( &CdData.VcbQueue );
|
|
|
|
|
|
|
|
|
|
ExInitializeResourceLite( &CdData.DataResource );
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Initialize the cache manager callback routines
|
|
|
|
|
//
|
|
|
|
|
|
2017-11-23 20:05:28 +00:00
|
|
|
|
CdData.CacheManagerCallbacks.AcquireForLazyWrite = (PVOID)&CdAcquireForCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */
|
|
|
|
|
CdData.CacheManagerCallbacks.ReleaseFromLazyWrite = (PVOID)&CdReleaseFromCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */
|
|
|
|
|
CdData.CacheManagerCallbacks.AcquireForReadAhead = (PVOID)&CdAcquireForCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */
|
|
|
|
|
CdData.CacheManagerCallbacks.ReleaseFromReadAhead = (PVOID)&CdReleaseFromCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
|
|
|
|
CdData.CacheManagerVolumeCallbacks.AcquireForLazyWrite = &CdNoopAcquire;
|
|
|
|
|
CdData.CacheManagerVolumeCallbacks.ReleaseFromLazyWrite = &CdNoopRelease;
|
|
|
|
|
CdData.CacheManagerVolumeCallbacks.AcquireForReadAhead = &CdNoopAcquire;
|
|
|
|
|
CdData.CacheManagerVolumeCallbacks.ReleaseFromReadAhead = &CdNoopRelease;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Initialize the lock mutex and the async and delay close queues.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
ExInitializeFastMutex( &CdData.CdDataMutex );
|
|
|
|
|
InitializeListHead( &CdData.AsyncCloseQueue );
|
|
|
|
|
InitializeListHead( &CdData.DelayedCloseQueue );
|
|
|
|
|
|
|
|
|
|
CdData.CloseItem = IoAllocateWorkItem (FileSystemDeviceObject);
|
|
|
|
|
if (CdData.CloseItem == NULL) {
|
|
|
|
|
|
|
|
|
|
ExDeleteResourceLite( &CdData.DataResource );
|
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// Do the initialization based on the system size.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
switch (MmQuerySystemSize()) {
|
|
|
|
|
|
|
|
|
|
case MmSmallSystem:
|
|
|
|
|
|
|
|
|
|
CdData.IrpContextMaxDepth = 4;
|
|
|
|
|
CdData.MaxDelayedCloseCount = 8;
|
|
|
|
|
CdData.MinDelayedCloseCount = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MmMediumSystem:
|
|
|
|
|
|
|
|
|
|
CdData.IrpContextMaxDepth = 8;
|
|
|
|
|
CdData.MaxDelayedCloseCount = 24;
|
|
|
|
|
CdData.MinDelayedCloseCount = 6;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MmLargeSystem:
|
|
|
|
|
|
|
|
|
|
CdData.IrpContextMaxDepth = 32;
|
|
|
|
|
CdData.MaxDelayedCloseCount = 72;
|
|
|
|
|
CdData.MinDelayedCloseCount = 18;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|