ReactOS  0.4.14-dev-608-gd495a4f
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 */
32 typedef union _UCHAR1
33 {
34  UCHAR Uchar[1];
36 } UCHAR1, *PUCHAR1;
37 
38 typedef union _UCHAR2
39 {
40  UCHAR Uchar[2];
42 } UCHAR2, *PUCHAR2;
43 
44 typedef union _UCHAR4
45 {
46  UCHAR Uchar[4];
48 } UCHAR4, *PUCHAR4;
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 */
78 typedef struct _PACKED_BIOS_PARAMETER_BLOCK
79 {
83  UCHAR Fats[1];
84  UCHAR RootEntries[2];
85  UCHAR Sectors[2];
86  UCHAR Media[1];
89  UCHAR Heads[2];
93 
94 typedef 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 */
108 typedef struct BIOS_PARAMETER_BLOCK
109 {
113  UCHAR Fats;
115  USHORT Sectors;
116  UCHAR Media;
119  USHORT Heads;
123  union
124  {
126  struct
127  {
128  ULONG ActiveFat:4;
129  ULONG Reserved0:3;
131  ULONG Reserved1:8;
132  };
133  };
139 
140 /* UDFS Structures */
141 #include <pshpack1.h>
142 typedef struct _TAG
143 {
152 } TAG, *PTAG;
153 
154 typedef struct _EXTENT
155 {
158 } EXTENT, *PEXTENT;
159 
160 typedef struct _AVDP
161 {
165 } AVDP, *PAVDP;
166 #include <poppack.h>
167 
168 /* Filesystem Types */
169 typedef enum _FILE_SYSTEM_TYPE
170 {
181 
182 /* FS Recognizer State */
183 typedef enum _FS_REC_STATE
184 {
189 
190 /* Device extension */
191 typedef struct _DEVICE_EXTENSION
192 {
197 
198 /* Prototypes */
199 NTSTATUS
200 NTAPI
203  IN PIRP Irp
204 );
205 
206 NTSTATUS
207 NTAPI
210  IN PIRP Irp
211 );
212 
213 NTSTATUS
214 NTAPI
217  IN PIRP Irp
218 );
219 
220 NTSTATUS
221 NTAPI
224  IN PIRP Irp
225 );
226 
227 NTSTATUS
228 NTAPI
231  IN PIRP Irp
232 );
233 
234 NTSTATUS
235 NTAPI
238  IN PIRP Irp
239 );
240 
241 NTSTATUS
242 NTAPI
245  IN PIRP Irp
246 );
247 
248 NTSTATUS
249 NTAPI
252  IN PIRP Irp
253 );
254 
255 BOOLEAN
256 NTAPI
261 );
262 
263 BOOLEAN
264 NTAPI
268 );
269 
270 BOOLEAN
271 NTAPI
275  IN ULONG Length,
277  IN OUT PVOID *Buffer,
278  OUT PBOOLEAN DeviceError OPTIONAL
279 );
280 
281 NTSTATUS
282 NTAPI
285  IN PWCHAR DriverServiceName
286 );
287 
288 #endif /* _FS_REC_H */
ULONG ForceAlignment
Definition: cdprocs.h:1683
struct _EXTENT * PEXTENT
union _UCHAR2 * PUCHAR2
UCHAR Jump[3]
Definition: fat.h:163
#define IN
Definition: typedefs.h:38
enum _FS_REC_STATE FS_REC_STATE
struct _TAG * PTAG
unsigned int ULONG32
Definition: basetsd.h:125
union _UCHAR2 UCHAR2
UCHAR BytesPerSector[2]
Definition: fat.h:56
NTSTATUS NTAPI FsRecCdfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: cdfs.c:66
struct _PACKED_BOOT_SECTOR PACKED_BOOT_SECTOR
NTSTATUS NTAPI FsRecExt2FsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: ext2.c:30
unsigned char Uchar
Definition: utypes.h:45
_In_ PIRP Irp
Definition: csq.h:116
USHORT SectorsPerFat
Definition: fat.h:111
ULONG MirrorDisabled
Definition: fat.h:122
USHORT BackupBootSector
Definition: fat.h:129
LONG NTSTATUS
Definition: precomp.h:26
USHORT ForceAlignment
Definition: cdprocs.h:1678
ULONG Reserved0
Definition: fat.h:121
union _UCHAR1 UCHAR1
union _UCHAR1 * PUCHAR1
USHORT FsVersion
Definition: fat.h:126
UCHAR SystemId[8]
Definition: fat.h:171
NTSTATUS NTAPI FsRecUdfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: udfs.c:106
uint16_t * PWCHAR
Definition: typedefs.h:54
struct _PACKED_BIOS_PARAMETER_BLOCK PACKED_BIOS_PARAMETER_BLOCK
struct BIOS_PARAMETER_BLOCK BIOS_PARAMETER_BLOCK
UCHAR VolumeLabel[11]
Definition: fat.h:170
EXTENT ReserveVolumeDescriptorExtent
Definition: fs_rec.h:164
ULONG Reserved1
Definition: fat.h:123
enum _FS_REC_STATE * PFS_REC_STATE
Definition: fs_rec.h:186
USHORT SerialNumber
Definition: fs_rec.h:148
TAG DescriptorTag
Definition: fs_rec.h:162
USHORT Heads
Definition: fat.h:113
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
NTSTATUS NTAPI FsRecNtfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: ntfs.c:52
struct _PACKED_BOOT_SECTOR * PPACKED_BOOT_SECTOR
UCHAR CurrentHead
Definition: fat.h:167
NTSTATUS NTAPI FsRecBtrfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: btrfs.c:30
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
EXTENT MainVolumeDescriptorExtent
Definition: fs_rec.h:163
USHORT Sectors
Definition: fat.h:109
_FILE_SYSTEM_TYPE
Definition: fs_rec.h:169
USHORT ExtendedFlags
Definition: fat.h:118
struct _PACKED_BIOS_PARAMETER_BLOCK * PPACKED_BIOS_PARAMETER_BLOCK
UCHAR PhysicalDriveNumber
Definition: fat.h:166
union _UCHAR4 UCHAR4
unsigned char BOOLEAN
UCHAR Id[4]
Definition: fat.h:169
NTSTATUS NTAPI FsRecLoadFileSystem(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR DriverServiceName)
Definition: fs_rec.c:23
Definition: bufpool.h:45
UCHAR ReservedSectors[2]
Definition: fat.h:58
UCHAR Oem[8]
Definition: fat.h:164
PDEVICE_OBJECT Alternate
Definition: fs_rec.h:195
NTSTATUS NTAPI FsRecVfatFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fat.c:100
USHORT Version
Definition: fs_rec.h:145
UCHAR HiddenSectors[4]
Definition: fat.h:66
struct BIOS_PARAMETER_BLOCK * PBIOS_PARAMETER_BLOCK
USHORT BytesPerSector
Definition: fat.h:104
struct _AVDP * PAVDP
_FS_REC_STATE
Definition: fs_rec.h:183
UCHAR ForceAlignment
Definition: cdprocs.h:1673
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct _DEVICE_EXTENSION DEVICE_EXTENSION
USHORT CrcLength
Definition: fs_rec.h:150
unsigned char UCHAR
Definition: xmlstorage.h:181
char * PBOOLEAN
Definition: retypes.h:11
USHORT RootEntries
Definition: fat.h:108
UCHAR Checksum
Definition: fs_rec.h:146
PACKED_BIOS_PARAMETER_BLOCK PackedBpb
Definition: fat.h:165
ULONG32 LargeSectorsPerFat
Definition: fat.h:116
ULONG Location
Definition: fs_rec.h:151
NTSTATUS NTAPI FsRecFfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: ffs.c:43
FS_REC_STATE State
Definition: fs_rec.h:193
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
ULONG SectorCount
Definition: part_xbox.c:32
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
USHORT ReservedSectors
Definition: fat.h:106
ULONG ActiveFat
Definition: fat.h:120
unsigned short USHORT
Definition: pedump.c:61
UCHAR SectorsPerFat[2]
Definition: fat.h:63
enum _FILE_SYSTEM_TYPE * PFILE_SYSTEM_TYPE
ULONG Length
Definition: fs_rec.h:156
UCHAR SectorsPerTrack[2]
Definition: fat.h:64
USHORT FsInfoSector
Definition: fat.h:128
Definition: fs_rec.h:160
unsigned int * PULONG
Definition: retypes.h:1
struct _EXTENT EXTENT
USHORT Crc
Definition: fs_rec.h:149
UCHAR Reserved
Definition: fs_rec.h:147
Definition: fs_rec.h:142
BOOLEAN NTAPI FsRecGetDeviceSectors(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, OUT PLARGE_INTEGER SectorCount)
Definition: blockdev.c:24
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
UCHAR SectorsPerCluster
Definition: fat.h:105
USHORT Identifier
Definition: fs_rec.h:144
struct _AVDP AVDP
_In_ ULONG SectorSize
Definition: halfuncs.h:291
ULONG32 RootDirFirstCluster
Definition: fat.h:127
FILE_SYSTEM_TYPE FsType
Definition: fs_rec.h:194
UCHAR Signature
Definition: fat.h:168
ULONG32 HiddenSectors
Definition: fat.h:114
struct _TAG TAG
Definition: db.cpp:143
union _UCHAR4 * PUCHAR4
ULONG32 LargeSectors
Definition: fat.h:115
enum _FILE_SYSTEM_TYPE FILE_SYSTEM_TYPE
UCHAR SectorsPerCluster[1]
Definition: fat.h:57
BOOLEAN NTAPI FsRecGetDeviceSectorSize(IN PDEVICE_OBJECT DeviceObject, OUT PULONG SectorSize)
Definition: blockdev.c:80
ULONG Location
Definition: fs_rec.h:157
NTSTATUS NTAPI FsRecReiserfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: reiserfs.c:43
USHORT SectorsPerTrack
Definition: fat.h:112
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68