mirror of
https://github.com/reactos/reactos.git
synced 2024-10-02 07:26:47 +00:00
688875e411
The main motivation to switch to that newer driver is, that our old one simply can not read all isos. Especially complex ones made trouble and were only shown as empty in explorer. It is still possible to build and use the old driver when needed, only thing that needs to be done for that is to revert 0.4.8-dev-164-gec6b3ecbe4
Porting back the state up to 0.4.8-release-100-g8f947b5 implies: Fixing the following JIRA-IDs (or avoid introducing them): CORE-18029 "Mute noisy DPRINT 'SectionObject has ImageSection'" CORE-17405 "Fix a macro-copy-paste and shrink the binary size" CORE-15659 "Unable to build the gcc Release version in Windows using RosBE 2.1.6 (module cdfs fails)" CORE-14315 "CDFS_NEW assertion during first stage setup due to new CcPerformReadAhead" CORE-14128 "Avast! Free Antivirus 7.0 hangs the system when trying to detect a newly created virus" CORE-14067 "CDFS_NEW assertions and exceptions" CORE-14003 "Shutting down LiveCD asserts since introduction of MS PL CDFS_NEW" CORE-13184 "Restore ability to install from disk-image" by picking the following commits: 0.4.8-release-100-g8f947b5322
[NTOSKRNL] Mute noisy DPRINT 'SectionObject has ImageSection' CORE-18029 0.4.8-release-80-geb1ea19588
[CDFS_NEW] == 0.4.15-dev-1456-g889eab7
CORE-17405 0.4.8-release-62-g8c07aad4a8
[CDFS_NEW/XDK] == 0.4.11-dev-39-ga2f9762
+ 0.4.11-dev-40-g6d7ec8c
CORE-14067 0.4.8-release-3-g5d976d04e8
[CDFS_NEW] == 0.4.12-dev-431-gbccad87f3c
+ 0.4.12-dev-432-g3463b2db9f
CORE-15659 0.4.8-RC-3-g51f9494d48
[CDFS_NEW] superseded later by the proper fix 0.4.8-release-62-g8c07aad4a8
CORE-14067 0.4.8-dev-1069-ga5e89014dc
[CDFS_NEW] CORE-14315 0.4.8-dev-475-ga59d4674de
[NTOSKRNL] io/iomgr/device.c (forgotten assert) CORE-14128 0.4.8-dev-221-g9d67a24799
[CDFS_NEW] 0.4.8-dev-220-g67a7e45e35
[CDFS_NEW/DOC] 0.4.8-dev-219-g6a3bbf24e0
[CDFS_NEW] 0.4.8-dev-218-gec26cde4a1
[CDFS_NEW] 0.4.8-dev-217-gbc2378a356
[CDFS_NEW] 0.4.8-dev-216-g5429771b99
[CDFS_NEW] 0.4.8-dev-215-gfd34548263
[CDFS_NEW] Sync with MS-PL driver 0.4.8-dev-164-gec6b3ecbe4
[FILESYSTEMS] switch from CDFS to CDFS_NEW in CMakeLists.txt 0.4.8-dev-160-g2b217e4ecf
[NTOSKRNL] Mute spam CcSetReadAheadGranularity() 0.4.8-dev-159-g64cb138a67
[NTOSKRNL] Mute spam CcPurgeCacheSection() 0.4.8-dev-150-gf723d230a0
[CDFS_NEW] 0.4.8-dev-133-gfaee3753ea
[CDFS_NEW] CORE-14003 0.4.8-dev-132-g1d777ffab5
[NTOSKRNL] iofunc.c CORE-14003 0.4.8-dev-131-gc3d5a3f2bd
[NTOSKRNL] iofunc.c CORE-14003 0.4.8-dev-130-g3b64f7f8fb
[NTOSKRNL] ob/obref.c & co CORE-14003 0.4.8-dev-129-g7eefe70294
[NTOSKRNL] io/iomgr.c & co CORE-14003 0.4.8-dev-127-g5f255827d3
[CDFS_NEW] 0.4.8-dev-126-g1bef48796e
[NTOSKRNL] just a comment, superseded later 0.4.8-dev-125-gcbf0430b56
[CDFS_NEW] 0.4.8-dev-123-gf88fe43abd
[NTOSKRNL] io/iomgr/device.c (forbidden DPRINT) 0.4.8-dev-122-g6c73385625
[CDFS_NEW] CORE-13184 0.4.8-dev-97-g94298313c0
[CDFS_NEW] 0.4.8-dev-95-ge88eeb21af
[CDFS_NEW/NTOSKRNL] CcWaitForCurrentLazyWriterActivity() stub return Success 0.4.8-dev-94-g03d5be6437
[CDFS_NEW] 0.4.8-dev-93-gfa1c60db50
[CDFS_NEW] 0.4.8-dev-92-g8b2fd60829
[CDFS_NEW] 0.4.8-dev-91-ge4da7ecc50
[CDFS_NEW] 0.4.8-dev-90-g7b19676e2b
[CDFS_NEW] 0.4.8-dev-89-g3d4b8783fd
[CDFS_NEW] 0.4.8-dev-88-g818025ecc8
[CDFS_NEW] 0.4.8-dev-87-g2639dd6736
[CDFS_NEW] 0.4.8-dev-86-g755bdb5d0b
[CDFS_NEW] 0.4.8-dev-85-g3cbcb1bade
[CDFS_NEW] and mute spam in opcode INSTEAD of picking: 0.4.8-dev-165-g2284a457a3
[NTOSKRNL] oplock.c Fixup 0.4.8-dev-163-gd3d5853956
[NTOSKRNL] oplock.c Implement oplock-support 0.4.12-dev-232-gf488102c86
[CDFS] was also left out for now I am aware, that the backport introduces white-space-glitches within CDFS_NEW. I decided to live with them in favor of better sync to master and newer releases.
454 lines
12 KiB
C
Executable file
454 lines
12 KiB
C
Executable file
/*++
|
||
|
||
Copyright (c) 1989-2000 Microsoft Corporation
|
||
|
||
Module Name:
|
||
|
||
CdInit.c
|
||
|
||
Abstract:
|
||
|
||
This module implements the DRIVER_INITIALIZATION routine for Cdfs
|
||
|
||
|
||
--*/
|
||
|
||
#include "cdprocs.h"
|
||
|
||
//
|
||
// The Bug check file id for this module
|
||
//
|
||
|
||
#define BugCheckFileId (CDFS_BUG_CHECK_CDINIT)
|
||
|
||
// Tell prefast the function type.
|
||
DRIVER_INITIALIZE DriverEntry;
|
||
|
||
NTSTATUS
|
||
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
|
||
DriverEntry(
|
||
_In_ PDRIVER_OBJECT DriverObject,
|
||
_In_ PUNICODE_STRING RegistryPath
|
||
);
|
||
|
||
|
||
// tell prefast this is a driver unload function
|
||
DRIVER_UNLOAD CdUnload;
|
||
|
||
VOID
|
||
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
|
||
CdUnload(
|
||
_In_ PDRIVER_OBJECT DriverObject
|
||
);
|
||
|
||
NTSTATUS
|
||
CdInitializeGlobalData (
|
||
_In_ PDRIVER_OBJECT DriverObject,
|
||
_In_ PDEVICE_OBJECT FileSystemDeviceObject
|
||
#ifdef __REACTOS__
|
||
,
|
||
IN PDEVICE_OBJECT HddFileSystemDeviceObject
|
||
#endif
|
||
);
|
||
|
||
#ifdef ALLOC_PRAGMA
|
||
#pragma alloc_text(INIT, DriverEntry)
|
||
#pragma alloc_text(PAGE, CdUnload)
|
||
#pragma alloc_text(INIT, CdInitializeGlobalData)
|
||
#endif
|
||
|
||
|
||
//
|
||
// Local support routine
|
||
//
|
||
|
||
NTSTATUS
|
||
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
|
||
DriverEntry(
|
||
_In_ PDRIVER_OBJECT DriverObject,
|
||
_In_ PUNICODE_STRING RegistryPath
|
||
)
|
||
|
||
/*++
|
||
|
||
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;
|
||
FS_FILTER_CALLBACKS FilterCallbacks;
|
||
#ifdef __REACTOS__
|
||
PDEVICE_OBJECT HddFileSystemDeviceObject;
|
||
#endif
|
||
|
||
UNREFERENCED_PARAMETER( RegistryPath );
|
||
|
||
//
|
||
// 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;
|
||
}
|
||
|
||
#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
|
||
#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.")
|
||
#endif
|
||
|
||
DriverObject->DriverUnload = CdUnload;
|
||
|
||
//
|
||
// 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] =
|
||
DriverObject->MajorFunction[IRP_MJ_WRITE] =
|
||
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] =
|
||
DriverObject->MajorFunction[IRP_MJ_PNP] =
|
||
DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = (PDRIVER_DISPATCH) CdFsdDispatch;
|
||
#ifdef _MSC_VER
|
||
#pragma prefast(pop)
|
||
|
||
#pragma prefast(suppress: 28175, "this is a file system driver, we're allowed to touch FastIoDispatch.")
|
||
#endif
|
||
DriverObject->FastIoDispatch = &CdFastIoDispatch;
|
||
|
||
//
|
||
// 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 );
|
||
#ifdef __REACTOS__
|
||
IoDeleteDevice (HddFileSystemDeviceObject);
|
||
#endif
|
||
return Status;
|
||
}
|
||
|
||
//
|
||
// Initialize the global data structures
|
||
//
|
||
|
||
#ifndef __REACTOS__
|
||
Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject );
|
||
#else
|
||
Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject, HddFileSystemDeviceObject );
|
||
#endif
|
||
if (!NT_SUCCESS (Status)) {
|
||
IoDeleteDevice (CdfsFileSystemDeviceObject);
|
||
#ifdef __REACTOS__
|
||
IoDeleteDevice (HddFileSystemDeviceObject);
|
||
#endif
|
||
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;
|
||
#ifdef __REACTOS__
|
||
HddFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM;
|
||
#endif
|
||
|
||
IoRegisterFileSystem( CdfsFileSystemDeviceObject );
|
||
ObReferenceObject (CdfsFileSystemDeviceObject);
|
||
#ifdef __REACTOS__
|
||
IoRegisterFileSystem( HddFileSystemDeviceObject );
|
||
ObReferenceObject (HddFileSystemDeviceObject);
|
||
#endif
|
||
|
||
#ifdef CDFS_TELEMETRY_DATA
|
||
//
|
||
// Initialize Telemetry
|
||
//
|
||
|
||
CdInitializeTelemetry();
|
||
|
||
#endif
|
||
|
||
//
|
||
// And return to our caller
|
||
//
|
||
|
||
return( STATUS_SUCCESS );
|
||
}
|
||
|
||
|
||
VOID
|
||
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
|
||
CdUnload(
|
||
_In_ PDRIVER_OBJECT DriverObject
|
||
)
|
||
/*++
|
||
|
||
Routine Description:
|
||
|
||
This routine unload routine for CDFS.
|
||
|
||
Arguments:
|
||
|
||
DriverObject - Supplies the driver object for CDFS.
|
||
|
||
Return Value:
|
||
|
||
None.
|
||
|
||
--*/
|
||
{
|
||
PIRP_CONTEXT IrpContext;
|
||
|
||
PAGED_CODE();
|
||
|
||
UNREFERENCED_PARAMETER( DriverObject );
|
||
|
||
//
|
||
// 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);
|
||
#ifdef __REACTOS__
|
||
ObDereferenceObject (CdData.HddFileSystemDeviceObject);
|
||
#endif
|
||
}
|
||
|
||
//
|
||
// Local support routine
|
||
//
|
||
|
||
NTSTATUS
|
||
CdInitializeGlobalData (
|
||
_In_ PDRIVER_OBJECT DriverObject,
|
||
_In_ PDEVICE_OBJECT FileSystemDeviceObject
|
||
#ifdef __REACTOS__
|
||
,
|
||
IN PDEVICE_OBJECT HddFileSystemDeviceObject
|
||
#endif
|
||
)
|
||
|
||
/*++
|
||
|
||
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);
|
||
|
||
#ifdef _MSC_VER
|
||
#pragma prefast(push)
|
||
#pragma prefast(disable:28155, "these are all correct")
|
||
#endif
|
||
|
||
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
|
||
//
|
||
// This callback has been replaced by CdFilterCallbackAcquireForCreateSection.
|
||
//
|
||
|
||
CdFastIoDispatch.AcquireFileForNtCreateSection = NULL;
|
||
CdFastIoDispatch.ReleaseFileForNtCreateSection = CdReleaseForCreateSection;
|
||
CdFastIoDispatch.FastIoQueryNetworkOpenInfo = CdFastQueryNetworkInfo; // QueryNetworkInfo
|
||
|
||
CdFastIoDispatch.MdlRead = FsRtlMdlReadDev;
|
||
CdFastIoDispatch.MdlReadComplete = FsRtlMdlReadCompleteDev;
|
||
CdFastIoDispatch.PrepareMdlWrite = FsRtlPrepareMdlWriteDev;
|
||
CdFastIoDispatch.MdlWriteComplete = FsRtlMdlWriteCompleteDev;
|
||
|
||
#ifdef _MSC_VER
|
||
#pragma prefast(pop)
|
||
#endif
|
||
|
||
//
|
||
// 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;
|
||
#ifdef __REACTOS__
|
||
CdData.HddFileSystemDeviceObject = HddFileSystemDeviceObject;
|
||
#endif
|
||
|
||
InitializeListHead( &CdData.VcbQueue );
|
||
|
||
ExInitializeResourceLite( &CdData.DataResource );
|
||
|
||
//
|
||
// Initialize the cache manager callback routines
|
||
//
|
||
|
||
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" */
|
||
|
||
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;
|
||
}
|
||
|