ReactOS 0.4.16-dev-91-g764881a
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
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}
63
67 IN PIRP Irp)
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}
114
115/* EOF */
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI FsRecIsCdfsVolume(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize)
Definition: cdfs.c:23
NTSTATUS NTAPI FsRecCdfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: cdfs.c:66
#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
_In_ PIRP Irp
Definition: csq.h:116
#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
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_FS_DRIVER_REQUIRED
Definition: ntstatus.h:645
#define L(x)
Definition: ntvdm.h:50
#define DPRINT
Definition: sndvol32.h:73
Definition: iso.h:49
char Type
Definition: cdfs.h:13
char Identifier[5]
Definition: cdfs.h:14
char Version
Definition: cdfs.h:15
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
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
#define IRP_MN_LOAD_FILE_SYSTEM
Definition: iotypes.h:4406
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4404