ReactOS  0.4.14-dev-52-g6116262
rawfs.c
Go to the documentation of this file.
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/io/iomgr/rawfs.c
5 * PURPOSE: Raw File System Driver
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8 
9 /* INCLUDES *****************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* TYPES *******************************************************************/
16 
17 typedef struct _VCB
18 {
22  PVPB Vpb;
30 } VCB, *PVCB;
31 
32 typedef struct _VOLUME_DEVICE_OBJECT
33 {
35  VCB Vcb;
37 
38 #define VCB_STATE_LOCKED 0x00000001
39 #define VCB_STATE_DISMOUNTED 0x00000002
40 
41 /* GLOBALS *******************************************************************/
42 
44 
45 /* FUNCTIONS *****************************************************************/
46 
48 NTAPI
51  IN PVPB Vpb)
52 {
54 
55  PAGED_CODE();
56 
57  DPRINT("RawInitializeVcb(%p, %p, %p)\n", Vcb, TargetDeviceObject, Vpb);
58 
59  /* Clear it */
60  RtlZeroMemory(Vcb, sizeof(VCB));
61 
62  /* Associate to system objects */
63  Vcb->TargetDeviceObject = TargetDeviceObject;
64  Vcb->Vpb = Vpb;
65 
66  /* Initialize the lock */
67  KeInitializeMutex(&Vcb->Mutex, 0);
68 
69  Vcb->LocalVpb = ExAllocatePoolWithTag(NonPagedPool, sizeof(VPB), ' waR');
70  if (Vcb->LocalVpb == NULL)
71  {
73  }
74 
75  return Status;
76 }
77 
78 BOOLEAN
79 NTAPI
82 {
83  KIRQL OldIrql;
84  PVPB Vpb;
86 
87  DPRINT("RawCheckForDismount(%p, %lu)\n", Vcb, CreateOperation);
88 
89  ASSERT(KeReadStateMutant(&Vcb->Mutex) == 0);
90 
91  /* Lock VPB */
93 
94  /* Reference it and check if a create is being done */
95  Vpb = Vcb->Vpb;
96  if (Vcb->Vpb->ReferenceCount != CreateOperation)
97  {
98  /* Copy the VPB to our local own to prepare later dismount */
99  if (Vcb->LocalVpb != NULL)
100  {
101  RtlZeroMemory(Vcb->LocalVpb, sizeof(VPB));
102  Vcb->LocalVpb->Type = IO_TYPE_VPB;
103  Vcb->LocalVpb->Size = sizeof(VPB);
104  Vcb->LocalVpb->RealDevice = Vcb->Vpb->RealDevice;
105  Vcb->LocalVpb->DeviceObject = NULL;
106  Vcb->LocalVpb->Flags = Vcb->Vpb->Flags & VPB_REMOVE_PENDING;
107  Vcb->Vpb->RealDevice->Vpb = Vcb->LocalVpb;
108  Vcb->LocalVpb = NULL;
109  Vcb->Vpb->Flags |= VPB_PERSISTENT;
110  }
111 
112  /* Don't do anything */
113  Delete = FALSE;
114  }
115  else
116  {
117  /* Otherwise, delete the volume */
118  Delete = TRUE;
119 
120  /* Check if it has a VPB and unmount it */
121  if (Vpb->RealDevice->Vpb == Vpb)
122  {
123  Vpb->DeviceObject = NULL;
124  Vpb->Flags &= ~VPB_MOUNTED;
125  }
126  }
127 
128  /* Release the VPB lock */
130 
131  /* If we were to delete, delete the volume */
132  if (Delete)
133  {
134  /* Release our Vcb lock to be able delete us */
135  KeReleaseMutex(&Vcb->Mutex, FALSE);
136 
137  /* If we have a local VPB, we'll have to delete it
138  * but we won't dismount us - something went bad before
139  */
140  if (Vcb->LocalVpb)
141  {
142  ExFreePool(Vcb->LocalVpb);
143  }
144  /* Otherwise, delete any of the available VPB if its reference count is zero */
145  else if (Vcb->Vpb->ReferenceCount == 0)
146  {
147  ExFreePool(Vcb->Vpb);
148  }
149 
150  /* Dismount our device if possible */
151  ObDereferenceObject(Vcb->TargetDeviceObject);
154  Vcb));
155  }
156 
157  return Delete;
158 }
159 
160 NTSTATUS
161 NTAPI
163  IN PIRP Irp,
164  IN PVOID Context)
165 {
167 
168  DPRINT("RawCompletionRoutine(%p, %p, %p)\n", DeviceObject, Irp, Context);
169 
170  /* Check if this was a valid sync R/W request */
171  if (((IoStackLocation->MajorFunction == IRP_MJ_READ) ||
172  (IoStackLocation->MajorFunction == IRP_MJ_WRITE)) &&
173  ((IoStackLocation->FileObject)) &&
174  (FlagOn(IoStackLocation->FileObject->Flags, FO_SYNCHRONOUS_IO)) &&
175  (NT_SUCCESS(Irp->IoStatus.Status)))
176  {
177  /* Update byte offset */
178  IoStackLocation->FileObject->CurrentByteOffset.QuadPart +=
179  Irp->IoStatus.Information;
180  }
181 
182  /* Mark the IRP Pending if it was */
183  if (Irp->PendingReturned) IoMarkIrpPending(Irp);
184  return STATUS_SUCCESS;
185 }
186 
187 NTSTATUS
188 NTAPI
190  IN PIRP Irp,
191  IN PIO_STACK_LOCATION IoStackLocation)
192 {
194  PAGED_CODE();
195 
196  DPRINT("RawClose(%p, %p, %p)\n", Vcb, Irp, IoStackLocation);
197 
198  /* If its a stream, not much to do */
199  if (IoStackLocation->FileObject->Flags & FO_STREAM_FILE)
200  {
201  Irp->IoStatus.Status = STATUS_SUCCESS;
203  return STATUS_SUCCESS;
204  }
205 
206  /* Make sure we can clean up */
207  Status = KeWaitForSingleObject(&Vcb->Mutex,
208  Executive,
209  KernelMode,
210  FALSE,
211  NULL);
213 
214  /* Decrease the open count and check if this is a dismount */
215  Vcb->OpenCount--;
216  if (Vcb->OpenCount != 0 || !RawCheckForDismount(Vcb, FALSE))
217  {
218  KeReleaseMutex(&Vcb->Mutex, FALSE);
219  }
220 
221  /* Complete the request */
222  Irp->IoStatus.Status = STATUS_SUCCESS;
224  return STATUS_SUCCESS;
225 }
226 
227 NTSTATUS
228 NTAPI
230  IN PIRP Irp,
231  IN PIO_STACK_LOCATION IoStackLocation)
232 {
237  PAGED_CODE();
238 
239  DPRINT("RawCreate(%p, %p, %p)\n", Vcb, Irp, IoStackLocation);
240 
241  /* Make sure we can clean up */
242  Status = KeWaitForSingleObject(&Vcb->Mutex,
243  Executive,
244  KernelMode,
245  FALSE,
246  NULL);
248 
249  /* Check if this is a valid non-directory file open */
250  if ((!(IoStackLocation->FileObject) ||
251  !(IoStackLocation->FileObject->FileName.Length)) &&
252  ((IoStackLocation->Parameters.Create.Options >> 24) == FILE_OPEN) &&
253  (!(IoStackLocation->Parameters.Create.Options & FILE_DIRECTORY_FILE)))
254  {
255  /* Make sure the VCB isn't locked */
256  if (Vcb->VcbState & VCB_STATE_LOCKED)
257  {
258  /* Refuse the operation */
260  Irp->IoStatus.Information = 0;
261  }
262  else if (Vcb->VcbState & VCB_STATE_DISMOUNTED)
263  {
264  /* Refuse the operation */
266  Irp->IoStatus.Information = 0;
267  }
268  else
269  {
270  /* Setup share access */
271  ShareAccess = IoStackLocation->Parameters.Create.ShareAccess;
272  DesiredAccess = IoStackLocation->Parameters.Create.
273  SecurityContext->DesiredAccess;
274 
275  /* Check if this VCB was already opened */
276  if (Vcb->OpenCount > 0)
277  {
278  /* Try to see if we have access to it */
280  ShareAccess,
281  IoStackLocation->FileObject,
282  &Vcb->ShareAccess,
283  TRUE);
284  if (!NT_SUCCESS(Status)) Irp->IoStatus.Information = 0;
285  }
286 
287  /* Make sure we have access */
288  if (NT_SUCCESS(Status))
289  {
290  /* Check if this is the first open */
291  if (!Vcb->OpenCount)
292  {
293  /* Set the share access */
295  ShareAccess,
296  IoStackLocation->FileObject,
297  &Vcb->ShareAccess);
298  }
299 
300  /* Increase the open count and set the VPB */
301  Vcb->OpenCount++;
302  IoStackLocation->FileObject->Vpb = Vcb->Vpb;
303 
304  /* Set IRP status and disable intermediate buffering */
306  Irp->IoStatus.Information = FILE_OPENED;
307  IoStackLocation->FileObject->Flags |=
309  }
310  }
311  }
312  else
313  {
314  /* Invalid create request */
316  Irp->IoStatus.Information = 0;
317  }
318 
319  /* Check if the request failed */
320  if (!NT_SUCCESS(Status) && !Vcb->OpenCount)
321  {
322  /* Check if we can dismount the device */
324  }
325 
326  /* In case of deletion, the mutex is already released */
327  if (!Deleted)
328  {
329  KeReleaseMutex(&Vcb->Mutex, FALSE);
330  }
331 
332  /* Complete the request */
333  Irp->IoStatus.Status = Status;
335  return Status;
336 }
337 
338 NTSTATUS
339 NTAPI
341  IN PIRP Irp,
342  IN PIO_STACK_LOCATION IoStackLocation)
343 {
345  PAGED_CODE();
346 
347  DPRINT("RawReadWriteDeviceControl(%p, %p, %p)\n", Vcb, Irp, IoStackLocation);
348 
349  /* Don't do anything if the request was 0 bytes */
350  if (((IoStackLocation->MajorFunction == IRP_MJ_READ) ||
351  (IoStackLocation->MajorFunction == IRP_MJ_WRITE)) &&
352  !(IoStackLocation->Parameters.Read.Length))
353  {
354  /* Complete it */
355  Irp->IoStatus.Status = STATUS_SUCCESS;
357  return STATUS_SUCCESS;
358  }
359 
360  /* Copy the IRP stack location */
362 
363  /* Disable verifies */
365 
366  /* Setup a completion routine */
369  NULL,
370  TRUE,
371  TRUE,
372  TRUE);
373 
374  /* Call the next driver and exit */
375  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
376  return Status;
377 }
378 
379 NTSTATUS
380 NTAPI
382 {
387  PAGED_CODE();
388 
389  DPRINT("RawMountVolume(%p)\n", IoStackLocation);
390 
391  /* Remember our owner */
392  DeviceObject = IoStackLocation->Parameters.MountVolume.DeviceObject;
393 
394  /* Create the volume */
395  Status = IoCreateDevice(RawDiskDeviceObject->DriverObject,
396  sizeof(VOLUME_DEVICE_OBJECT) -
397  sizeof(DEVICE_OBJECT),
398  NULL,
400  0,
401  FALSE,
403  if (!NT_SUCCESS(Status)) return Status;
404 
405  /* Use highest alignment requirement */
406  Volume->DeviceObject.AlignmentRequirement = max(DeviceObject->
407  AlignmentRequirement,
408  Volume->DeviceObject.
409  AlignmentRequirement);
410 
411  /* Setup the VCB */
413  IoStackLocation->Parameters.MountVolume.DeviceObject,
414  IoStackLocation->Parameters.MountVolume.Vpb);
415  if (!NT_SUCCESS(Status))
416  {
418  return Status;
419  }
420 
421  /* Set dummy label and serial number */
422  Volume->Vcb.Vpb->SerialNumber = 0xFFFFFFFF;
423  Volume->Vcb.Vpb->VolumeLabelLength = 0;
424 
425  /* Setup the DO */
426  Volume->Vcb.Vpb->DeviceObject = &Volume->DeviceObject;
427  Volume->DeviceObject.StackSize = DeviceObject->StackSize + 1;
428  Volume->DeviceObject.SectorSize = DeviceObject->SectorSize;
429  Volume->DeviceObject.Flags |= DO_DIRECT_IO;
430  Volume->DeviceObject.Flags &= ~DO_DEVICE_INITIALIZING;
431 
432  /* Try to get associated FO (for notification) */
433  _SEH2_TRY
434  {
436  &(Volume->DeviceObject));
437  }
439  {
440  /* Get the exception code */
442  }
443  _SEH2_END;
444 
445  /* If failed, delete devive */
446  if (!NT_SUCCESS(Status))
447  {
449  return Status;
450  }
451 
452  /* Increment OpenCount by two to avoid dismount when RawClose() will be called on ObDereferenceObject() */
453  Volume->Vcb.OpenCount += 2;
454  /* Notify for successful mount */
456  /* It's not opened anymore, decrease the reference count to 0 to make FileObject being released */
458  Volume->Vcb.OpenCount -= 2;
459 
460  return Status;
461 }
462 
463 NTSTATUS
464 NTAPI
466  IN PVCB Vcb)
467 {
469  PAGED_CODE();
470 
471  DPRINT("RawUserFsCtrl(%p, %p)\n", IoStackLocation, Vcb);
472 
473  /* Lock the device */
474  Status = KeWaitForSingleObject(&Vcb->Mutex,
475  Executive,
476  KernelMode,
477  FALSE,
478  NULL);
480 
481  /* Check what kind of request this is */
482  switch (IoStackLocation->Parameters.FileSystemControl.FsControlCode)
483  {
484  /* Oplock requests */
489 
490  /* We don't handle them */
492  break;
493 
494  /* Lock request */
495  case FSCTL_LOCK_VOLUME:
496 
497  /* Make sure we're not locked, and that we're alone */
498  if (!(Vcb->VcbState & VCB_STATE_LOCKED) && (Vcb->OpenCount == 1))
499  {
500  /* Lock the VCB */
501  Vcb->VcbState |= VCB_STATE_LOCKED;
503  }
504  else
505  {
506  /* Otherwise, we can't do this */
508  }
509  break;
510 
511  /* Unlock request */
512  case FSCTL_UNLOCK_VOLUME:
513 
514  /* Make sure we're locked */
515  if (!(Vcb->VcbState & VCB_STATE_LOCKED))
516  {
517  /* Let caller know we're not */
519  }
520  else
521  {
522  /* Unlock the VCB */
523  Vcb->VcbState &= ~VCB_STATE_LOCKED;
525  }
526  break;
527 
528  /* Dismount request */
530 
531  /* Make sure we're locked */
532  if (Vcb->VcbState & VCB_STATE_LOCKED)
533  {
534  /* Do nothing, just return success */
536  }
537  else
538  {
539  /* We can't dismount, device not locked */
541  }
542  break;
543 
544  /* Unknown request */
545  default:
546 
547  /* Fail */
549  break;
550  }
551 
552  /* Unlock device */
553  KeReleaseMutex(&Vcb->Mutex, FALSE);
554 
555  /* In case of status change, notify */
556  switch (IoStackLocation->Parameters.FileSystemControl.FsControlCode)
557  {
558  case FSCTL_LOCK_VOLUME:
560  break;
561  case FSCTL_UNLOCK_VOLUME:
562  if (NT_SUCCESS(Status))
563  {
564  FsRtlNotifyVolumeEvent(IoStackLocation->FileObject, FSRTL_VOLUME_UNLOCK);
565  }
566  break;
569  break;
570  }
571 
572  return Status;
573 }
574 
575 NTSTATUS
576 NTAPI
578  IN PIRP Irp,
579  IN PIO_STACK_LOCATION IoStackLocation)
580 {
582  PAGED_CODE();
583 
584  DPRINT("RawFileSystemControl(%p, %p, %p)\n", Vcb, Irp, IoStackLocation);
585 
586  /* Check the kinds of FSCTLs that we support */
587  switch (IoStackLocation->MinorFunction)
588  {
589  /* User-mode request */
591 
592  /* Handle it */
593  Status = RawUserFsCtrl(IoStackLocation, Vcb);
594  break;
595 
596  /* Mount request */
597  case IRP_MN_MOUNT_VOLUME:
598 
599  /* Mount the volume */
600  Status = RawMountVolume(IoStackLocation);
601  break;
602 
604 
605  /* Lock the device */
606  Status = KeWaitForSingleObject(&Vcb->Mutex,
607  Executive,
608  KernelMode,
609  FALSE,
610  NULL);
612 
613  /* We don't do verifies */
615  Vcb->Vpb->RealDevice->Flags &= ~DO_VERIFY_VOLUME;
616 
617  /* Check if we should delete the device */
618  if (Vcb->OpenCount != 0 || !RawCheckForDismount(Vcb, FALSE))
619  {
620  /* In case of deletion, the mutex is already released */
621  KeReleaseMutex(&Vcb->Mutex, FALSE);
622  }
623 
624  /* We're done */
625  break;
626 
627  /* Invalid request */
628  default:
629 
630  /* Fail it */
632  break;
633  }
634 
635  /* Complete the request */
636  Irp->IoStatus.Status = Status;
638  return Status;
639 }
640 
641 NTSTATUS
642 NTAPI
644  IN PIRP Irp,
645  IN PIO_STACK_LOCATION IoStackLocation)
646 {
648  PULONG Length;
650  PAGED_CODE();
651 
652  DPRINT("RawQueryInformation(%p, %p, %p)\n", Vcb, Irp, IoStackLocation);
653 
654  /* Get information from the IRP */
655  Length = &IoStackLocation->Parameters.QueryFile.Length;
656  Buffer = Irp->AssociatedIrp.SystemBuffer;
657 
658  /* We only handle this request */
659  if (IoStackLocation->Parameters.QueryFile.FileInformationClass ==
661  {
662  /* Validate buffer size */
663  if (*Length < sizeof(FILE_POSITION_INFORMATION))
664  {
665  /* Invalid, fail */
666  Irp->IoStatus.Information = 0;
668  }
669  else
670  {
671  /* Get offset and update length */
672  Buffer->CurrentByteOffset = IoStackLocation->FileObject->
673  CurrentByteOffset;
674  *Length -= sizeof(FILE_POSITION_INFORMATION);
675 
676  /* Set IRP Status information */
677  Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
679  }
680  }
681 
682  /* Complete it */
683  Irp->IoStatus.Status = Status;
685  return Status;
686 }
687 
688 NTSTATUS
689 NTAPI
691  IN PIRP Irp,
692  IN PIO_STACK_LOCATION IoStackLocation)
693 {
697  PAGED_CODE();
698 
699  DPRINT("RawSetInformation(%p, %p, %p)\n", Vcb, Irp, IoStackLocation);
700 
701  /* Get information from the IRP */
702  Buffer = Irp->AssociatedIrp.SystemBuffer;
703 
704  /* We only handle this request */
705  if (IoStackLocation->Parameters.QueryFile.FileInformationClass ==
707  {
708  /* Get the DO */
709  DeviceObject = IoGetRelatedDeviceObject(IoStackLocation->FileObject);
710 
711  /* Make sure the offset is aligned */
712  if ((Buffer->CurrentByteOffset.LowPart &
714  {
715  /* It's not, fail */
717  }
718  else
719  {
720  /* Otherwise, set offset */
721  IoStackLocation->FileObject->CurrentByteOffset = Buffer->
722  CurrentByteOffset;
723 
724  /* Set IRP Status information */
726  }
727  }
728 
729  /* Complete it */
730  Irp->IoStatus.Status = Status;
732  return Status;
733 }
734 
735 NTSTATUS
736 NTAPI
740 {
741  PAGED_CODE();
742 
743  DPRINT("RawQueryFsVolumeInfo(%p, %p, %p)\n", Vcb, Buffer, Length);
744 
745  /* Clear the buffer and stub it out */
747  Buffer->VolumeSerialNumber = Vcb->Vpb->SerialNumber;
748  Buffer->SupportsObjects = FALSE;
749  Buffer->VolumeLabelLength = 0;
750 
751  /* Return length and success */
752  *Length -= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel[0]);
753  return STATUS_SUCCESS;
754 }
755 
756 NTSTATUS
757 NTAPI
761 {
762  PIRP Irp;
763  KEVENT Event;
766  PDEVICE_OBJECT RealDevice;
767  DISK_GEOMETRY DiskGeometry;
768  PARTITION_INFORMATION PartitionInformation;
769  BOOLEAN DiskHasPartitions;
770  PAGED_CODE();
771 
772  DPRINT("RawQueryFsSizeInfo(%p, %p, %p)\n", Vcb, Buffer, Length);
773 
774  /* Validate the buffer */
775  if (*Length < sizeof(FILE_FS_SIZE_INFORMATION))
776  {
777  /* Fail */
778  return STATUS_BUFFER_OVERFLOW;
779  }
780 
781  /* Clear the buffer, initialize the event and set the DO */
784  RealDevice = Vcb->Vpb->RealDevice;
785 
786  /* Build query IRP */
788  RealDevice,
789  NULL,
790  0,
791  &DiskGeometry,
792  sizeof(DISK_GEOMETRY),
793  FALSE,
794  &Event,
795  &IoStatusBlock);
796  if (!Irp) return STATUS_INSUFFICIENT_RESOURCES;
797 
798  /* Call driver and check if we're pending */
799  Status = IoCallDriver(RealDevice, Irp);
800  if (Status == STATUS_PENDING)
801  {
802  /* Wait on driver to finish */
804  Executive,
805  KernelMode,
806  FALSE,
807  NULL);
809  }
810 
811  /* Fail if we couldn't get CHS data */
812  if (!NT_SUCCESS(Status))
813  {
814  *Length = 0;
815  return Status;
816  }
817 
818  /* Check if this is a floppy */
819  if (FlagOn(RealDevice->Characteristics, FILE_FLOPPY_DISKETTE))
820  {
821  /* Floppies don't have partitions */
822  DiskHasPartitions = FALSE;
823  }
824  else
825  {
826  /* Setup query IRP */
829  RealDevice,
830  NULL,
831  0,
832  &PartitionInformation,
833  sizeof(PARTITION_INFORMATION),
834  FALSE,
835  &Event,
836  &IoStatusBlock);
837  if (!Irp) return STATUS_INSUFFICIENT_RESOURCES;
838 
839  /* Call driver and check if we're pending */
840  Status = IoCallDriver(RealDevice, Irp);
841  if (Status == STATUS_PENDING)
842  {
843  /* Wait on driver to finish */
845  Executive,
846  KernelMode,
847  FALSE,
848  NULL);
850  }
851 
852  /* If this was an invalid request, then the disk is not partitioned */
854  {
855  DiskHasPartitions = FALSE;
856  }
857  else
858  {
859  /* Otherwise, it must be */
861  DiskHasPartitions = TRUE;
862  }
863  }
864 
865  /* Set sector data */
866  Buffer->BytesPerSector = DiskGeometry.BytesPerSector;
867  Buffer->SectorsPerAllocationUnit = 1;
868 
869  /* Calculate allocation units */
870  if (DiskHasPartitions)
871  {
872  /* Use partition data */
873  Buffer->TotalAllocationUnits =
874  RtlExtendedLargeIntegerDivide(PartitionInformation.PartitionLength,
875  DiskGeometry.BytesPerSector,
876  NULL);
877  }
878  else
879  {
880  /* Use CHS */
881  Buffer->TotalAllocationUnits =
883  DiskGeometry.TracksPerCylinder *
884  DiskGeometry.SectorsPerTrack);
885  }
886 
887  /* Set available units */
888  Buffer->AvailableAllocationUnits = Buffer->TotalAllocationUnits;
889 
890  /* Return length and success */
891  *Length -= sizeof(FILE_FS_SIZE_INFORMATION);
892  return STATUS_SUCCESS;
893 }
894 
895 NTSTATUS
896 NTAPI
900 {
901  PAGED_CODE();
902 
903  DPRINT("RawQueryFsDeviceInfo(%p, %p, %p)\n", Vcb, Buffer, Length);
904 
905  /* Validate buffer */
906  if (*Length < sizeof(FILE_FS_DEVICE_INFORMATION))
907  {
908  /* Fail */
909  return STATUS_BUFFER_OVERFLOW;
910  }
911 
912  /* Clear buffer and write information */
914  Buffer->DeviceType = FILE_DEVICE_DISK;
915  Buffer->Characteristics = Vcb->TargetDeviceObject->Characteristics;
916 
917  /* Return length and success */
919  return STATUS_SUCCESS;
920 }
921 
922 NTSTATUS
923 NTAPI
927 {
928  const WCHAR szRawFSName[] = L"RAW";
930  PAGED_CODE();
931 
932  DPRINT("RawQueryFsAttributeInfo(%p, %p, %p)\n", Vcb, Buffer, Length);
933 
934  /* Check if the buffer is large enough for our name ("RAW") */
936  FileSystemName[sizeof(szRawFSName) / sizeof(szRawFSName[0])]);
938 
939  /* Output the data */
940  Buffer->FileSystemAttributes = 0;
941  Buffer->MaximumComponentNameLength = 0;
942  Buffer->FileSystemNameLength = 6;
943  RtlCopyMemory(&Buffer->FileSystemName[0], szRawFSName, sizeof(szRawFSName));
944 
945  /* Return length and success */
946  *Length -= ReturnLength;
947  return STATUS_SUCCESS;
948 }
949 
950 NTSTATUS
951 NTAPI
953  IN PIRP Irp,
954  IN PIO_STACK_LOCATION IoStackLocation)
955 {
957  ULONG Length;
958  PVOID Buffer;
959  PAGED_CODE();
960 
961  DPRINT("RawQueryVolumeInformation(%p, %p, %p)\n", Vcb, Irp, IoStackLocation);
962 
963  /* Get IRP Data */
964  Length = IoStackLocation->Parameters.QueryVolume.Length;
965  Buffer = Irp->AssociatedIrp.SystemBuffer;
966 
967  /* Check the kind of request */
968  switch (IoStackLocation->Parameters.QueryVolume.FsInformationClass)
969  {
970  /* Volume information request */
972 
974  break;
975 
976  /* File system size invormation */
978 
980  break;
981 
982  /* Device information */
984 
986  break;
987 
988  /* Attribute information */
990 
992  break;
993 
994  /* Invalid request */
995  default:
996 
997  /* Fail it */
999  break;
1000  }
1001 
1002  /* Set status and complete the request */
1003  Irp->IoStatus.Information = IoStackLocation->
1004  Parameters.QueryVolume.Length - Length;
1005  Irp->IoStatus.Status = Status;
1007  return Status;
1008 }
1009 
1010 NTSTATUS
1011 NTAPI
1013  IN PIRP Irp,
1014  IN PIO_STACK_LOCATION IoStackLocation)
1015 {
1016  NTSTATUS Status;
1017  PAGED_CODE();
1018 
1019  DPRINT("RawCleanup(%p, %p, %p)\n", Vcb, Irp, IoStackLocation);
1020 
1021  /* Make sure we can clean up */
1022  Status = KeWaitForSingleObject(&Vcb->Mutex,
1023  Executive,
1024  KernelMode,
1025  FALSE,
1026  NULL);
1028 
1029  /* Remove shared access */
1030  IoRemoveShareAccess(IoStackLocation->FileObject, &Vcb->ShareAccess);
1031 
1032  /* Check if we're to dismount */
1033  if (Vcb->VcbState & VCB_STATE_DISMOUNTED)
1034  {
1035  ASSERT(Vcb->OpenCount == 1);
1037  }
1038 
1039  KeReleaseMutex(&Vcb->Mutex, FALSE);
1040  Irp->IoStatus.Status = STATUS_SUCCESS;
1042  return STATUS_SUCCESS;
1043 }
1044 
1045 NTSTATUS
1046 NTAPI
1048  IN PIRP Irp)
1049 {
1052  PIO_STACK_LOCATION IoStackLocation;
1053  PVCB Vcb;
1054  PAGED_CODE();
1055 
1056  DPRINT("RawDispatch(%p, %p)\n", DeviceObject, Irp);
1057 
1058  /* Get the stack location */
1059  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
1060 
1061  /* Differentiate between Volume DO and FS DO */
1062  if ((DeviceObject->Size == sizeof(DEVICE_OBJECT)) &&
1063  !((IoStackLocation->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL) &&
1064  (IoStackLocation->MinorFunction == IRP_MN_MOUNT_VOLUME)))
1065  {
1066  /* This is an FS DO. Stub out the common calls */
1067  if ((IoStackLocation->MajorFunction == IRP_MJ_CREATE) ||
1068  (IoStackLocation->MajorFunction == IRP_MJ_CLEANUP) ||
1069  (IoStackLocation->MajorFunction == IRP_MJ_CLOSE))
1070  {
1071  /* Return success for them */
1073  }
1074  else
1075  {
1076  /* Anything else, we don't support */
1078  }
1079 
1080  /* Complete the request */
1081  Irp->IoStatus.Status = Status;
1083  return Status;
1084  }
1085 
1086  /* Otherwise, get our VCB and start handling the IRP */
1088  Vcb = &VolumeDeviceObject->Vcb;
1089 
1090  /* Check what kind of IRP this is */
1091  switch (IoStackLocation->MajorFunction)
1092  {
1093  /* Cleanup request */
1094  case IRP_MJ_CLEANUP:
1095 
1096  Status = RawCleanup(Vcb, Irp, IoStackLocation);
1097  break;
1098 
1099  /* Close request */
1100  case IRP_MJ_CLOSE:
1101 
1102  Status = RawClose(Vcb, Irp, IoStackLocation);
1103  break;
1104 
1105  /* Create request */
1106  case IRP_MJ_CREATE:
1107 
1108  Status = RawCreate(Vcb, Irp, IoStackLocation);
1109  break;
1110 
1111  /* FSCTL request */
1113 
1114  Status = RawFileSystemControl(Vcb, Irp, IoStackLocation);
1115  break;
1116 
1117  /* R/W or IOCTL request */
1118  case IRP_MJ_READ:
1119  case IRP_MJ_WRITE:
1120  case IRP_MJ_DEVICE_CONTROL:
1121 
1122  Status = RawReadWriteDeviceControl(Vcb, Irp, IoStackLocation);
1123  break;
1124 
1125  /* Information query request */
1127 
1128  Status = RawQueryInformation(Vcb, Irp, IoStackLocation);
1129  break;
1130 
1131  /* Information set request */
1133 
1134  Status = RawSetInformation(Vcb, Irp, IoStackLocation);
1135  break;
1136 
1137  /* Volume information request */
1139 
1140  Status = RawQueryVolumeInformation(Vcb, Irp, IoStackLocation);
1141  break;
1142 
1143  /* Unexpected request */
1144  default:
1145 
1146  /* Anything else is pretty bad */
1148  }
1149 
1150  /* Return the status */
1152  return Status;
1153 }
1154 
1155 NTSTATUS
1156 NTAPI
1158  IN PIRP Irp)
1159 {
1160  /* Unregister file systems */
1161 #if 0 // FIXME: This freezes ROS at shutdown. PnP Problem?
1165 
1166  /* Delete the devices */
1170 #endif
1171 
1172  /* Complete the request */
1173  Irp->IoStatus.Status = STATUS_SUCCESS;
1175  return STATUS_SUCCESS;
1176 }
1177 
1178 VOID
1179 NTAPI
1181 {
1182 #if 0 // FIXME: DriverUnload is never called
1183  /* Dereference device objects */
1187 #endif
1188 }
1189 
1190 INIT_FUNCTION
1191 NTSTATUS
1192 NTAPI
1195 {
1197  NTSTATUS Status;
1198 
1199  /* Create the raw disk device */
1200  RtlInitUnicodeString(&DeviceName, L"\\Device\\RawDisk");
1202  0,
1203  NULL,
1205  0,
1206  FALSE,
1208  if (!NT_SUCCESS(Status)) return Status;
1209 
1210  /* Create the raw CDROM device */
1211  RtlInitUnicodeString(&DeviceName, L"\\Device\\RawCdRom");
1213  0,
1214  NULL,
1216  0,
1217  FALSE,
1219  if (!NT_SUCCESS(Status)) return Status;
1220 
1221  /* Create the raw tape device */
1222  RtlInitUnicodeString(&DeviceName, L"\\Device\\RawTape");
1224  0,
1225  NULL,
1227  0,
1228  FALSE,
1230  if (!NT_SUCCESS(Status)) return Status;
1231 
1232  /* Set Direct I/O for all devices */
1236 
1237  /* Set generic stubs */
1248 
1249  /* Shutdown and unload */
1252 
1253  /* Register the file systems */
1257 
1258 #if 0 // FIXME: DriverUnload is never called
1259  /* Reference device objects */
1263 #endif
1264  return STATUS_SUCCESS;
1265 }
1266 
1267 /* EOF */
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
NTSTATUS NTAPI RawQueryFsDeviceInfo(IN PVCB Vcb, IN PFILE_FS_DEVICE_INFORMATION Buffer, IN OUT PULONG Length)
Definition: rawfs.c:897
#define IN
Definition: typedefs.h:38
#define FSRTL_VOLUME_DISMOUNT
Definition: ntifs_ex.h:439
#define FILE_DEVICE_DISK
Definition: winioctl.h:112
#define max(a, b)
Definition: svc.c:63
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LARGE_INTEGER PartitionLength
Definition: ntdddisk.h:394
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FsRtlEnterFileSystem
#define FILE_DEVICE_TAPE_FILE_SYSTEM
Definition: winioctl.h:137
#define FSRTL_VOLUME_DISMOUNT_FAILED
Definition: ntifs_ex.h:440
#define FsRtlExitFileSystem
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
static void CreateOperation(FILE *Out, unsigned Bpp, PROPINFO RopInfo, unsigned SourceBpp, unsigned Bits)
Definition: gendib.c:247
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
VOID NTAPI IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:1061
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_OPENED
Definition: nt_native.h:769
#define FSRTL_VOLUME_UNLOCK
Definition: ntifs_ex.h:443
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1209
Definition: cdstruc.h:504
PVPB Vpb
Definition: cdstruc.h:517
NTSTATUS NTAPI RawDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: rawfs.c:1047
ULONG BytesPerSector
Definition: ntdddisk.h:376
NTSTATUS NTAPI RawClose(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
Definition: rawfs.c:189
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define VPB_PERSISTENT
Definition: iotypes.h:1766
ULONG TracksPerCylinder
Definition: ntdddisk.h:374
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
VOID NTAPI IoSetShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, OUT PSHARE_ACCESS ShareAccess)
Definition: file.c:3516
#define VCB_STATE_LOCKED
Definition: rawfs.c:38
#define STATUS_WRONG_VOLUME
Definition: udferr_usr.h:140
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define FO_NO_INTERMEDIATE_BUFFERING
Definition: iotypes.h:1735
ULONG VcbState
Definition: cdstruc.h:546
NTSTATUS NTAPI RawInitializeVcb(IN OUT PVCB Vcb, IN PDEVICE_OBJECT TargetDeviceObject, IN PVPB Vpb)
Definition: rawfs.c:49
struct _FILE_POSITION_INFORMATION FILE_POSITION_INFORMATION
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
PFILE_OBJECT NTAPI IoCreateStreamFileObjectLite(IN PFILE_OBJECT FileObject OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL)
Definition: file.c:3198
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
Definition: create.c:4157
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
Definition: file.c:3477
#define PAGED_CODE()
Definition: video.h:57
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
_SEH2_TRY
Definition: create.c:4250
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1733
#define FSRTL_VOLUME_LOCK_FAILED
Definition: ntifs_ex.h:442
SHARE_ACCESS ShareAccess
Definition: fatstruc.h:302
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG CLONG
Definition: umtypes.h:126
#define IRP_MN_VERIFY_VOLUME
Definition: iotypes.h:4049
#define IO_DISK_INCREMENT
Definition: iotypes.h:568
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FSCTL_OPLOCK_BREAK_NOTIFY
Definition: nt_native.h:831
NTSTATUS NTAPI RawCreate(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
Definition: rawfs.c:229
NTSTATUS NTAPI RawQueryFsAttributeInfo(IN PVCB Vcb, IN PFILE_FS_ATTRIBUTE_INFORMATION Buffer, IN OUT PULONG Length)
Definition: rawfs.c:924
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
NTSTATUS NTAPI RawShutdown(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: rawfs.c:1157
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct _VOLUME_DEVICE_OBJECT * PVOLUME_DEVICE_OBJECT
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define IoCompleteRequest
Definition: irp.c:1240
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1507
NTSYSAPI LONGLONG WINAPI RtlExtendedLargeIntegerDivide(LONGLONG, INT, INT *)
Definition: bufpool.h:45
NTSTATUS NTAPI RawQueryFsSizeInfo(IN PVCB Vcb, IN PFILE_FS_SIZE_INFORMATION Buffer, IN OUT PULONG Length)
Definition: rawfs.c:758
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
NTSYSAPI LONGLONG WINAPI RtlExtendedIntegerMultiply(LONGLONG, INT)
#define VPB_REMOVE_PENDING
Definition: ntifs_ex.h:428
DEVICE_OBJECT DeviceObject
Definition: cdstruc.h:735
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:113
#define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE
Definition: nt_native.h:829
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4048
#define IRP_MN_USER_FS_REQUEST
Definition: iotypes.h:4047
NTSTATUS NTAPI RawFileSystemControl(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
Definition: rawfs.c:577
NTSTATUS NTAPI RawSetInformation(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
Definition: rawfs.c:690
NTSTATUS NTAPI FsRtlNotifyVolumeEvent(IN PFILE_OBJECT FileObject, IN ULONG EventCode)
Definition: pnp.c:38
struct _VCB * PVCB
__wchar_t WCHAR
Definition: xmlstorage.h:180
PDEVICE_OBJECT TargetDeviceObject
Definition: cdstruc.h:523
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define FSCTL_REQUEST_OPLOCK_LEVEL_2
Definition: nt_native.h:827
PDEVICE_OBJECT RawTapeDeviceObject
Definition: rawfs.c:43
LARGE_INTEGER Cylinders
Definition: ntdddisk.h:372
struct _VCB VCB
#define IRP_MJ_FILE_SYSTEM_CONTROL
ULONG SectorsPerTrack
Definition: ntdddisk.h:375
#define Vcb
Definition: cdprocs.h:1425
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1955
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI RawCleanup(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
Definition: rawfs.c:1012
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:88
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
static const WCHAR L[]
Definition: oid.c:1250
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2180
struct _FILE_FS_DEVICE_INFORMATION FILE_FS_DEVICE_INFORMATION
BOOLEAN NTAPI RawCheckForDismount(IN PVCB Vcb, IN BOOLEAN CreateOperation)
Definition: rawfs.c:80
NTSTATUS NTAPI RawUserFsCtrl(IN PIO_STACK_LOCATION IoStackLocation, IN PVCB Vcb)
Definition: rawfs.c:465
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FSCTL_REQUEST_OPLOCK_LEVEL_1
Definition: nt_native.h:826
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
CLONG OpenCount
Definition: rawfs.c:26
ULONG AlignmentRequirement
Definition: env_spec_w32.h:420
ULONG BytesPerSector
Definition: rawfs.c:28
#define IO_TYPE_VPB
PDEVICE_OBJECT RawDiskDeviceObject
Definition: rawfs.c:43
struct _VPB VPB
Status
Definition: gdiplustypes.h:24
struct _FILE_FS_SIZE_INFORMATION FILE_FS_SIZE_INFORMATION
#define FILE_OPEN
Definition: from_kernel.h:54
LARGE_INTEGER SectorsOnDisk
Definition: rawfs.c:29
NTSTATUS NTAPI IoCheckShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess, IN BOOLEAN Update)
Definition: file.c:3389
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
LONG NTAPI KeReadStateMutant(IN PKMUTANT Mutant)
Definition: mutex.c:87
#define FSRTL_VOLUME_LOCK
Definition: ntifs_ex.h:441
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
USHORT NodeByteSize
Definition: rawfs.c:20
_SEH2_END
Definition: create.c:4424
VOID NTAPI RawUnload(IN PDRIVER_OBJECT DriverObject)
Definition: rawfs.c:1180
struct _VOLUME_DEVICE_OBJECT VOLUME_DEVICE_OBJECT
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
NTSTATUS NTAPI RawMountVolume(IN PIO_STACK_LOCATION IoStackLocation)
Definition: rawfs.c:381
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI RawReadWriteDeviceControl(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
Definition: rawfs.c:340
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
KMUTEX Mutex
Definition: rawfs.c:25
INIT_FUNCTION NTSTATUS NTAPI RawFsDriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
Definition: rawfs.c:1193
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define IRP_MJ_READ
Definition: rdpdr.c:46
VOID NTAPI IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:992
USHORT NodeTypeCode
Definition: rawfs.c:19
#define IRP_MJ_CLEANUP
Definition: iotypes.h:166
#define OUT
Definition: typedefs.h:39
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
Definition: winioctl.h:108
#define ObReferenceObject
Definition: obfuncs.h:204
#define VCB_STATE_DISMOUNTED
Definition: rawfs.c:39
#define STATUS_VOLUME_DISMOUNTED
Definition: ntstatus.h:733
#define STATUS_NOT_LOCKED
Definition: ntstatus.h:265
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2181
#define FSRTL_VOLUME_MOUNT
Definition: ntifs_ex.h:444
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS NTAPI RawQueryFsVolumeInfo(IN PVCB Vcb, IN PFILE_FS_VOLUME_INFORMATION Buffer, IN OUT PULONG Length)
Definition: rawfs.c:737
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
PVPB LocalVpb
Definition: rawfs.c:23
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1664
PDEVICE_OBJECT RawCdromDeviceObject
Definition: rawfs.c:43
return STATUS_SUCCESS
Definition: btrfs.c:2966
NTSTATUS NTAPI RawCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: rawfs.c:162
IoMarkIrpPending(Irp)
#define VPB_MOUNTED
Definition: iotypes.h:1764
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
NTSTATUS NTAPI RawQueryVolumeInformation(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
Definition: rawfs.c:952
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1220
HRESULT Create([out]ITransactionReceiver **ppReceiver)
ULONG ACCESS_MASK
Definition: nt_native.h:40
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
#define FO_STREAM_FILE
Definition: iotypes.h:1740
NTSTATUS NTAPI RawQueryInformation(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
Definition: rawfs.c:643
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52