ReactOS 0.4.16-dev-336-gb667d82
fs_rec.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS File System Recognizer
4 * FILE: drivers/filesystems/fs_rec/fs_rec.h
5 * PURPOSE: Main Header File
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7 * Eric Kohl
8 */
9
10#ifndef _FS_REC_H
11#define _FS_REC_H
12
13#include <ntifs.h>
14
15/* Tag for memory allocations */
16#define FSREC_TAG 'cRsF'
17
18/* UDFS Offsets */
19#define UDFS_VRS_START_OFFSET 32768
20#define UDFS_AVDP_SECTOR 256
21
22/* Non-standard rounding macros */
23#ifndef ROUND_UP
24#define ROUND_UP(n, align) \
25 ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
26
27#define ROUND_DOWN(n, align) \
28 (((ULONG)n) & ~((align) - 1l))
29#endif
30
31/* Conversion types and macros taken from internal ntifs headers */
32typedef union _UCHAR1
33{
34 UCHAR Uchar[1];
37
38typedef union _UCHAR2
39{
40 UCHAR Uchar[2];
43
44typedef union _UCHAR4
45{
46 UCHAR Uchar[4];
49
50#define CopyUchar1(Dst,Src) { \
51 *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
52}
53
54#define CopyUchar2(Dst,Src) { \
55 *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
56}
57
58#define CopyUchar4(Dst,Src) { \
59 *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
60}
61
62#define FatUnpackBios(Bios,Pbios) { \
63 CopyUchar2(&(Bios)->BytesPerSector, &(Pbios)->BytesPerSector[0] ); \
64 CopyUchar1(&(Bios)->SectorsPerCluster, &(Pbios)->SectorsPerCluster[0]); \
65 CopyUchar2(&(Bios)->ReservedSectors, &(Pbios)->ReservedSectors[0] ); \
66 CopyUchar1(&(Bios)->Fats, &(Pbios)->Fats[0] ); \
67 CopyUchar2(&(Bios)->RootEntries, &(Pbios)->RootEntries[0] ); \
68 CopyUchar2(&(Bios)->Sectors, &(Pbios)->Sectors[0] ); \
69 CopyUchar1(&(Bios)->Media, &(Pbios)->Media[0] ); \
70 CopyUchar2(&(Bios)->SectorsPerFat, &(Pbios)->SectorsPerFat[0] ); \
71 CopyUchar2(&(Bios)->SectorsPerTrack, &(Pbios)->SectorsPerTrack[0] ); \
72 CopyUchar2(&(Bios)->Heads, &(Pbios)->Heads[0] ); \
73 CopyUchar4(&(Bios)->HiddenSectors, &(Pbios)->HiddenSectors[0] ); \
74 CopyUchar4(&(Bios)->LargeSectors, &(Pbios)->LargeSectors[0] ); \
75}
76
77/* Packed versions of the BPB and Boot Sector */
79{
83 UCHAR Fats[1];
85 UCHAR Sectors[2];
86 UCHAR Media[1];
89 UCHAR Heads[2];
93
94typedef struct _PACKED_BOOT_SECTOR
95{
96 UCHAR Jump[3];
97 UCHAR Oem[8];
102 UCHAR Id[4];
103 UCHAR VolumeLabel[11];
104 UCHAR SystemId[8];
106
107/* Unpacked version of the BPB */
108typedef struct BIOS_PARAMETER_BLOCK
109{
113 UCHAR Fats;
116 UCHAR Media;
123 union
124 {
126 struct
127 {
132 };
133 };
139
140/* UDFS Structures */
141#include <pshpack1.h>
142typedef struct _TAG
143{
153
154typedef struct _EXTENT
155{
159
160typedef struct _AVDP
161{
166#include <poppack.h>
167
168/* Filesystem Types */
170{
182
183/* FS Recognizer State */
184typedef enum _FS_REC_STATE
185{
190
191/* Device extension */
192typedef struct _DEVICE_EXTENSION
193{
198
199/* Prototypes */
201NTAPI
204 IN PIRP Irp
205);
206
208NTAPI
211 IN PIRP Irp
212);
213
215NTAPI
218 IN PIRP Irp
219);
220
222NTAPI
225 IN PIRP Irp
226);
227
229NTAPI
232 IN PIRP Irp
233);
234
236NTAPI
239 IN PIRP Irp
240);
241
243NTAPI
246 IN PIRP Irp
247);
248
250NTAPI
253 IN PIRP Irp
254);
255
257NTAPI
260 IN PIRP Irp
261);
262
264NTAPI
269);
270
272NTAPI
276);
277
279NTAPI
286 OUT PBOOLEAN DeviceError OPTIONAL
287);
288
290NTAPI
293 IN PWCHAR DriverServiceName
294);
295
296#endif /* _FS_REC_H */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
unsigned int ULONG32
Definition: basetsd.h:123
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI FsRecExtFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: ext.c:30
union _UCHAR2 UCHAR2
struct _TAG TAG
Definition: db.cpp:145
enum _FILE_SYSTEM_TYPE * PFILE_SYSTEM_TYPE
struct _EXTENT EXTENT
struct _EXTENT * PEXTENT
enum _FS_REC_STATE FS_REC_STATE
struct _DEVICE_EXTENSION DEVICE_EXTENSION
_FILE_SYSTEM_TYPE
Definition: fs_rec.h:170
@ FS_TYPE_UDFS
Definition: fs_rec.h:175
@ FS_TYPE_BTRFS
Definition: fs_rec.h:177
@ FS_TYPE_NTFS
Definition: fs_rec.h:173
@ FS_TYPE_FFS
Definition: fs_rec.h:179
@ FS_TYPE_CDFS
Definition: fs_rec.h:174
@ FS_TYPE_FATX
Definition: fs_rec.h:180
@ FS_TYPE_EXT
Definition: fs_rec.h:176
@ FS_TYPE_UNUSED
Definition: fs_rec.h:171
@ FS_TYPE_REISERFS
Definition: fs_rec.h:178
@ FS_TYPE_VFAT
Definition: fs_rec.h:172
struct _PACKED_BIOS_PARAMETER_BLOCK PACKED_BIOS_PARAMETER_BLOCK
union _UCHAR1 * PUCHAR1
struct _PACKED_BOOT_SECTOR * PPACKED_BOOT_SECTOR
struct BIOS_PARAMETER_BLOCK * PBIOS_PARAMETER_BLOCK
NTSTATUS NTAPI FsRecLoadFileSystem(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR DriverServiceName)
Definition: fs_rec.c:23
NTSTATUS NTAPI FsRecFatxFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fatx.c:66
enum _FILE_SYSTEM_TYPE FILE_SYSTEM_TYPE
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
enum _FS_REC_STATE * PFS_REC_STATE
NTSTATUS NTAPI FsRecNtfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: ntfs.c:52
struct _TAG * PTAG
struct _AVDP * PAVDP
struct _PACKED_BOOT_SECTOR PACKED_BOOT_SECTOR
NTSTATUS NTAPI FsRecFfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: ffs.c:43
struct _PACKED_BIOS_PARAMETER_BLOCK * PPACKED_BIOS_PARAMETER_BLOCK
BOOLEAN NTAPI FsRecGetDeviceSectors(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, OUT PLARGE_INTEGER SectorCount)
Definition: blockdev.c:24
BOOLEAN NTAPI FsRecGetDeviceSectorSize(IN PDEVICE_OBJECT DeviceObject, OUT PULONG SectorSize)
Definition: blockdev.c:80
union _UCHAR4 UCHAR4
NTSTATUS NTAPI FsRecReiserfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: reiserfs.c:43
_FS_REC_STATE
Definition: fs_rec.h:185
@ Pending
Definition: fs_rec.h:186
@ Unloading
Definition: fs_rec.h:188
@ Loaded
Definition: fs_rec.h:187
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
union _UCHAR4 * PUCHAR4
union _UCHAR2 * PUCHAR2
NTSTATUS NTAPI FsRecVfatFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fat.c:100
NTSTATUS NTAPI FsRecBtrfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: btrfs.c:30
NTSTATUS NTAPI FsRecCdfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: cdfs.c:66
union _UCHAR1 UCHAR1
struct _AVDP AVDP
NTSTATUS NTAPI FsRecUdfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: udfs.c:106
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
ULONG SectorCount
Definition: part_xbox.c:31
unsigned short USHORT
Definition: pedump.c:61
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
USHORT SectorsPerTrack
Definition: fat.h:112
USHORT ReservedSectors
Definition: fat.h:106
USHORT BytesPerSector
Definition: fat.h:104
ULONG Reserved1
Definition: fat.h:123
USHORT ExtendedFlags
Definition: fat.h:118
ULONG ActiveFat
Definition: fat.h:120
USHORT FsVersion
Definition: fat.h:126
USHORT Sectors
Definition: fat.h:109
ULONG MirrorDisabled
Definition: fat.h:122
USHORT Heads
Definition: fat.h:113
ULONG32 LargeSectors
Definition: fat.h:115
USHORT BackupBootSector
Definition: fat.h:129
ULONG Reserved0
Definition: fat.h:121
USHORT FsInfoSector
Definition: fat.h:128
ULONG32 LargeSectorsPerFat
Definition: fat.h:116
ULONG32 RootDirFirstCluster
Definition: fat.h:127
ULONG32 HiddenSectors
Definition: fat.h:114
USHORT RootEntries
Definition: fat.h:108
UCHAR SectorsPerCluster
Definition: fat.h:105
USHORT SectorsPerFat
Definition: fat.h:111
Definition: fs_rec.h:161
TAG DescriptorTag
Definition: fs_rec.h:162
EXTENT ReserveVolumeDescriptorExtent
Definition: fs_rec.h:164
EXTENT MainVolumeDescriptorExtent
Definition: fs_rec.h:163
FS_REC_STATE State
Definition: fs_rec.h:194
FILE_SYSTEM_TYPE FsType
Definition: fs_rec.h:195
PDEVICE_OBJECT Alternate
Definition: fs_rec.h:196
ULONG Location
Definition: fs_rec.h:157
ULONG Length
Definition: fs_rec.h:156
UCHAR SectorsPerFat[2]
Definition: fat.h:63
UCHAR BytesPerSector[2]
Definition: fat.h:56
UCHAR ReservedSectors[2]
Definition: fat.h:58
UCHAR SectorsPerTrack[2]
Definition: fat.h:64
UCHAR SectorsPerCluster[1]
Definition: fat.h:57
UCHAR HiddenSectors[4]
Definition: fat.h:66
UCHAR Id[4]
Definition: fat.h:169
UCHAR CurrentHead
Definition: fat.h:167
UCHAR Jump[3]
Definition: fat.h:163
UCHAR Oem[8]
Definition: fat.h:164
UCHAR SystemId[8]
Definition: fat.h:171
UCHAR PhysicalDriveNumber
Definition: fat.h:166
UCHAR Signature
Definition: fat.h:168
PACKED_BIOS_PARAMETER_BLOCK PackedBpb
Definition: fat.h:165
UCHAR VolumeLabel[11]
Definition: fat.h:170
Definition: fs_rec.h:143
USHORT Identifier
Definition: fs_rec.h:144
UCHAR Checksum
Definition: fs_rec.h:146
USHORT Version
Definition: fs_rec.h:145
USHORT CrcLength
Definition: fs_rec.h:150
USHORT SerialNumber
Definition: fs_rec.h:148
USHORT Crc
Definition: fs_rec.h:149
ULONG Location
Definition: fs_rec.h:151
UCHAR Reserved
Definition: fs_rec.h:147
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * PBOOLEAN
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
UCHAR ForceAlignment
Definition: cdprocs.h:1663
USHORT ForceAlignment
Definition: cdprocs.h:1668
ULONG ForceAlignment
Definition: cdprocs.h:1673
unsigned char Uchar
Definition: utypes.h:45
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ ULONG SectorSize
Definition: halfuncs.h:291
unsigned char UCHAR
Definition: xmlstorage.h:181