ReactOS  0.4.14-dev-342-gdc047f9
cdfs.c File Reference
#include "fs_rec.h"
#include <debug.h>
#include "cdfs.h"
Include dependency graph for cdfs.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI FsRecIsCdfsVolume (IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize)
 
NTSTATUS NTAPI FsRecCdfsFsControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file cdfs.c.

Function Documentation

◆ FsRecCdfsFsControl()

NTSTATUS NTAPI FsRecCdfsFsControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 66 of file cdfs.c.

68 {
69  PDEVICE_OBJECT MountDevice;
71  PIO_STACK_LOCATION Stack;
73  PAGED_CODE();
74 
75  /* Get the I/O Stack and check the function type */
77  switch (Stack->MinorFunction)
78  {
80 
81  /* Assume failure */
83 
84  /* Get the device object and request the sector size */
85  MountDevice = Stack->Parameters.MountVolume.DeviceObject;
86  if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize))
87  {
88  /* Check if it's an actual CDFS (ISO-9660) volume */
89  if (FsRecIsCdfsVolume(MountDevice, SectorSize))
90  {
91  /* It is! */
93  }
94  }
95 
96  break;
97 
99 
100  /* Load the file system */
102  L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Cdfs");
103  break;
104 
105  default:
106 
107  /* Invalid request */
109  }
110 
111  /* Return Status */
112  return Status;
113 }
_In_ PIRP Irp
Definition: csq.h:116
BOOLEAN NTAPI FsRecGetDeviceSectorSize(IN PDEVICE_OBJECT DeviceObject, OUT PULONG SectorSize)
Definition: blockdev.c:80
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MN_LOAD_FILE_SYSTEM
Definition: iotypes.h:4050
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_FS_DRIVER_REQUIRED
Definition: ntstatus.h:631
#define PAGED_CODE()
Definition: video.h:57
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4048
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
BOOLEAN NTAPI FsRecIsCdfsVolume(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize)
Definition: cdfs.c:23
NTSTATUS NTAPI FsRecLoadFileSystem(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR DriverServiceName)
Definition: fs_rec.c:23
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG SectorSize
Definition: halfuncs.h:291
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772

Referenced by FsRecFsControl().

◆ FsRecIsCdfsVolume()

BOOLEAN NTAPI FsRecIsCdfsVolume ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  SectorSize 
)

Definition at line 23 of file cdfs.c.

25 {
26  BOOLEAN bReturnValue = FALSE;
28  PVD_HEADER pVdHeader = NULL;
29  PAGED_CODE();
30 
31  // Read the Primary Volume Descriptor.
32  Offset.QuadPart = VD_HEADER_OFFSET;
33  if (!FsRecReadBlock(DeviceObject, &Offset, sizeof(VD_HEADER), SectorSize, (PVOID*)&pVdHeader, NULL))
34  {
35  // We cannot read this block, so no reason to let the CDFS driver try it.
36  goto Cleanup;
37  }
38 
39  // Verify the fields.
40  if (pVdHeader->Type != VD_TYPE_PRIMARY)
41  goto Cleanup;
42 
43  DPRINT("pVdHeader->Type verified!\n");
44 
46  goto Cleanup;
47 
48  DPRINT("pVdHeader->Identifier verified!\n");
49 
50  if (pVdHeader->Version != VD_VERSION)
51  goto Cleanup;
52 
53  DPRINT("pVdHeader->Version verified! This is a CDFS volume!\n");
54 
55  bReturnValue = TRUE;
56 
57 Cleanup:
58  if (pVdHeader)
59  ExFreePool(pVdHeader);
60 
61  return bReturnValue;
62 }
#define VD_VERSION
Definition: cdfs.h:24
#define TRUE
Definition: types.h:120
#define VD_TYPE_PRIMARY
Definition: cdfs.h:23
#define PAGED_CODE()
Definition: video.h:57
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define VD_IDENTIFIER_LENGTH
Definition: cdfs.h:22
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define VD_IDENTIFIER
Definition: cdfs.h:21
Definition: iso.h:49
static const WCHAR Cleanup[]
Definition: register.c:80
BOOLEAN NTAPI FsRecReadBlock(IN PDEVICE_OBJECT DeviceObject, IN PLARGE_INTEGER Offset, IN ULONG Length, IN ULONG SectorSize, IN OUT PVOID *Buffer, OUT PBOOLEAN DeviceError OPTIONAL)
Definition: blockdev.c:152
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define VD_HEADER_OFFSET
Definition: cdfs.h:20
_In_ ULONG SectorSize
Definition: halfuncs.h:291
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

Referenced by FsRecCdfsFsControl().