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
;
78 PDEVICE_OBJECT StorageDevice
;
80 int rootDirectorySectors
, FATStart
, rootStart
, dataStart
;
81 int FATEntriesPerSector
, FATUnit
;
82 ULONG BytesPerCluster
;
85 } DEVICE_EXTENSION
, *PDEVICE_EXTENSION
;
87 typedef struct _FSRTL_COMMON_FCB_HEADER
{
88 char IsFastIoPossible
;//is char the realtype ?
90 ERESOURCE PagingIoResource
;
91 ULONG Flags
;// is long the real type ?
92 LARGE_INTEGER AllocationSize
;
93 LARGE_INTEGER FileSize
;
94 LARGE_INTEGER ValidDataLength
;
96 } FSRTL_COMMON_FCB_HEADER
;
98 typedef struct _SFsdNTRequiredFCB
{
99 FSRTL_COMMON_FCB_HEADER CommonFCBHeader
;
100 SECTION_OBJECT_POINTERS SectionObject
;
101 ERESOURCE MainResource
;
102 ERESOURCE PagingIoResource
;
103 } SFsdNTRequiredFCB
, *PtrSFsdNTRequiredFCB
;
106 typedef struct _VfatFCB
108 SFsdNTRequiredFCB NTRequiredFCB
;
110 WCHAR
*ObjectName
; // point on filename (250 chars max) in PathName
111 WCHAR PathName
[MAX_PATH
];// path+filename 260 max
113 PDEVICE_EXTENSION pDevExt
;
114 struct _VfatFCB
* nextFcb
, *prevFcb
;
115 struct _VfatFCB
* parentFcb
;
119 } VfatFCB
, *PVfatFCB
;
125 PFILE_OBJECT PtrFileObject
;
126 LARGE_INTEGER CurrentByteOffset
;
127 ULONG StartEntry
; //for DirectoryControl
128 // PSTRING DirectorySearchPattern;// for DirectoryControl ?
129 } VfatCCB
, *PVfatCCB
;
132 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
135 extern PVfatFCB pFirstFcb
;
137 // functions called by i/o manager :
138 NTSTATUS
DriverEntry(PDRIVER_OBJECT _DriverObject
,PUNICODE_STRING RegistryPath
);
139 NTSTATUS
FsdDirectoryControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
140 NTSTATUS
FsdRead(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
141 NTSTATUS
FsdWrite(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
142 NTSTATUS
FsdCreate(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
143 NTSTATUS
FsdClose(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
144 NTSTATUS
FsdFileSystemControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
145 NTSTATUS
FsdQueryInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
148 // internal functions in blockdev.c
149 BOOLEAN
VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject
,
151 IN ULONG SectorCount
,
154 BOOLEAN
VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject
,
156 IN ULONG SectorCount
,
159 //internal functions in iface.c :
160 NTSTATUS
FindFile(PDEVICE_EXTENSION DeviceExt
, PVfatFCB Fcb
,
161 PVfatFCB Parent
, PWSTR FileToFind
,ULONG
*Entry
);
162 NTSTATUS
FsdCloseFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
);
163 NTSTATUS
FsdGetStandardInformation(PVfatFCB FCB
, PDEVICE_OBJECT DeviceObject
,
164 PFILE_STANDARD_INFORMATION StandardInfo
);
165 NTSTATUS
FsdOpenFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
167 NTSTATUS
FsdReadFile(PDEVICE_EXTENSION DeviceExt
, PVfatFCB pFcb
,
168 PVOID Buffer
, ULONG Length
, ULONG ReadOffset
,
170 NTSTATUS
FsdWriteFile(PDEVICE_EXTENSION DeviceExt
, PVfatFCB pFcb
,
171 PVOID Buffer
, ULONG Length
, ULONG WriteOffset
);
172 ULONG
GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt
, ULONG CurrentCluster
);
173 BOOLEAN
IsDeletedEntry(FATDirEntry
*pEntry
);
174 BOOLEAN
IsLastEntry(FATDirEntry
*pEntry
);
175 wchar_t * vfat_wcsncpy(wchar_t * dest
, const wchar_t *src
,size_t wcount
);
176 void VFATWriteCluster(PDEVICE_EXTENSION DeviceExt
, PVOID Buffer
, ULONG Cluster
);
178 //internal functions in dirwr.c
179 NTSTATUS
addEntry(PDEVICE_EXTENSION DeviceExt
180 ,PFILE_OBJECT pFileObject
,ULONG RequestedOptions
,UCHAR ReqAttr
);
181 NTSTATUS
updEntry(PDEVICE_EXTENSION DeviceExt
,PVfatFCB pFcb
);
184 //FIXME : following defines must be removed
185 //FIXME when this functions will work.
186 #define ExAcquireResourceExclusiveLite(x,y) {}
187 #define ExReleaseResourceForThreadLite(x,y) {}