ReactOS 0.4.15-dev-7670-g69b08be
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;
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}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI FsRecIsCdfsVolume(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize)
Definition: cdfs.c:23
_In_ PIRP Irp
Definition: csq.h:116
BOOLEAN NTAPI FsRecGetDeviceSectorSize(IN PDEVICE_OBJECT DeviceObject, OUT PULONG SectorSize)
Definition: blockdev.c:80
NTSTATUS NTAPI FsRecLoadFileSystem(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR DriverServiceName)
Definition: fs_rec.c:23
Status
Definition: gdiplustypes.h:25
#define STATUS_FS_DRIVER_REQUIRED
Definition: ntstatus.h:645
#define L(x)
Definition: ntvdm.h:50
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
_In_ ULONG SectorSize
Definition: halfuncs.h:291
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define IRP_MN_LOAD_FILE_SYSTEM
Definition: iotypes.h:4406
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4404

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
58 if (pVdHeader)
59 ExFreePool(pVdHeader);
60
61 return bReturnValue;
62}
unsigned char BOOLEAN
#define VD_VERSION
Definition: cdfs.h:24
#define VD_IDENTIFIER
Definition: cdfs.h:21
#define VD_TYPE_PRIMARY
Definition: cdfs.h:23
#define VD_IDENTIFIER_LENGTH
Definition: cdfs.h:22
#define VD_HEADER_OFFSET
Definition: cdfs.h:20
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR Cleanup[]
Definition: register.c:80
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
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_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define DPRINT
Definition: sndvol32.h:71
Definition: iso.h:50

Referenced by FsRecCdfsFsControl().