ReactOS  0.4.15-dev-1070-ge1a01de
cdfs.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS File System Recognizer
3  * LICENSE: GPL-2.0 (https://spdx.org/licenses/GPL-2.0)
4  * PURPOSE: CDFS Recognizer
5  * COPYRIGHT: Copyright 2002 Eric Kohl
6  * Copyright 2007 Alex Ionescu <alex.ionescu@reactos.org>
7  * Copyright 2017 Colin Finck <colin@reactos.org>
8  */
9 
10 /* INCLUDES *****************************************************************/
11 
12 #include "fs_rec.h"
13 
14 #define NDEBUG
15 #include <debug.h>
16 
17 #include "cdfs.h"
18 
19 /* FUNCTIONS ****************************************************************/
20 
21 BOOLEAN
22 NTAPI
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 }
63 
65 NTAPI
67  IN PIRP Irp)
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 }
114 
115 /* EOF */
#define VD_VERSION
Definition: cdfs.h:24
#define IN
Definition: typedefs.h:39
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
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:4385
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define VD_TYPE_PRIMARY
Definition: cdfs.h:23
#define STATUS_FS_DRIVER_REQUIRED
Definition: ntstatus.h:645
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define FALSE
Definition: types.h:117
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
NTSTATUS NTAPI FsRecCdfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: cdfs.c:66
#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
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4383
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
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
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
BOOLEAN NTAPI FsRecIsCdfsVolume(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize)
Definition: cdfs.c:23
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI FsRecLoadFileSystem(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR DriverServiceName)
Definition: fs_rec.c:23
unsigned int ULONG
Definition: retypes.h:1
#define VD_HEADER_OFFSET
Definition: cdfs.h:20
_In_ ULONG SectorSize
Definition: halfuncs.h:291
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define PAGED_CODE()