3 Copyright (c) 1989-2000 Microsoft Corporation
11 This module implements the File System Device Control routines for Cdfs
12 called by the dispatch driver.
20 // The Bug check file id for this module
23 #define BugCheckFileId (CDFS_BUG_CHECK_DEVCTRL)
26 // Local support routines
29 // Tell prefast this is a completion routine
30 IO_COMPLETION_ROUTINE CdDevCtrlCompletionRoutine
;
33 CdDevCtrlCompletionRoutine (
34 _In_ PDEVICE_OBJECT DeviceObject
,
36 _In_reads_opt_(_Inexpressible_("varies")) PVOID Contxt
40 #pragma alloc_text(PAGE, CdCommonDevControl)
46 _Inout_ PIRP_CONTEXT IrpContext
,
63 TYPE_OF_OPEN TypeOfOpen
;
67 PIO_STACK_LOCATION IrpSp
;
68 PIO_STACK_LOCATION NextIrpSp
;
73 // Extract and decode the file object.
76 IrpSp
= IoGetCurrentIrpStackLocation( Irp
);
78 TypeOfOpen
= CdDecodeFileObject( IrpContext
,
84 // The only type of opens we accept are user volume opens.
87 if (TypeOfOpen
!= UserVolumeOpen
) {
89 CdCompleteRequest( IrpContext
, Irp
, STATUS_INVALID_PARAMETER
);
90 return STATUS_INVALID_PARAMETER
;
93 if (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_CDROM_READ_TOC
) {
96 // Verify the Vcb in this case to detect if the volume has changed.
99 CdVerifyVcb( IrpContext
, Fcb
->Vcb
);
102 // Handle the case of the disk type ourselves.
105 } else if (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_CDROM_DISK_TYPE
) {
108 // Verify the Vcb in this case to detect if the volume has changed.
111 CdVerifyVcb( IrpContext
, Fcb
->Vcb
);
114 // Check the size of the output buffer.
117 if (IrpSp
->Parameters
.DeviceIoControl
.OutputBufferLength
< sizeof( CDROM_DISK_DATA
)) {
119 CdCompleteRequest( IrpContext
, Irp
, STATUS_BUFFER_TOO_SMALL
);
120 return STATUS_BUFFER_TOO_SMALL
;
124 // Copy the data from the Vcb.
127 ((PCDROM_DISK_DATA
) Irp
->AssociatedIrp
.SystemBuffer
)->DiskData
= Fcb
->Vcb
->DiskFlags
;
129 Irp
->IoStatus
.Information
= sizeof( CDROM_DISK_DATA
);
130 CdCompleteRequest( IrpContext
, Irp
, STATUS_SUCCESS
);
131 return STATUS_SUCCESS
;
135 // Get the next stack location, and copy over the stack parameter
139 NextIrpSp
= IoGetNextIrpStackLocation( Irp
);
144 // Set up the completion routine
147 IoSetCompletionRoutine( Irp
,
148 CdDevCtrlCompletionRoutine
,
158 Status
= IoCallDriver( IrpContext
->Vcb
->TargetDeviceObject
, Irp
);
161 // Cleanup our Irp Context. The driver has completed the Irp.
164 CdCompleteRequest( IrpContext
, NULL
, STATUS_SUCCESS
);
171 // Local support routine
175 CdDevCtrlCompletionRoutine (
176 _In_ PDEVICE_OBJECT DeviceObject
,
178 _In_reads_opt_(_Inexpressible_("varies")) PVOID Contxt
183 // Add the hack-o-ramma to fix formats.
186 if (Irp
->PendingReturned
) {
188 IoMarkIrpPending( Irp
);
191 return STATUS_SUCCESS
;
193 UNREFERENCED_PARAMETER( DeviceObject
);
194 UNREFERENCED_PARAMETER( Contxt
);