Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

204 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. DevCtrl.c
  5. Abstract:
  6. This module implements the File System Device Control routines for Cdfs
  7. called by the dispatch driver.
  8. // @@BEGIN_DDKSPLIT
  9. Author:
  10. Brian Andrew [BrianAn] 04-Mar-1991
  11. Revision History:
  12. // @@END_DDKSPLIT
  13. --*/
  14. #include "CdProcs.h"
  15. //
  16. // The Bug check file id for this module
  17. //
  18. #define BugCheckFileId (CDFS_BUG_CHECK_DEVCTRL)
  19. //
  20. // Local support routines
  21. //
  22. NTSTATUS
  23. CdDevCtrlCompletionRoutine (
  24. IN PDEVICE_OBJECT DeviceObject,
  25. IN PIRP Irp,
  26. IN PVOID Contxt
  27. );
  28. #ifdef ALLOC_PRAGMA
  29. #pragma alloc_text(PAGE, CdCommonDevControl)
  30. #endif
  31. NTSTATUS
  32. CdCommonDevControl (
  33. IN PIRP_CONTEXT IrpContext,
  34. IN PIRP Irp
  35. )
  36. /*++
  37. Routine Description:
  38. Arguments:
  39. Return Value:
  40. --*/
  41. {
  42. NTSTATUS Status;
  43. TYPE_OF_OPEN TypeOfOpen;
  44. PFCB Fcb;
  45. PCCB Ccb;
  46. PIO_STACK_LOCATION IrpSp;
  47. PIO_STACK_LOCATION NextIrpSp;
  48. PVOID TargetBuffer = NULL;
  49. PAGED_CODE();
  50. //
  51. // Extract and decode the file object.
  52. //
  53. IrpSp = IoGetCurrentIrpStackLocation( Irp );
  54. TypeOfOpen = CdDecodeFileObject( IrpContext,
  55. IrpSp->FileObject,
  56. &Fcb,
  57. &Ccb );
  58. //
  59. // The only type of opens we accept are user volume opens.
  60. //
  61. if (TypeOfOpen != UserVolumeOpen) {
  62. CdCompleteRequest( IrpContext, Irp, STATUS_INVALID_PARAMETER );
  63. return STATUS_INVALID_PARAMETER;
  64. }
  65. if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_READ_TOC) {
  66. //
  67. // Verify the Vcb in this case to detect if the volume has changed.
  68. //
  69. CdVerifyVcb( IrpContext, Fcb->Vcb );
  70. //
  71. // Handle the case of the disk type ourselves.
  72. //
  73. } else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_DISK_TYPE) {
  74. //
  75. // Verify the Vcb in this case to detect if the volume has changed.
  76. //
  77. CdVerifyVcb( IrpContext, Fcb->Vcb );
  78. //
  79. // Check the size of the output buffer.
  80. //
  81. if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof( CDROM_DISK_DATA )) {
  82. CdCompleteRequest( IrpContext, Irp, STATUS_BUFFER_TOO_SMALL );
  83. return STATUS_BUFFER_TOO_SMALL;
  84. }
  85. //
  86. // Copy the data from the Vcb.
  87. //
  88. ((PCDROM_DISK_DATA) Irp->AssociatedIrp.SystemBuffer)->DiskData = Fcb->Vcb->DiskFlags;
  89. Irp->IoStatus.Information = sizeof( CDROM_DISK_DATA );
  90. CdCompleteRequest( IrpContext, Irp, STATUS_SUCCESS );
  91. return STATUS_SUCCESS;
  92. }
  93. //
  94. // Get the next stack location, and copy over the stack parameter
  95. // information.
  96. //
  97. NextIrpSp = IoGetNextIrpStackLocation( Irp );
  98. *NextIrpSp = *IrpSp;
  99. //
  100. // Set up the completion routine
  101. //
  102. IoSetCompletionRoutine( Irp,
  103. CdDevCtrlCompletionRoutine,
  104. NULL,
  105. TRUE,
  106. TRUE,
  107. TRUE );
  108. //
  109. // Send the request.
  110. //
  111. Status = IoCallDriver( IrpContext->Vcb->TargetDeviceObject, Irp );
  112. //
  113. // Cleanup our Irp Context. The driver has completed the Irp.
  114. //
  115. CdCompleteRequest( IrpContext, NULL, STATUS_SUCCESS );
  116. return Status;
  117. }
  118. //
  119. // Local support routine
  120. //
  121. NTSTATUS
  122. CdDevCtrlCompletionRoutine (
  123. IN PDEVICE_OBJECT DeviceObject,
  124. IN PIRP Irp,
  125. IN PVOID Contxt
  126. )
  127. {
  128. //
  129. // Add the hack-o-ramma to fix formats.
  130. //
  131. if (Irp->PendingReturned) {
  132. IoMarkIrpPending( Irp );
  133. }
  134. return STATUS_SUCCESS;
  135. UNREFERENCED_PARAMETER( DeviceObject );
  136. UNREFERENCED_PARAMETER( Contxt );
  137. }