2005-09-04 21:14:54 +00:00
|
|
|
/*
|
2002-05-15 18:05:00 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2007-04-05 00:11:35 +00:00
|
|
|
* PROJECT: ReactOS File System Recognizer
|
|
|
|
* FILE: drivers/filesystems/fs_rec/fs_rec.h
|
|
|
|
* PURPOSE: Main Header File
|
|
|
|
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
|
|
|
|
* Eric Kohl
|
2002-05-15 18:05:00 +00:00
|
|
|
*/
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2014-02-06 11:18:34 +00:00
|
|
|
#ifndef _FS_REC_H
|
|
|
|
#define _FS_REC_H
|
|
|
|
|
2005-09-04 21:14:54 +00:00
|
|
|
#include <ntifs.h>
|
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* Tag for memory allocations */
|
2009-08-24 17:12:25 +00:00
|
|
|
#define FSREC_TAG 'cRsF'
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* UDFS Offsets */
|
2008-11-14 09:23:09 +00:00
|
|
|
#define UDFS_VRS_START_OFFSET 32768
|
2007-04-05 00:11:35 +00:00
|
|
|
#define UDFS_AVDP_SECTOR 256
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* Non-standard rounding macros */
|
2015-10-04 17:14:24 +00:00
|
|
|
#ifndef ROUND_UP
|
2009-01-25 16:21:14 +00:00
|
|
|
#define ROUND_UP(n, align) \
|
|
|
|
ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
|
|
|
|
|
|
|
|
#define ROUND_DOWN(n, align) \
|
|
|
|
(((ULONG)n) & ~((align) - 1l))
|
2015-10-04 17:14:24 +00:00
|
|
|
#endif
|
2009-01-25 16:21:14 +00:00
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* Conversion types and macros taken from internal ntifs headers */
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef union _UCHAR1
|
|
|
|
{
|
|
|
|
UCHAR Uchar[1];
|
|
|
|
UCHAR ForceAlignment;
|
|
|
|
} UCHAR1, *PUCHAR1;
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef union _UCHAR2
|
2002-05-15 09:42:19 +00:00
|
|
|
{
|
2007-04-05 00:11:35 +00:00
|
|
|
UCHAR Uchar[2];
|
|
|
|
USHORT ForceAlignment;
|
|
|
|
} UCHAR2, *PUCHAR2;
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef union _UCHAR4
|
2004-05-02 20:12:38 +00:00
|
|
|
{
|
2007-04-05 00:11:35 +00:00
|
|
|
UCHAR Uchar[4];
|
|
|
|
ULONG ForceAlignment;
|
|
|
|
} UCHAR4, *PUCHAR4;
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
#define CopyUchar1(Dst,Src) { \
|
|
|
|
*((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
|
|
|
|
}
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
#define CopyUchar2(Dst,Src) { \
|
|
|
|
*((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
|
|
|
|
}
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
#define CopyUchar4(Dst,Src) { \
|
|
|
|
*((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
|
|
|
|
}
|
2002-05-15 18:05:00 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
#define FatUnpackBios(Bios,Pbios) { \
|
|
|
|
CopyUchar2(&(Bios)->BytesPerSector, &(Pbios)->BytesPerSector[0] ); \
|
|
|
|
CopyUchar1(&(Bios)->SectorsPerCluster, &(Pbios)->SectorsPerCluster[0]); \
|
|
|
|
CopyUchar2(&(Bios)->ReservedSectors, &(Pbios)->ReservedSectors[0] ); \
|
|
|
|
CopyUchar1(&(Bios)->Fats, &(Pbios)->Fats[0] ); \
|
|
|
|
CopyUchar2(&(Bios)->RootEntries, &(Pbios)->RootEntries[0] ); \
|
|
|
|
CopyUchar2(&(Bios)->Sectors, &(Pbios)->Sectors[0] ); \
|
|
|
|
CopyUchar1(&(Bios)->Media, &(Pbios)->Media[0] ); \
|
|
|
|
CopyUchar2(&(Bios)->SectorsPerFat, &(Pbios)->SectorsPerFat[0] ); \
|
|
|
|
CopyUchar2(&(Bios)->SectorsPerTrack, &(Pbios)->SectorsPerTrack[0] ); \
|
|
|
|
CopyUchar2(&(Bios)->Heads, &(Pbios)->Heads[0] ); \
|
|
|
|
CopyUchar4(&(Bios)->HiddenSectors, &(Pbios)->HiddenSectors[0] ); \
|
|
|
|
CopyUchar4(&(Bios)->LargeSectors, &(Pbios)->LargeSectors[0] ); \
|
|
|
|
}
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* Packed versions of the BPB and Boot Sector */
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef struct _PACKED_BIOS_PARAMETER_BLOCK
|
|
|
|
{
|
|
|
|
UCHAR BytesPerSector[2];
|
|
|
|
UCHAR SectorsPerCluster[1];
|
|
|
|
UCHAR ReservedSectors[2];
|
|
|
|
UCHAR Fats[1];
|
|
|
|
UCHAR RootEntries[2];
|
|
|
|
UCHAR Sectors[2];
|
|
|
|
UCHAR Media[1];
|
|
|
|
UCHAR SectorsPerFat[2];
|
|
|
|
UCHAR SectorsPerTrack[2];
|
|
|
|
UCHAR Heads[2];
|
|
|
|
UCHAR HiddenSectors[4];
|
|
|
|
UCHAR LargeSectors[4];
|
|
|
|
} PACKED_BIOS_PARAMETER_BLOCK, *PPACKED_BIOS_PARAMETER_BLOCK;
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef struct _PACKED_BOOT_SECTOR
|
|
|
|
{
|
|
|
|
UCHAR Jump[3];
|
|
|
|
UCHAR Oem[8];
|
|
|
|
PACKED_BIOS_PARAMETER_BLOCK PackedBpb;
|
|
|
|
UCHAR PhysicalDriveNumber;
|
|
|
|
UCHAR CurrentHead;
|
|
|
|
UCHAR Signature;
|
|
|
|
UCHAR Id[4];
|
|
|
|
UCHAR VolumeLabel[11];
|
|
|
|
UCHAR SystemId[8];
|
|
|
|
} PACKED_BOOT_SECTOR, *PPACKED_BOOT_SECTOR;
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* Unpacked version of the BPB */
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef struct BIOS_PARAMETER_BLOCK
|
|
|
|
{
|
|
|
|
USHORT BytesPerSector;
|
|
|
|
UCHAR SectorsPerCluster;
|
|
|
|
USHORT ReservedSectors;
|
|
|
|
UCHAR Fats;
|
|
|
|
USHORT RootEntries;
|
|
|
|
USHORT Sectors;
|
|
|
|
UCHAR Media;
|
|
|
|
USHORT SectorsPerFat;
|
|
|
|
USHORT SectorsPerTrack;
|
|
|
|
USHORT Heads;
|
|
|
|
ULONG32 HiddenSectors;
|
|
|
|
ULONG32 LargeSectors;
|
|
|
|
ULONG32 LargeSectorsPerFat;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
USHORT ExtendedFlags;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ULONG ActiveFat:4;
|
|
|
|
ULONG Reserved0:3;
|
|
|
|
ULONG MirrorDisabled:1;
|
|
|
|
ULONG Reserved1:8;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
USHORT FsVersion;
|
|
|
|
ULONG32 RootDirFirstCluster;
|
|
|
|
USHORT FsInfoSector;
|
|
|
|
USHORT BackupBootSector;
|
|
|
|
} BIOS_PARAMETER_BLOCK, *PBIOS_PARAMETER_BLOCK;
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* UDFS Structures */
|
2007-04-05 00:11:35 +00:00
|
|
|
#include <pshpack1.h>
|
|
|
|
typedef struct _TAG
|
|
|
|
{
|
|
|
|
USHORT Identifier;
|
|
|
|
USHORT Version;
|
|
|
|
UCHAR Checksum;
|
|
|
|
UCHAR Reserved;
|
|
|
|
USHORT SerialNumber;
|
|
|
|
USHORT Crc;
|
|
|
|
USHORT CrcLength;
|
|
|
|
ULONG Location;
|
|
|
|
} TAG, *PTAG;
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef struct _EXTENT
|
|
|
|
{
|
|
|
|
ULONG Length;
|
|
|
|
ULONG Location;
|
|
|
|
} EXTENT, *PEXTENT;
|
|
|
|
|
|
|
|
typedef struct _AVDP
|
|
|
|
{
|
|
|
|
TAG DescriptorTag;
|
|
|
|
EXTENT MainVolumeDescriptorExtent;
|
|
|
|
EXTENT ReserveVolumeDescriptorExtent;
|
|
|
|
} AVDP, *PAVDP;
|
|
|
|
#include <poppack.h>
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* Filesystem Types */
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef enum _FILE_SYSTEM_TYPE
|
|
|
|
{
|
|
|
|
FS_TYPE_UNUSED,
|
|
|
|
FS_TYPE_VFAT,
|
|
|
|
FS_TYPE_NTFS,
|
|
|
|
FS_TYPE_CDFS,
|
2008-02-11 16:41:25 +00:00
|
|
|
FS_TYPE_UDFS,
|
|
|
|
FS_TYPE_EXT2,
|
2016-03-05 13:01:11 +00:00
|
|
|
FS_TYPE_BTRFS,
|
2016-05-26 18:17:19 +00:00
|
|
|
FS_TYPE_REISERFS,
|
2016-05-27 12:18:47 +00:00
|
|
|
FS_TYPE_FFS,
|
2007-04-05 00:11:35 +00:00
|
|
|
} FILE_SYSTEM_TYPE, *PFILE_SYSTEM_TYPE;
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* FS Recognizer State */
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef enum _FS_REC_STATE
|
|
|
|
{
|
|
|
|
Pending,
|
|
|
|
Loaded,
|
|
|
|
Unloading
|
|
|
|
} FS_REC_STATE, *PFS_REC_STATE;
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* Device extension */
|
2007-04-05 00:11:35 +00:00
|
|
|
typedef struct _DEVICE_EXTENSION
|
|
|
|
{
|
|
|
|
FS_REC_STATE State;
|
|
|
|
FILE_SYSTEM_TYPE FsType;
|
|
|
|
PDEVICE_OBJECT Alternate;
|
|
|
|
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
|
|
|
|
2014-02-06 10:59:19 +00:00
|
|
|
/* Prototypes */
|
2002-05-15 09:42:19 +00:00
|
|
|
NTSTATUS
|
2007-04-05 00:11:35 +00:00
|
|
|
NTAPI
|
|
|
|
FsRecCdfsFsControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp
|
|
|
|
);
|
2002-05-15 09:42:19 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
FsRecVfatFsControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp
|
|
|
|
);
|
2003-01-16 11:58:15 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
FsRecNtfsFsControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp
|
|
|
|
);
|
2003-01-16 11:58:15 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
2007-04-05 00:11:35 +00:00
|
|
|
NTAPI
|
|
|
|
FsRecUdfsFsControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp
|
|
|
|
);
|
|
|
|
|
2008-02-11 16:41:25 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
FsRecExt2FsControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp
|
|
|
|
);
|
|
|
|
|
2016-03-05 13:01:11 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
FsRecBtrfsFsControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp
|
|
|
|
);
|
|
|
|
|
2016-05-26 18:17:19 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
FsRecReiserfsFsControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp
|
|
|
|
);
|
|
|
|
|
2016-05-27 12:18:47 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
FsRecFfsFsControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp
|
|
|
|
);
|
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
FsRecGetDeviceSectors(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN ULONG SectorSize,
|
|
|
|
OUT PLARGE_INTEGER SectorCount
|
|
|
|
);
|
2003-01-16 11:58:15 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
FsRecGetDeviceSectorSize(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
OUT PULONG SectorSize
|
|
|
|
);
|
2005-10-06 21:39:18 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
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
|
|
|
|
);
|
2005-10-06 21:39:18 +00:00
|
|
|
|
2007-04-05 00:11:35 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
FsRecLoadFileSystem(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PWCHAR DriverServiceName
|
|
|
|
);
|
2014-02-06 11:18:34 +00:00
|
|
|
|
|
|
|
#endif /* _FS_REC_H */
|