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 NTAPI
/* ReactOS Change: GCC Does not support STDCALL by default */
34 CdDevCtrlCompletionRoutine (
35 _In_ PDEVICE_OBJECT DeviceObject
,
37 _In_reads_opt_(_Inexpressible_("varies")) PVOID Contxt
41 #pragma alloc_text(PAGE, CdCommonDevControl)
47 _Inout_ PIRP_CONTEXT IrpContext
,
64 TYPE_OF_OPEN TypeOfOpen
;
68 PIO_STACK_LOCATION IrpSp
;
69 PIO_STACK_LOCATION NextIrpSp
;
74 // Extract and decode the file object.
77 IrpSp
= IoGetCurrentIrpStackLocation( Irp
);
79 TypeOfOpen
= CdDecodeFileObject( IrpContext
,
85 // The only type of opens we accept are user volume opens.
88 if (TypeOfOpen
!= UserVolumeOpen
) {
90 CdCompleteRequest( IrpContext
, Irp
, STATUS_INVALID_PARAMETER
);
91 return STATUS_INVALID_PARAMETER
;
94 if (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_CDROM_READ_TOC
) {
97 // Verify the Vcb in this case to detect if the volume has changed.
100 CdVerifyVcb( IrpContext
, Fcb
->Vcb
);
103 // Handle the case of the disk type ourselves.
106 } else if (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_CDROM_DISK_TYPE
) {
109 // Verify the Vcb in this case to detect if the volume has changed.
112 CdVerifyVcb( IrpContext
, Fcb
->Vcb
);
115 // Check the size of the output buffer.
118 if (IrpSp
->Parameters
.DeviceIoControl
.OutputBufferLength
< sizeof( CDROM_DISK_DATA
)) {
120 CdCompleteRequest( IrpContext
, Irp
, STATUS_BUFFER_TOO_SMALL
);
121 return STATUS_BUFFER_TOO_SMALL
;
125 // Copy the data from the Vcb.
128 ((PCDROM_DISK_DATA
) Irp
->AssociatedIrp
.SystemBuffer
)->DiskData
= Fcb
->Vcb
->DiskFlags
;
130 Irp
->IoStatus
.Information
= sizeof( CDROM_DISK_DATA
);
131 CdCompleteRequest( IrpContext
, Irp
, STATUS_SUCCESS
);
132 return STATUS_SUCCESS
;
136 // Get the next stack location, and copy over the stack parameter
140 NextIrpSp
= IoGetNextIrpStackLocation( Irp
);
145 // Set up the completion routine
148 IoSetCompletionRoutine( Irp
,
149 CdDevCtrlCompletionRoutine
,
159 Status
= IoCallDriver( IrpContext
->Vcb
->TargetDeviceObject
, Irp
);
162 // Cleanup our Irp Context. The driver has completed the Irp.
165 CdCompleteRequest( IrpContext
, NULL
, STATUS_SUCCESS
);
172 // Local support routine
176 NTAPI
/* ReactOS Change: GCC Does not support STDCALL by default */
177 CdDevCtrlCompletionRoutine (
178 _In_ PDEVICE_OBJECT DeviceObject
,
180 _In_reads_opt_(_Inexpressible_("varies")) PVOID Contxt
185 // Add the hack-o-ramma to fix formats.
188 if (Irp
->PendingReturned
) {
190 IoMarkIrpPending( Irp
);
193 return STATUS_SUCCESS
;
195 UNREFERENCED_PARAMETER( DeviceObject
);
196 UNREFERENCED_PARAMETER( Contxt
);