7 unsigned char magic0
, res0
, magic1
;
8 unsigned char OEMName
[8];
9 unsigned short BytesPerSector
;
10 unsigned char SectorsPerCluster
;
11 unsigned short ReservedSectors
;
12 unsigned char FATCount
;
13 unsigned short RootEntries
, Sectors
;
15 unsigned short FATSectors
, SectorsPerTrack
, Heads
;
16 unsigned long HiddenSectors
, SectorsHuge
;
17 unsigned char Drive
, Res1
, Sig
;
18 unsigned long VolumeID
;
19 unsigned char VolumeLabel
[11], SysType
[8];
20 unsigned char Res2
[450];
21 } __attribute__((packed
));
23 struct _BootSector32
{
24 unsigned char magic0
, res0
, magic1
;
25 unsigned char OEMName
[8];
26 unsigned short BytesPerSector
;
27 unsigned char SectorsPerCluster
;
28 unsigned short ReservedSectors
;
29 unsigned char FATCount
;
30 unsigned short RootEntries
, Sectors
;
32 unsigned short FATSectors
, SectorsPerTrack
, Heads
;
33 unsigned long HiddenSectors
, SectorsHuge
;
34 unsigned long FATSectors32
;
36 unsigned char VolumeLabel
[11], SysType
[8];
37 unsigned char Res2
[422];
38 } __attribute__((packed
));
40 typedef struct _BootSector BootSector
;
43 unsigned char Filename
[8], Ext
[3], Attrib
, Res
[2];
44 unsigned short CreationTime
,CreationDate
,AccessDate
;
45 unsigned short FirstClusterHigh
;// higher
46 unsigned short UpdateTime
;//time create/update
47 unsigned short UpdateDate
;//date create/update
48 unsigned short FirstCluster
;
49 unsigned long FileSize
;
50 } __attribute__((packed
));
52 typedef struct _FATDirEntry FATDirEntry
;
56 unsigned char id
; // sequence number for slot
57 WCHAR name0_4
[5]; // first 5 characters in name
58 unsigned char attr
; // attribute byte
59 unsigned char reserved
; // always 0
60 unsigned char alias_checksum
; // checksum for 8.3 alias
61 WCHAR name5_10
[6]; // 6 more characters in name
62 unsigned char start
[2]; // starting cluster number
63 WCHAR name11_12
[2]; // last 2 characters in name
64 } __attribute__((packed
));
67 typedef struct _slot slot
;
77 PDEVICE_OBJECT StorageDevice
;
79 int rootDirectorySectors
, FATStart
, rootStart
, dataStart
;
80 int FATEntriesPerSector
, FATUnit
;
81 ULONG BytesPerCluster
;
84 } DEVICE_EXTENSION
, *PDEVICE_EXTENSION
;
86 typedef struct _FSRTL_COMMON_FCB_HEADER
{
87 char IsFastIoPossible
;//is char the realtype ?
89 ERESOURCE PagingIoResource
;
90 ULONG Flags
;// is long the real type ?
91 LARGE_INTEGER AllocationSize
;
92 LARGE_INTEGER FileSize
;
93 LARGE_INTEGER ValidDataLength
;
95 } FSRTL_COMMON_FCB_HEADER
;
97 typedef struct _SFsdNTRequiredFCB
{
98 FSRTL_COMMON_FCB_HEADER CommonFCBHeader
;
99 SECTION_OBJECT_POINTERS SectionObject
;
100 ERESOURCE MainResource
;
101 ERESOURCE PagingIoResource
;
102 } SFsdNTRequiredFCB
, *PtrSFsdNTRequiredFCB
;
105 typedef struct _VfatFCB
107 SFsdNTRequiredFCB NTRequiredFCB
;
109 WCHAR
*ObjectName
; // point on filename (250 chars max) in PathName
110 WCHAR PathName
[261];// path+filename 260 max
112 PDEVICE_EXTENSION pDevExt
;
113 struct _VfatFCB
* nextFcb
, *prevFcb
;
114 struct _VfatFCB
* parentFcb
;
115 } VfatFCB
, *PVfatFCB
;
121 PFILE_OBJECT PtrFileObject
;
122 LARGE_INTEGER CurrentByteOffset
;
123 ULONG StartSector
; // for DirectoryControl
124 ULONG StartEntry
; //for DirectoryControl
125 // PSTRING DirectorySearchPattern;// for DirectoryControl ?
126 } VfatCCB
, *PVfatCCB
;
129 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
133 // functions called by i/o manager :
134 NTSTATUS
DriverEntry(PDRIVER_OBJECT _DriverObject
,PUNICODE_STRING RegistryPath
);
135 NTSTATUS
FsdDirectoryControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
136 NTSTATUS
FsdRead(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
137 NTSTATUS
FsdWrite(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
138 NTSTATUS
FsdCreate(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
139 NTSTATUS
FsdClose(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
140 NTSTATUS
FsdFileSystemControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
141 NTSTATUS
FsdQueryInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
144 // internal functions in blockdev.c
145 BOOLEAN
VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject
,
147 IN ULONG SectorCount
,
150 BOOLEAN
VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject
,
152 IN ULONG SectorCount
,
155 //internal functions in iface.c :
156 NTSTATUS
FsdGetStandardInformation(PVfatFCB FCB
, PDEVICE_OBJECT DeviceObject
,
157 PFILE_STANDARD_INFORMATION StandardInfo
);
158 NTSTATUS
FindFile(PDEVICE_EXTENSION DeviceExt
, PVfatFCB Fcb
,
159 PVfatFCB Parent
, PWSTR FileToFind
,ULONG
*StartSector
,ULONG
*Entry
);
160 wchar_t * vfat_wcsncpy(wchar_t * dest
, const wchar_t *src
,size_t wcount
);