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
;
116 } VfatFCB
, *PVfatFCB
;
122 PFILE_OBJECT PtrFileObject
;
123 LARGE_INTEGER CurrentByteOffset
;
124 ULONG StartSector
; // for DirectoryControl
125 ULONG StartEntry
; //for DirectoryControl
126 // PSTRING DirectorySearchPattern;// for DirectoryControl ?
127 } VfatCCB
, *PVfatCCB
;
130 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
133 extern PVfatFCB pFirstFcb
;
135 // functions called by i/o manager :
136 NTSTATUS
DriverEntry(PDRIVER_OBJECT _DriverObject
,PUNICODE_STRING RegistryPath
);
137 NTSTATUS
FsdDirectoryControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
138 NTSTATUS
FsdRead(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
139 NTSTATUS
FsdWrite(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
140 NTSTATUS
FsdCreate(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
141 NTSTATUS
FsdClose(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
142 NTSTATUS
FsdFileSystemControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
143 NTSTATUS
FsdQueryInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
146 // internal functions in blockdev.c
147 BOOLEAN
VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject
,
149 IN ULONG SectorCount
,
152 BOOLEAN
VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject
,
154 IN ULONG SectorCount
,
157 //internal functions in iface.c :
158 NTSTATUS
FindFile(PDEVICE_EXTENSION DeviceExt
, PVfatFCB Fcb
,
159 PVfatFCB Parent
, PWSTR FileToFind
,ULONG
*StartSector
,ULONG
*Entry
);
160 NTSTATUS
FsdCloseFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
);
161 NTSTATUS
FsdGetStandardInformation(PVfatFCB FCB
, PDEVICE_OBJECT DeviceObject
,
162 PFILE_STANDARD_INFORMATION StandardInfo
);
163 NTSTATUS
FsdOpenFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
165 NTSTATUS
FsdReadFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
166 PVOID Buffer
, ULONG Length
, ULONG ReadOffset
,
168 NTSTATUS
FsdWriteFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
169 PVOID Buffer
, ULONG Length
, ULONG WriteOffset
);
170 ULONG
GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt
, ULONG CurrentCluster
);
171 BOOLEAN
IsDeletedEntry(PVOID Block
, ULONG Offset
);
172 BOOLEAN
IsLastEntry(PVOID Block
, ULONG Offset
);
173 wchar_t * vfat_wcsncpy(wchar_t * dest
, const wchar_t *src
,size_t wcount
);
174 void VFATWriteCluster(PDEVICE_EXTENSION DeviceExt
, PVOID Buffer
, ULONG Cluster
);
176 //internal functions in dirwr.c
177 NTSTATUS
addEntry(PDEVICE_EXTENSION DeviceExt
178 ,PFILE_OBJECT pFileObject
,ULONG RequestedOptions
,UCHAR ReqAttr
);
179 NTSTATUS
updEntry(PDEVICE_EXTENSION DeviceExt
,PFILE_OBJECT pFileObject
);
182 //FIXME : following defines must be removed
183 //FIXME when this functions will work.
184 #define ExAcquireResourceExclusiveLite(x,y) {}
185 #define ExReleaseResourceForThreadLite(x,y) {}