ReactOS  0.4.15-dev-439-g292f67a
fatprocs.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1989-2000 Microsoft Corporation
4 
5 Module Name:
6 
7  FatProcs.h
8 
9 Abstract:
10 
11  This module defines all of the globally used procedures in the FAT
12  file system.
13 
14 
15 --*/
16 
17 #ifndef _FATPROCS_
18 #define _FATPROCS_
19 
20 #ifdef _MSC_VER
21 #pragma warning( disable: 4127 ) // conditional expression is constant
22 
23 #pragma warning( push )
24 #pragma warning( disable: 4201 ) // nonstandard extension used : nameless struct/union
25 #pragma warning( disable: 4214 ) // nonstandard extension used : bit field types
26 #endif
27 
28 #include <ntifs.h>
29 
30 
31 #include <ntddscsi.h>
32 #include <scsi.h>
33 #include <ntddcdrm.h>
34 #include <ntdddisk.h>
35 #include <ntddstor.h>
36 #include <ntintsafe.h>
37 #ifdef __REACTOS__
38 #include <pseh/pseh2.h>
39 #endif
40 
41 
42 #ifdef __REACTOS__
43 // Downgrade unsupported NT6.2+ features.
44 #undef MdlMappingNoExecute
45 #define MdlMappingNoExecute 0
46 #define NonPagedPoolNx NonPagedPool
47 #define NonPagedPoolNxCacheAligned NonPagedPoolCacheAligned
48 #undef POOL_NX_ALLOCATION
49 #define POOL_NX_ALLOCATION 0
50 
51 // Moved up: needed in 'fatstruc.h'.
52 typedef enum _TYPE_OF_OPEN {
53 
60  EaFile,
61 } TYPE_OF_OPEN;
62 #endif
63 
64 #include "nodetype.h"
65 #include "fat.h"
66 #include "lfn.h"
67 #include "fatstruc.h"
68 #include "fatdata.h"
69 
70 
71 
72 #ifdef _MSC_VER
73 #pragma warning( pop )
74 #endif
75 
76 #ifndef INLINE
77 #define INLINE __inline
78 #endif
79 
80 #define Add2Ptr(P,I) ((PVOID)((PUCHAR)(P) + (I)))
81 
82 #ifndef MAX_ULONG
83 #define MAX_ULONG ((ULONG)-1)
84 #endif
85 
86 #ifndef MAX_USHORT
87 #define MAX_USHORT ((USHORT)-1)
88 #endif
89 
90 //
91 // We must explicitly tag our allocations.
92 //
93 
94 #undef FsRtlAllocatePool
95 #undef FsRtlAllocatePoolWithQuota
96 
97 //
98 // A function that returns finished denotes if it was able to complete the
99 // operation (TRUE) or could not complete the operation (FALSE) because the
100 // wait value stored in the irp context was false and we would have had
101 // to block for a resource or I/O
102 //
103 
105 
106 //
107 // Size (characters) of stack allocated name component buffers in
108 // the create/rename paths.
109 //
110 
111 #define FAT_CREATE_INITIAL_NAME_BUF_SIZE 32
112 
113 
114 //
115 // Some string buffer handling functions, implemented in strucsup.c
116 //
117 
118 VOID
121  );
122 
123 VOID
126  _In_ USHORT DesiredBufferSize,
127  _In_ BOOLEAN FreeOldBuffer,
128  __out_opt PBOOLEAN NeedsFree
129  );
130 
131 VOID
134  _In_ USHORT DesiredBufferSize
135  );
136 
137 BOOLEAN
139  IN PVCB Vcb,
140  IN PLARGE_MCB Mcb,
141  IN VBO Vbo,
142  IN LBO Lbo,
144  );
145 
146 BOOLEAN
148  IN PVCB Vcb,
149  IN PLARGE_MCB Mcb,
150  IN VBO Vbo,
151  OUT PLBO Lbo,
154  );
155 
156 BOOLEAN
158  IN PVCB Vcb,
159  IN PLARGE_MCB Mcb,
160  OUT PVBO Vbo,
161  OUT PLBO Lbo,
163  );
164 
165 BOOLEAN
167  IN PVCB Vcb,
168  IN PLARGE_MCB Mcb,
169  IN ULONG RunIndex,
170  OUT PVBO Vbo,
171  OUT PLBO Lbo,
173  );
174 
175 VOID
177  IN PVCB Vcb,
178  IN PLARGE_MCB Mcb,
179  IN VBO Vbo,
181  );
182 
183 
184 //
185 // File access check routine, implemented in AcChkSup.c
186 //
187 
188 BOOLEAN
190  PIRP_CONTEXT IrpContext,
191  IN UCHAR DirentAttributes,
193  );
194 
195 BOOLEAN
197  _In_ PIRP_CONTEXT IrpContext,
199  _In_ KPROCESSOR_MODE ProcessorMode
200  );
201 
202 NTSTATUS
204  IN PIRP_CONTEXT IrpContext,
207  IN KPROCESSOR_MODE ProcessorMode
208  );
209 
210 
211 //
212 // Allocation support routines, implemented in AllocSup.c
213 //
214 
215 static
216 INLINE
217 BOOLEAN
219  IN PVCB Vcb,
221  IN ULONG Length
222  )
223 
224 /*++
225 
226 Routine Description:
227 
228  This routine enforces the restriction that object space must be
229  representable in 32 bits.
230 
231 Arguments:
232 
233  Vcb - the volume the range is on
234 
235  Start - starting byte (zero based) of the range
236 
237  Length - size of the range
238 
239  HeaderSize - if the file has a header
240 
241 Return Value:
242 
243  BOOLEAN - if, considering the cluster size, the neccesary size of
244  the object to contain the range can be represented in 32 bits.
245 
246 --*/
247 
248 {
249 
251 
252  //
253  // The only restriction on a FAT object is that the filesize must
254  // fit in 32bits, i.e. <= 0xffffffff. This then implies that the
255  // range of valid byte offsets is [0, fffffffe].
256  //
257  // Two phases which check for illegality
258  //
259  // - if the high 32bits are nonzero
260  // - if the length would cause a 32bit overflow
261  //
262 
263  return !(Start.HighPart ||
264  Start.LowPart + Length < Start.LowPart);
265 }
266 
267 
268 //
269 // This strucure is used by FatLookupFatEntry to remember a pinned page
270 // of fat.
271 //
272 
273 typedef struct _FAT_ENUMERATION_CONTEXT {
274 
278 
280 
281 VOID
283  IN PIRP_CONTEXT IrpContext,
284  IN PVCB Vcb,
285  IN ULONG FatIndex,
288  );
289 
290 VOID
292  IN PIRP_CONTEXT IrpContext,
293  IN PVCB Vcb
294  );
295 
296 VOID
298  IN PIRP_CONTEXT IrpContext,
299  IN PVCB Vcb
300  );
301 
302 _Requires_lock_held_(_Global_critical_region_)
303 VOID
304 FatLookupFileAllocation (
305  IN PIRP_CONTEXT IrpContext,
307  IN VBO Vbo,
308  OUT PLBO Lbo,
313  );
314 
315 _Requires_lock_held_(_Global_critical_region_)
316 VOID
317 FatAddFileAllocation (
318  IN PIRP_CONTEXT IrpContext,
322  );
323 
324 _Requires_lock_held_(_Global_critical_region_)
325 VOID
326 FatTruncateFileAllocation (
327  IN PIRP_CONTEXT IrpContext,
328  IN PFCB FcbOrDcb,
330  );
331 
332 _Requires_lock_held_(_Global_critical_region_)
333 VOID
334 FatLookupFileAllocationSize (
335  IN PIRP_CONTEXT IrpContext,
337  );
338 
339 _Requires_lock_held_(_Global_critical_region_)
340 VOID
341 FatAllocateDiskSpace (
342  IN PIRP_CONTEXT IrpContext,
348  );
349 
350 _Requires_lock_held_(_Global_critical_region_)
351 VOID
352 FatDeallocateDiskSpace (
353  IN PIRP_CONTEXT IrpContext,
355  IN PLARGE_MCB Mcb,
357  );
358 
359 _Requires_lock_held_(_Global_critical_region_)
360 VOID
361 FatSplitAllocation (
362  IN PIRP_CONTEXT IrpContext,
365  IN VBO SplitAtVbo,
367  );
368 
369 _Requires_lock_held_(_Global_critical_region_)
370 VOID
371 FatMergeAllocation (
372  IN PIRP_CONTEXT IrpContext,
376  );
377 
378 _Requires_lock_held_(_Global_critical_region_)
379 VOID
380 FatSetFatEntry (
381  IN PIRP_CONTEXT IrpContext,
383  IN ULONG FatIndex,
385  );
386 
387 UCHAR
388 FatLogOf(
389  IN ULONG Value
390  );
391 
392 
393 //
394 // Buffer control routines for data caching, implemented in CacheSup.c
395 //
396 
397 VOID
399  IN PIRP_CONTEXT IrpContext,
400  IN PVCB Vcb,
403  OUT PBCB *Bcb,
404  OUT PVOID *Buffer
405  );
406 
407 _Requires_lock_held_(_Global_critical_region_)
408 VOID
409 FatPrepareWriteVolumeFile (
410  IN PIRP_CONTEXT IrpContext,
414  OUT PBCB *Bcb,
415  OUT PVOID *Buffer,
417  IN BOOLEAN Zero
418  );
419 
420 _Requires_lock_held_(_Global_critical_region_)
421 VOID
422 FatReadDirectoryFile (
423  IN PIRP_CONTEXT IrpContext,
427  IN BOOLEAN Pin,
428  OUT PBCB *Bcb,
429  OUT PVOID *Buffer,
431  );
432 
433 _Requires_lock_held_(_Global_critical_region_)
434 VOID
435 FatPrepareWriteDirectoryFile (
436  IN PIRP_CONTEXT IrpContext,
437  IN PDCB Dcb,
440  OUT PBCB *Bcb,
441  OUT PVOID *Buffer,
442  IN BOOLEAN Zero,
445  );
446 
447 _Requires_lock_held_(_Global_critical_region_)
448 VOID
449 FatOpenDirectoryFile (
450  IN PIRP_CONTEXT IrpContext,
451  IN PDCB Dcb
452  );
453 
456  IN PIRP_CONTEXT IrpContext,
457  IN PFCB EaFcb
458  );
459 
460 VOID
462  IN PIRP_CONTEXT IrpContext,
463  IN PVCB Vcb,
464  IN BOOLEAN FlushFirst
465  );
466 
467 
468 _Requires_lock_held_(_Global_critical_region_)
469 VOID
470 FatSetDirtyBcb (
471  IN PIRP_CONTEXT IrpContext,
472  IN PBCB Bcb,
475  );
476 
477 VOID
478 FatRepinBcb (
479  IN PIRP_CONTEXT IrpContext,
480  IN PBCB Bcb
481  );
482 
483 VOID
485  IN PIRP_CONTEXT IrpContext
486  );
487 
488 FINISHED
489 FatZeroData (
490  IN PIRP_CONTEXT IrpContext,
491  IN PVCB Vcb,
493  IN ULONG StartingZero,
495  );
496 
497 NTSTATUS
499  IN PIRP_CONTEXT IrpContext,
500  IN PIRP Irp
501  );
502 
503 VOID
505  IN PIRP_CONTEXT IrpContext,
506  IN PDCB Dcb,
509  OUT PBCB *Bcb
510  );
511 
512 NTSTATUS
514  IN PIRP_CONTEXT IrpContext,
516  IN ULONG StartingPage,
517  IN ULONG PageCount
518  );
519 
520 //
521 // VOID
522 // FatUnpinBcb (
523 // IN PIRP_CONTEXT IrpContext,
524 // IN OUT PBCB Bcb,
525 // );
526 //
527 
528 //
529 // This macro unpins a Bcb, in the checked build make sure all
530 // requests unpin all Bcbs before leaving.
531 //
532 
533 #if DBG
534 
535 #define FatUnpinBcb(IRPCONTEXT,BCB) { \
536  if ((BCB) != NULL) { \
537  CcUnpinData((BCB)); \
538  NT_ASSERT( (IRPCONTEXT)->PinCount );\
539  (IRPCONTEXT)->PinCount -= 1; \
540  (BCB) = NULL; \
541  } \
542 }
543 
544 #else
545 
546 #define FatUnpinBcb(IRPCONTEXT,BCB) { \
547  if ((BCB) != NULL) { \
548  CcUnpinData((BCB)); \
549  (BCB) = NULL; \
550  } \
551 }
552 
553 #endif // DBG
554 
555 VOID
559  _In_ BOOLEAN PinAccess,
561  _In_ PVOID LazyWriteContext
562  );
563 
564 VOID
566  IN PIRP_CONTEXT IrpContext,
568  );
569 
570 
571 //
572 // Device I/O routines, implemented in DevIoSup.c
573 //
574 // These routines perform the actual device read and writes. They only affect
575 // the on disk structure and do not alter any other data structures.
576 //
577 
578 VOID
580  IN PIRP Irp,
581  IN PFCB Fcb
582  );
583 
584 
585 _Requires_lock_held_(_Global_critical_region_)
586 NTSTATUS
587 FatNonCachedIo (
588  IN PIRP_CONTEXT IrpContext,
590  IN PFCB FcbOrDcb,
595  );
596 
597 _Requires_lock_held_(_Global_critical_region_)
598 VOID
599 FatNonCachedNonAlignedRead (
600  IN PIRP_CONTEXT IrpContext,
601  IN PIRP Irp,
602  IN PFCB FcbOrDcb,
605  );
606 
607 VOID
609  IN PIRP_CONTEXT IrpContext,
610  IN PVCB Vcb,
611  IN PIRP Irp,
612  IN ULONG MultipleIrpCount,
613  IN PIO_RUN IoRuns
614  );
615 
616 VOID
618  IN PIRP_CONTEXT IrpContext,
619  IN PVCB Vcb,
620  IN LBO Lbo,
622  IN PIRP Irp
623  );
624 
625 VOID
626 FatWaitSync (
627  IN PIRP_CONTEXT IrpContext
628  );
629 
630 VOID
632  IN PIRP_CONTEXT IrpContext,
633  IN OUT PIRP Irp,
636  );
637 
638 PVOID
640  IN PIRP_CONTEXT IrpContext,
641  IN OUT PIRP Irp,
643  );
644 
645 PVOID
647  IN PIRP_CONTEXT IrpContext,
648  IN OUT PIRP Irp
649  );
650 
651 NTSTATUS
653  IN PIRP_CONTEXT IrpContext,
654  IN PVCB Vcb,
655  IN BOOLEAN PreventRemoval
656  );
657 
658 NTSTATUS
660  IN PIRP_CONTEXT IrpContext,
668  IN BOOLEAN OverrideVerify,
670  );
671 
672 PMDL
674  __in PIRP_CONTEXT IrpContext,
676  );
677 
678 
679 //
680 // Dirent support routines, implemented in DirSup.c
681 //
682 
683 //
684 // Tunneling is a deletion precursor (all tunneling cases do
685 // not involve deleting dirents, however)
686 //
687 
688 VOID
690  IN PFCB FcbOrDcb,
692  );
693 
694 _Requires_lock_held_(_Global_critical_region_)
695 ULONG
696 FatCreateNewDirent (
697  IN PIRP_CONTEXT IrpContext,
701  );
702 
703 _Requires_lock_held_(_Global_critical_region_)
704 VOID
705 FatInitializeDirectoryDirent (
706  IN PIRP_CONTEXT IrpContext,
709  );
710 
711 _Requires_lock_held_(_Global_critical_region_)
712 VOID
713 FatDeleteDirent (
714  IN PIRP_CONTEXT IrpContext,
716  IN PDELETE_CONTEXT DeleteContext OPTIONAL,
718  );
719 
720 
721 _Requires_lock_held_(_Global_critical_region_)
722 VOID
723 FatLocateDirent (
724  IN PIRP_CONTEXT IrpContext,
726  IN PCCB Ccb,
728  IN OUT PULONG Flags,
729  OUT PDIRENT *Dirent,
730  OUT PBCB *Bcb,
732  OUT PBOOLEAN FileNameDos OPTIONAL,
734  IN OUT PUNICODE_STRING OrigLfn OPTIONAL
735  );
736 
737 _Requires_lock_held_(_Global_critical_region_)
738 VOID
739 FatLocateSimpleOemDirent (
740  IN PIRP_CONTEXT IrpContext,
743  OUT PDIRENT *Dirent,
744  OUT PBCB *Bcb,
746  );
747 
748 _Requires_lock_held_(_Global_critical_region_)
749 BOOLEAN
750 FatLfnDirentExists (
751  IN PIRP_CONTEXT IrpContext,
755  );
756 
757 _Requires_lock_held_(_Global_critical_region_)
758 VOID
759 FatLocateVolumeLabel (
760  IN PIRP_CONTEXT IrpContext,
761  IN PVCB Vcb,
762  OUT PDIRENT *Dirent,
763  OUT PBCB *Bcb,
765  );
766 
767 _Requires_lock_held_(_Global_critical_region_)
768 VOID
769 FatGetDirentFromFcbOrDcb (
770  IN PIRP_CONTEXT IrpContext,
773  OUT PDIRENT *Dirent,
774  OUT PBCB *Bcb
775  );
776 
777 _Requires_lock_held_(_Global_critical_region_)
778 BOOLEAN
779 FatIsDirectoryEmpty (
780  IN PIRP_CONTEXT IrpContext,
781  IN PDCB Dcb
782  );
783 
784 _Requires_lock_held_(_Global_critical_region_)
785 VOID
786 FatDeleteFile (
787  IN PIRP_CONTEXT IrpContext,
791  IN PDIRENT Dirent,
793  );
794 
795 
796 VOID
798  IN PIRP_CONTEXT IrpContext,
801  IN BOOLEAN ComponentReallyLowercase,
802  IN BOOLEAN ExtensionReallyLowercase,
805  IN BOOLEAN ZeroAndSetTimeFields,
806  IN PLARGE_INTEGER SetCreationTime OPTIONAL
807  );
808 
809 VOID
811  IN PIRP_CONTEXT IrpContext,
814  );
815 
816 _Requires_lock_held_(_Global_critical_region_)
817 VOID
818 FatSetFileSizeInDirent (
819  IN PIRP_CONTEXT IrpContext,
821  IN PULONG AlternativeFileSize OPTIONAL
822  );
823 
824 _Requires_lock_held_(_Global_critical_region_)
825 VOID
826 FatSetFileSizeInDirentNoRaise (
827  IN PIRP_CONTEXT IrpContext,
828  IN PFCB Fcb,
829  IN PULONG AlternativeFileSize OPTIONAL
830  );
831 
832 
833 _Requires_lock_held_(_Global_critical_region_)
834 VOID
835 FatUpdateDirentFromFcb (
836  IN PIRP_CONTEXT IrpContext,
838  IN PFCB FcbOrDcb,
839  IN PCCB Ccb
840  );
841 
842 
843 //
844 // Generate a relatively unique static 64bit ID from a FAT Fcb/Dcb
845 //
846 // ULONGLONG
847 // FatDirectoryKey (FcbOrDcb);
848 //
849 
850 #define FatDirectoryKey(FcbOrDcb) ((ULONGLONG)((FcbOrDcb)->CreationTime.QuadPart ^ (FcbOrDcb)->FirstClusterOfFile))
851 
852 
853 //
854 // The following routines are used to access and manipulate the
855 // clusters containing EA data in the ea data file. They are
856 // implemented in EaSup.c
857 //
858 
859 //
860 // VOID
861 // FatUpcaseEaName (
862 // IN PIRP_CONTEXT IrpContext,
863 // IN POEM_STRING EaName,
864 // OUT POEM_STRING UpcasedEaName
865 // );
866 //
867 
868 #define FatUpcaseEaName( IRPCONTEXT, NAME, UPCASEDNAME ) \
869  RtlUpperString( UPCASEDNAME, NAME )
870 
871 _Requires_lock_held_(_Global_critical_region_)
872 VOID
873 FatGetEaLength (
874  IN PIRP_CONTEXT IrpContext,
876  IN PDIRENT Dirent,
878  );
879 
880 _Requires_lock_held_(_Global_critical_region_)
881 VOID
882 FatGetNeedEaCount (
883  IN PIRP_CONTEXT IrpContext,
885  IN PDIRENT Dirent,
887  );
888 
889 _Requires_lock_held_(_Global_critical_region_)
890 VOID
891 FatCreateEa (
892  IN PIRP_CONTEXT IrpContext,
894  IN PUCHAR Buffer,
895  IN ULONG Length,
898  );
899 
900 _Requires_lock_held_(_Global_critical_region_)
901 VOID
902 FatDeleteEa (
903  IN PIRP_CONTEXT IrpContext,
904  IN PVCB Vcb,
907  );
908 
909 _Requires_lock_held_(_Global_critical_region_)
910 VOID
911 FatGetEaFile (
912  IN PIRP_CONTEXT IrpContext,
915  OUT PBCB *EaBcb,
918  );
919 
920 VOID
921 FatReadEaSet (
922  IN PIRP_CONTEXT IrpContext,
923  IN PVCB Vcb,
926  IN BOOLEAN ReturnEntireSet,
928  );
929 
930 _Requires_lock_held_(_Global_critical_region_)
931 VOID
932 FatDeleteEaSet (
933  IN PIRP_CONTEXT IrpContext,
935  IN PBCB EaBcb,
939  );
940 
941 _Requires_lock_held_(_Global_critical_region_)
942 VOID
943 FatAddEaSet (
944  IN PIRP_CONTEXT IrpContext,
947  IN PBCB EaBcb,
951  );
952 
953 VOID
955  IN PIRP_CONTEXT IrpContext,
956  IN OUT PEA_SET_HEADER EaSetHeader,
957  IN OUT PULONG PackedEasLength,
958  IN ULONG Offset
959  );
960 
961 VOID
963  IN PIRP_CONTEXT IrpContext,
964  IN OUT PEA_SET_HEADER *EaSetHeader,
965  IN OUT PULONG PackedEasLength,
966  IN OUT PULONG AllocationLength,
968  IN ULONG BytesPerCluster
969  );
970 
971 ULONG
973  IN PIRP_CONTEXT IrpContext,
974  IN PPACKED_EA FirstPackedEa,
975  IN ULONG PackedEasLength,
976  IN ULONG PreviousOffset
977  );
978 
979 BOOLEAN
981  IN PIRP_CONTEXT IrpContext,
982  IN PPACKED_EA FirstPackedEa,
983  IN ULONG PackedEasLength,
984  IN POEM_STRING EaName,
986  );
987 
988 BOOLEAN
990  IN PIRP_CONTEXT IrpContext,
992  );
993 
994 VOID
996  IN PIRP_CONTEXT IrpContext,
997  IN PFILE_OBJECT VirtualEaFile,
998  IN PFCB EaFcb,
999  IN OUT PEA_RANGE EaRange,
1001  IN ULONG Length,
1002  IN NTSTATUS ErrorStatus
1003  );
1004 
1005 VOID
1007  IN PIRP_CONTEXT IrpContext,
1008  IN PFILE_OBJECT EaFileObject,
1009  IN OUT PEA_RANGE EaRange
1010  );
1011 
1012 VOID
1014  IN PIRP_CONTEXT IrpContext,
1015  IN OUT PEA_RANGE EaRange
1016  );
1017 
1018 //
1019 // The following macro computes the size of a full ea (not including
1020 // padding to bring it to a longword. A full ea has a 4 byte offset,
1021 // folowed by 1 byte flag, 1 byte name length, 2 bytes value length,
1022 // the name, 1 null byte, and the value.
1023 //
1024 // ULONG
1025 // SizeOfFullEa (
1026 // IN PFILE_FULL_EA_INFORMATION FullEa
1027 // );
1028 //
1029 
1030 #define SizeOfFullEa(EA) (4+1+1+2+(EA)->EaNameLength+1+(EA)->EaValueLength)
1031 
1032 
1033 //
1034 // The following routines are used to manipulate the fscontext fields
1035 // of the file object, implemented in FilObSup.c
1036 //
1037 
1038 #ifndef __REACTOS__
1039 typedef enum _TYPE_OF_OPEN {
1040 
1048 } TYPE_OF_OPEN;
1049 #endif
1050 
1051 typedef enum _FAT_FLUSH_TYPE {
1052 
1053  NoFlush = 0,
1057 
1058 } FAT_FLUSH_TYPE;
1059 
1060 VOID
1064  IN PVOID VcbOrFcbOrDcb,
1066  );
1067 
1071  _Outptr_ PVCB *Vcb,
1073  _Outptr_ PCCB *Ccb
1074  );
1075 
1076 _Requires_lock_held_(_Global_critical_region_)
1077 VOID
1078 FatPurgeReferencedFileObjects (
1079  IN PIRP_CONTEXT IrpContext,
1082  );
1083 
1084 _Requires_lock_held_(_Global_critical_region_)
1085 VOID
1086 FatForceCacheMiss (
1087  IN PIRP_CONTEXT IrpContext,
1088  IN PFCB Fcb,
1090  );
1091 
1092 
1093 //
1094 // File system control routines, implemented in FsCtrl.c
1095 //
1096 
1097 _Requires_lock_held_(_Global_critical_region_)
1098 VOID
1099 FatFlushAndCleanVolume(
1100  IN PIRP_CONTEXT IrpContext,
1101  IN PIRP Irp,
1102  IN PVCB Vcb,
1104  );
1105 
1106 BOOLEAN
1109  );
1110 
1111 _Requires_lock_held_(_Global_critical_region_)
1112 NTSTATUS
1113 FatLockVolumeInternal (
1114  IN PIRP_CONTEXT IrpContext,
1115  IN PVCB Vcb,
1117  );
1118 
1119 NTSTATUS
1121  IN PIRP_CONTEXT IrpContext,
1122  IN PVCB Vcb,
1124  );
1125 
1126 
1127 //
1128 // Name support routines, implemented in NameSup.c
1129 //
1130 
1131 //
1132 // BOOLEAN
1133 // FatAreNamesEqual (
1134 // IN PIRP_CONTEXT IrpContext,
1135 // IN OEM_STRING ConstantNameA,
1136 // IN OEM_STRING ConstantNameB
1137 // )
1138 //
1139 // /*++
1140 //
1141 // Routine Description:
1142 //
1143 // This routine simple returns whether the two names are exactly equal.
1144 // If the two names are known to be constant, this routine is much
1145 // faster than FatIsDbcsInExpression.
1146 //
1147 // Arguments:
1148 //
1149 // ConstantNameA - Constant name.
1150 //
1151 // ConstantNameB - Constant name.
1152 //
1153 // Return Value:
1154 //
1155 // BOOLEAN - TRUE if the two names are lexically equal.
1156 //
1157 
1158 #define FatAreNamesEqual(IRPCONTEXT,NAMEA,NAMEB) ( \
1159  ((ULONG)(NAMEA).Length == (ULONG)(NAMEB).Length) && \
1160  (RtlEqualMemory( &(NAMEA).Buffer[0], \
1161  &(NAMEB).Buffer[0], \
1162  (NAMEA).Length )) \
1163 )
1164 
1165 //
1166 // BOOLEAN
1167 // FatIsNameShortOemValid (
1168 // IN PIRP_CONTEXT IrpContext,
1169 // IN OEM_STRING Name,
1170 // IN BOOLEAN CanContainWildCards,
1171 // IN BOOLEAN PathNamePermissible,
1172 // IN BOOLEAN LeadingBackslashPermissible
1173 // )
1174 //
1175 // /*++
1176 //
1177 // Routine Description:
1178 //
1179 // This routine scans the input name and verifies that if only
1180 // contains valid characters
1181 //
1182 // Arguments:
1183 //
1184 // Name - Supplies the input name to check.
1185 //
1186 // CanContainWildCards - Indicates if the name can contain wild cards
1187 // (i.e., * and ?).
1188 //
1189 // Return Value:
1190 //
1191 // BOOLEAN - Returns TRUE if the name is valid and FALSE otherwise.
1192 //
1193 // --*/
1194 //
1195 // The FatIsNameLongOemValid and FatIsNameLongUnicodeValid are similar.
1196 //
1197 
1198 #define FatIsNameShortOemValid(IRPCONTEXT,NAME,CAN_CONTAIN_WILD_CARDS,PATH_NAME_OK,LEADING_BACKSLASH_OK) ( \
1199  FsRtlIsFatDbcsLegal((NAME), \
1200  (CAN_CONTAIN_WILD_CARDS), \
1201  (PATH_NAME_OK), \
1202  (LEADING_BACKSLASH_OK)) \
1203 )
1204 
1205 #define FatIsNameLongOemValid(IRPCONTEXT,NAME,CAN_CONTAIN_WILD_CARDS,PATH_NAME_OK,LEADING_BACKSLASH_OK) ( \
1206  FsRtlIsHpfsDbcsLegal((NAME), \
1207  (CAN_CONTAIN_WILD_CARDS), \
1208  (PATH_NAME_OK), \
1209  (LEADING_BACKSLASH_OK)) \
1210 )
1211 
1212 static
1213 INLINE
1214 BOOLEAN
1216  PIRP_CONTEXT IrpContext,
1218  BOOLEAN CanContainWildcards,
1219  BOOLEAN PathNameOk,
1220  BOOLEAN LeadingBackslashOk
1221  )
1222 {
1223  ULONG i;
1224 
1225  UNREFERENCED_PARAMETER( IrpContext );
1226  UNREFERENCED_PARAMETER( LeadingBackslashOk );
1227  UNREFERENCED_PARAMETER( PathNameOk );
1228 
1229  //
1230  // I'm not bothering to do the whole thing, just enough to make this call look
1231  // the same as the others.
1232  //
1233 
1234  NT_ASSERT( !PathNameOk && !LeadingBackslashOk );
1235 
1236  for (i=0; i < Name->Length/sizeof(WCHAR); i++) {
1237 
1238  if ((Name->Buffer[i] < 0x80) &&
1239  !(FsRtlIsAnsiCharacterLegalHpfs(Name->Buffer[i], CanContainWildcards))) {
1240 
1241  return FALSE;
1242  }
1243  }
1244 
1245  return TRUE;
1246 }
1247 
1248 BOOLEAN
1250  IN PIRP_CONTEXT IrpContext,
1253  );
1254 
1255 VOID
1257  _In_ PIRP_CONTEXT IrpContext,
1258  _In_ OEM_STRING InputString,
1259  _Out_writes_bytes_(11) PFAT8DOT3 Output8dot3
1260  );
1261 
1262 VOID
1264  _In_ PIRP_CONTEXT IrpContext,
1266  _In_ BOOLEAN RestoreCase,
1267  _Out_ POEM_STRING OutputString
1268  );
1269 
1270 _Requires_lock_held_(_Global_critical_region_)
1271 VOID
1272 FatGetUnicodeNameFromFcb (
1273  IN PIRP_CONTEXT IrpContext,
1274  IN PFCB Fcb,
1276  );
1277 
1278 _Requires_lock_held_(_Global_critical_region_)
1279 VOID
1280 FatSetFullFileNameInFcb (
1281  IN PIRP_CONTEXT IrpContext,
1282  IN PFCB Fcb
1283  );
1284 
1285 VOID
1287  _In_ PIRP_CONTEXT IrpContext,
1288  _Inout_ PFCB Fcb,
1289  _In_ PUNICODE_STRING FinalName
1290  );
1291 
1292 VOID
1294  IN PIRP_CONTEXT IrpContext,
1297  );
1298 
1299 _Requires_lock_held_(_Global_critical_region_)
1300 VOID
1301 FatSelectNames (
1302  IN PIRP_CONTEXT IrpContext,
1307  IN PUNICODE_STRING SuggestedShortName OPTIONAL,
1311  );
1312 
1313 VOID
1315  IN PIRP_CONTEXT IrpContext,
1320  );
1321 
1322 BOOLEAN
1324  IN PIRP_CONTEXT IrpContext,
1326  );
1327 
1328 VOID
1330  IN PUNICODE_STRING ShortNameWithCase,
1331  IN BOOLEAN LowerCase8,
1332  IN BOOLEAN LowerCase3
1333  );
1334 
1335 
1336 //
1337 // Resources support routines/macros, implemented in ResrcSup.c
1338 //
1339 // The following routines/macros are used for gaining shared and exclusive
1340 // access to the global/vcb data structures. The routines are implemented
1341 // in ResrcSup.c. There is a global resources that everyone tries to take
1342 // out shared to do their work, with the exception of mount/dismount which
1343 // take out the global resource exclusive. All other resources only work
1344 // on their individual item. For example, an Fcb resource does not take out
1345 // a Vcb resource. But the way the file system is structured we know
1346 // that when we are processing an Fcb other threads cannot be trying to remove
1347 // or alter the Fcb, so we do not need to acquire the Vcb.
1348 //
1349 // The procedures/macros are:
1350 //
1351 // Macro FatData Vcb Fcb Subsequent macros
1352 //
1353 // AcquireExclusiveGlobal Read/Write None None ReleaseGlobal
1354 //
1355 // AcquireSharedGlobal Read None None ReleaseGlobal
1356 //
1357 // AcquireExclusiveVcb Read Read/Write None ReleaseVcb
1358 //
1359 // AcquireSharedVcb Read Read None ReleaseVcb
1360 //
1361 // AcquireExclusiveFcb Read None Read/Write ConvertToSharFcb
1362 // ReleaseFcb
1363 //
1364 // AcquireSharedFcb Read None Read ReleaseFcb
1365 //
1366 // ConvertToSharedFcb Read None Read ReleaseFcb
1367 //
1368 // ReleaseGlobal
1369 //
1370 // ReleaseVcb
1371 //
1372 // ReleaseFcb
1373 //
1374 
1375 //
1376 // FINISHED
1377 // FatAcquireExclusiveGlobal (
1378 // IN PIRP_CONTEXT IrpContext
1379 // );
1380 //
1381 // FINISHED
1382 // FatAcquireSharedGlobal (
1383 // IN PIRP_CONTEXT IrpContext
1384 // );
1385 //
1386 
1387 #define FatAcquireExclusiveGlobal(IRPCONTEXT) ( \
1388  ExAcquireResourceExclusiveLite( &FatData.Resource, BooleanFlagOn((IRPCONTEXT)->Flags, IRP_CONTEXT_FLAG_WAIT) ) \
1389 )
1390 
1391 #define FatAcquireSharedGlobal(IRPCONTEXT) ( \
1392  ExAcquireResourceSharedLite( &FatData.Resource, BooleanFlagOn((IRPCONTEXT)->Flags, IRP_CONTEXT_FLAG_WAIT) ) \
1393 )
1394 
1395 //
1396 // The following macro must only be called when Wait is TRUE!
1397 //
1398 // FatAcquireExclusiveVolume (
1399 // IN PIRP_CONTEXT IrpContext,
1400 // IN PVCB Vcb
1401 // );
1402 //
1403 // FatReleaseVolume (
1404 // IN PIRP_CONTEXT IrpContext,
1405 // IN PVCB Vcb
1406 // );
1407 //
1408 
1409 #define FatAcquireExclusiveVolume(IRPCONTEXT,VCB) { \
1410  PFCB __FFFFFcb = NULL; \
1411  NT_ASSERT(FlagOn((IRPCONTEXT)->Flags, IRP_CONTEXT_FLAG_WAIT)); \
1412  (VOID)FatAcquireExclusiveVcb( (IRPCONTEXT), (VCB) ); \
1413  while ( (__FFFFFcb = FatGetNextFcbBottomUp((IRPCONTEXT), __FFFFFcb, (VCB)->RootDcb)) != NULL) { \
1414  (VOID)FatAcquireExclusiveFcb((IRPCONTEXT), __FFFFFcb ); \
1415  } \
1416 }
1417 
1418 #define FatReleaseVolume(IRPCONTEXT,VCB) { \
1419  PFCB __FFFFFcb = NULL; \
1420  NT_ASSERT(FlagOn((IRPCONTEXT)->Flags, IRP_CONTEXT_FLAG_WAIT)); \
1421  while ( (__FFFFFcb = FatGetNextFcbBottomUp((IRPCONTEXT), __FFFFFcb, (VCB)->RootDcb)) != NULL) { \
1422  (VOID)ExReleaseResourceLite( __FFFFFcb->Header.Resource ); \
1423  } \
1424  FatReleaseVcb((IRPCONTEXT), (VCB)); \
1425 }
1426 
1427 //
1428 // Macro to enable easy tracking of Vcb state transitions.
1429 //
1430 
1431 #ifdef FASTFATDBG
1432 #define FatSetVcbCondition( V, X) { \
1433  DebugTrace(0,DEBUG_TRACE_VERFYSUP,"%d -> ",(V)->VcbCondition); \
1434  DebugTrace(0,DEBUG_TRACE_VERFYSUP,"%x\n",(X)); \
1435  (V)->VcbCondition = (X); \
1436  }
1437 #else
1438 #define FatSetVcbCondition( V, X) (V)->VcbCondition = (X)
1439 #endif
1440 
1441 //
1442 // These macros can be used to determine what kind of FAT we have for an
1443 // initialized Vcb. It is somewhat more elegant to use these (visually).
1444 //
1445 
1446 #define FatIsFat32(VCB) ((BOOLEAN)((VCB)->AllocationSupport.FatIndexBitSize == 32))
1447 #define FatIsFat16(VCB) ((BOOLEAN)((VCB)->AllocationSupport.FatIndexBitSize == 16))
1448 #define FatIsFat12(VCB) ((BOOLEAN)((VCB)->AllocationSupport.FatIndexBitSize == 12))
1449 
1450 
1451 _Requires_lock_held_(_Global_critical_region_)
1453 FINISHED
1454 FatAcquireExclusiveVcb_Real (
1455  IN PIRP_CONTEXT IrpContext,
1458  );
1459 
1460 #define FatAcquireExclusiveVcb( IC, V) FatAcquireExclusiveVcb_Real( IC, V, FALSE)
1461 #define FatAcquireExclusiveVcbNoOpCheck( IC, V) FatAcquireExclusiveVcb_Real( IC, V, TRUE)
1462 
1463 _Requires_lock_held_(_Global_critical_region_)
1464 _When_(return != 0, _Acquires_shared_lock_(Vcb->Resource))
1465 FINISHED
1466 FatAcquireSharedVcb (
1467  IN PIRP_CONTEXT IrpContext,
1468  IN PVCB Vcb
1469  );
1470 
1471 _Requires_lock_held_(_Global_critical_region_)
1473 FINISHED
1474 FatAcquireExclusiveFcb (
1475  IN PIRP_CONTEXT IrpContext,
1476  IN PFCB Fcb
1477  );
1478 
1479 _Requires_lock_held_(_Global_critical_region_)
1481 FINISHED
1482 FatAcquireSharedFcb (
1483  IN PIRP_CONTEXT IrpContext,
1484  IN PFCB Fcb
1485  );
1486 
1487 _Requires_lock_held_(_Global_critical_region_)
1489 FINISHED
1491  IN PIRP_CONTEXT IrpContext,
1492  IN PFCB Fcb
1493  );
1494 
1495 #define FatVcbAcquiredExclusive(IRPCONTEXT,VCB) ( \
1496  ExIsResourceAcquiredExclusiveLite(&(VCB)->Resource) || \
1497  ExIsResourceAcquiredExclusiveLite(&FatData.Resource) \
1498 )
1499 
1500 #define FatFcbAcquiredShared(IRPCONTEXT,FCB) ( \
1501  ExIsResourceAcquiredSharedLite((FCB)->Header.Resource) \
1502 )
1503 
1504 #define FatFcbAcquiredExclusive(IRPCONTEXT,FCB) ( \
1505  ExIsResourceAcquiredExclusiveLite((FCB)->Header.Resource) \
1506 )
1507 
1508 #define FatAcquireDirectoryFileMutex(VCB) { \
1509  NT_ASSERT(KeAreApcsDisabled()); \
1510  ExAcquireFastMutexUnsafe(&(VCB)->DirectoryFileCreationMutex); \
1511 }
1512 
1513 #define FatReleaseDirectoryFileMutex(VCB) { \
1514  NT_ASSERT(KeAreApcsDisabled()); \
1515  ExReleaseFastMutexUnsafe(&(VCB)->DirectoryFileCreationMutex); \
1516 }
1517 
1518 //
1519 // The following are cache manager call backs
1520 
1521 BOOLEAN
1523  IN PVOID Vcb,
1524  IN BOOLEAN Wait
1525  );
1526 
1527 VOID
1529  IN PVOID Vcb
1530  );
1531 
1532 _Requires_lock_held_(_Global_critical_region_)
1533 BOOLEAN
1534 NTAPI
1535 FatAcquireFcbForLazyWrite (
1536  IN PVOID Null,
1537  IN BOOLEAN Wait
1538  );
1539 
1540 _Requires_lock_held_(_Global_critical_region_)
1541 VOID
1542 NTAPI
1543 FatReleaseFcbFromLazyWrite (
1544  IN PVOID Null
1545  );
1546 
1547 _Requires_lock_held_(_Global_critical_region_)
1548 BOOLEAN
1549 NTAPI
1550 FatAcquireFcbForReadAhead (
1551  IN PVOID Null,
1552  IN BOOLEAN Wait
1553  );
1554 
1555 _Requires_lock_held_(_Global_critical_region_)
1556 VOID
1557 NTAPI
1558 FatReleaseFcbFromReadAhead (
1559  IN PVOID Null
1560  );
1561 
1562 _Function_class_(FAST_IO_ACQUIRE_FOR_CCFLUSH)
1563 _Requires_lock_held_(_Global_critical_region_)
1564 NTSTATUS
1565 NTAPI
1566 FatAcquireForCcFlush (
1569  );
1570 
1571 _Function_class_(FAST_IO_RELEASE_FOR_CCFLUSH)
1572 _Requires_lock_held_(_Global_critical_region_)
1573 NTSTATUS
1574 NTAPI
1575 FatReleaseForCcFlush (
1578  );
1579 
1580 BOOLEAN
1581 NTAPI
1583  IN PVOID Fcb,
1584  IN BOOLEAN Wait
1585  );
1586 
1587 VOID
1588 NTAPI
1590  IN PVOID Fcb
1591  );
1592 
1593 _Requires_lock_held_(_Global_critical_region_)
1594 NTSTATUS
1595 NTAPI
1596 FatFilterCallbackAcquireForCreateSection (
1599  );
1600 
1601 //
1602 // VOID
1603 // FatConvertToSharedFcb (
1604 // IN PIRP_CONTEXT IrpContext,
1605 // IN PFCB Fcb
1606 // );
1607 //
1608 
1609 #define FatConvertToSharedFcb(IRPCONTEXT,Fcb) { \
1610  ExConvertExclusiveToSharedLite( (Fcb)->Header.Resource ); \
1611  }
1612 
1613 //
1614 // VOID
1615 // FatReleaseGlobal (
1616 // IN PIRP_CONTEXT IrpContext
1617 // );
1618 //
1619 // VOID
1620 // FatReleaseVcb (
1621 // IN PIRP_CONTEXT IrpContext,
1622 // IN PVCB Vcb
1623 // );
1624 //
1625 // VOID
1626 // FatReleaseFcb (
1627 // IN PIRP_CONTEXT IrpContext,
1628 // IN PVCB Vcb
1629 // );
1630 //
1631 
1632 #define FatDeleteResource(RESRC) { \
1633  ExDeleteResourceLite( (RESRC) ); \
1634 }
1635 
1636 #define FatReleaseGlobal(IRPCONTEXT) { \
1637  ExReleaseResourceLite( &(FatData.Resource) ); \
1638  }
1639 
1640 #define FatReleaseVcb(IRPCONTEXT,Vcb) { \
1641  ExReleaseResourceLite( &((Vcb)->Resource) ); \
1642  }
1643 
1644 #define FatReleaseFcb(IRPCONTEXT,Fcb) { \
1645  ExReleaseResourceLite( (Fcb)->Header.Resource ); \
1646  }
1647 
1648 //
1649 // The following macro is used to retrieve the oplock structure within
1650 // the Fcb. This structure was moved to the advanced Fcb header
1651 // in Win8.
1652 //
1653 
1654 #if (NTDDI_VERSION >= NTDDI_WIN8)
1655 
1656 #define FatGetFcbOplock(F) &(F)->Header.Oplock
1657 
1658 #else
1659 
1660 #define FatGetFcbOplock(F) &(F)->Specific.Fcb.Oplock
1661 
1662 #endif
1663 
1664 
1665 //
1666 // In-memory structure support routine, implemented in StrucSup.c
1667 //
1668 
1669 _Requires_lock_held_(_Global_critical_region_)
1670 VOID
1671 FatInitializeVcb (
1672  IN PIRP_CONTEXT IrpContext,
1675  IN PVPB Vpb,
1677  );
1678 
1679 VOID
1681  IN PIRP_CONTEXT IrpContext,
1682  IN PVCB Vcb
1683  );
1684 
1685 VOID
1686 FatDeleteVcb (
1687  IN PIRP_CONTEXT IrpContext,
1688  IN PVCB Vcb
1689  );
1690 
1691 _Requires_lock_held_(_Global_critical_region_)
1692 VOID
1693 FatCreateRootDcb (
1694  IN PIRP_CONTEXT IrpContext,
1695  IN PVCB Vcb
1696  );
1697 
1698 PFCB
1699 FatCreateFcb (
1700  IN PIRP_CONTEXT IrpContext,
1701  IN PVCB Vcb,
1702  IN PDCB ParentDcb,
1703  IN ULONG LfnOffsetWithinDirectory,
1704  IN ULONG DirentOffsetWithinDirectory,
1705  IN PDIRENT Dirent,
1707  IN PUNICODE_STRING OrigLfn OPTIONAL,
1708  IN BOOLEAN IsPagingFile,
1709  IN BOOLEAN SingleResource
1710  );
1711 
1712 PDCB
1713 FatCreateDcb (
1714  IN PIRP_CONTEXT IrpContext,
1715  IN PVCB Vcb,
1716  IN PDCB ParentDcb,
1717  IN ULONG LfnOffsetWithinDirectory,
1718  IN ULONG DirentOffsetWithinDirectory,
1719  IN PDIRENT Dirent,
1721  );
1722 
1723 VOID
1724 FatDeleteFcb (
1725  IN PIRP_CONTEXT IrpContext,
1726  IN PFCB *Fcb
1727  );
1728 
1729 PCCB
1730 FatCreateCcb (
1731  IN PIRP_CONTEXT IrpContext
1732  );
1733 
1734 VOID
1736  IN PCCB Ccb
1737  );
1738 
1739 VOID
1740 FatDeleteCcb (
1741  IN PIRP_CONTEXT IrpContext,
1742  IN PCCB *Ccb
1743  );
1744 
1747  IN PIRP Irp,
1748  IN BOOLEAN Wait
1749  );
1750 
1751 VOID
1753  IN PIRP_CONTEXT IrpContext
1754  );
1755 
1756 #ifdef FASTFATDBG
1757 #define FatDeleteIrpContext(IRPCONTEXT) { \
1758  FatDeleteIrpContext_Real((IRPCONTEXT)); \
1759  (IRPCONTEXT) = NULL; \
1760 }
1761 #else
1762 #define FatDeleteIrpContext(IRPCONTEXT) { \
1763  FatDeleteIrpContext_Real((IRPCONTEXT)); \
1764 }
1765 #endif // FASTFAT_DBG
1766 
1767 PFCB
1769  IN PIRP_CONTEXT IrpContext,
1770  IN PFCB Fcb,
1771  IN PFCB TerminationFcb
1772  );
1773 
1774 PFCB
1776  IN PIRP_CONTEXT IrpContext,
1777  IN PFCB Fcb,
1778  IN PFCB TerminationFcb
1779  );
1780 
1781 //
1782 // These two macros just make the code a bit cleaner.
1783 //
1784 
1785 #define FatGetFirstChild(DIR) ((PFCB)( \
1786  IsListEmpty(&(DIR)->Specific.Dcb.ParentDcbQueue) ? NULL : \
1787  CONTAINING_RECORD((DIR)->Specific.Dcb.ParentDcbQueue.Flink, \
1788  DCB, \
1789  ParentDcbLinks.Flink)))
1790 
1791 #define FatGetNextSibling(FILE) ((PFCB)( \
1792  &(FILE)->ParentDcb->Specific.Dcb.ParentDcbQueue.Flink == \
1793  (PVOID)(FILE)->ParentDcbLinks.Flink ? NULL : \
1794  CONTAINING_RECORD((FILE)->ParentDcbLinks.Flink, \
1795  FCB, \
1796  ParentDcbLinks.Flink)))
1797 
1798 _Requires_lock_held_(_Global_critical_region_)
1799 BOOLEAN
1800 FatCheckForDismount (
1801  IN PIRP_CONTEXT IrpContext,
1803  IN BOOLEAN Force
1804  );
1805 
1806 VOID
1808  IN PIRP_CONTEXT IrpContext,
1809  PFCB Fcb,
1810  PDIRENT Dirent,
1812  );
1813 
1814 _Requires_lock_held_(_Global_critical_region_)
1815 VOID
1816 FatCheckFreeDirentBitmap (
1817  IN PIRP_CONTEXT IrpContext,
1818  IN PDCB Dcb
1819  );
1820 
1821 ULONG
1823  IN PIRP_CONTEXT IrpContext,
1824  IN PVCB Vcb
1825  );
1826 
1827 VOID
1829  IN PVCB Vcb
1830  );
1831 
1834  IN PVCB Vcb
1835  );
1836 
1837 //
1838 // BOOLEAN
1839 // FatIsRawDevice (
1840 // IN PIRP_CONTEXT IrpContext,
1841 // IN NTSTATUS Status
1842 // );
1843 //
1844 
1845 #define FatIsRawDevice(IC,S) ( \
1846  ((S) == STATUS_DEVICE_NOT_READY) || \
1847  ((S) == STATUS_NO_MEDIA_IN_DEVICE) \
1848 )
1849 
1850 
1851 //
1852 // Routines to support managing file names Fcbs and Dcbs.
1853 // Implemented in SplaySup.c
1854 //
1855 
1856 VOID
1857 FatInsertName (
1858  IN PIRP_CONTEXT IrpContext,
1861  );
1862 
1863 VOID
1865  IN PIRP_CONTEXT IrpContext,
1866  IN PFCB Fcb
1867  );
1868 
1869 PFCB
1870 FatFindFcb (
1871  IN PIRP_CONTEXT IrpContext,
1873  IN PSTRING Name,
1874  OUT PBOOLEAN FileNameDos OPTIONAL
1875  );
1876 
1877 BOOLEAN
1879  IN PIRP_CONTEXT IrpContext,
1880  IN PVCB Vcb
1881  );
1882 
1883 typedef enum _COMPARISON {
1887 } COMPARISON;
1888 
1889 COMPARISON
1891  IN PSTRING NameA,
1892  IN PSTRING NameB
1893  );
1894 
1895 //
1896 // Do a macro here to check for a common case.
1897 //
1898 
1899 #define CompareNames(NAMEA,NAMEB) ( \
1900  *(PUCHAR)(NAMEA)->Buffer != *(PUCHAR)(NAMEB)->Buffer ? \
1901  *(PUCHAR)(NAMEA)->Buffer < *(PUCHAR)(NAMEB)->Buffer ? \
1902  IsLessThan : IsGreaterThan : \
1903  FatCompareNames((PSTRING)(NAMEA), (PSTRING)(NAMEB)) \
1904 )
1905 
1906 //
1907 // Time conversion support routines, implemented in TimeSup.c
1908 //
1909 
1910 _Success_(return != FALSE)
1911 BOOLEAN
1912 FatNtTimeToFatTime (
1913  _In_ PIRP_CONTEXT IrpContext,
1918  );
1919 
1922  _In_ PIRP_CONTEXT IrpContext,
1924  _In_ UCHAR TenMilliSeconds
1925  );
1926 
1929  _In_ PIRP_CONTEXT IrpContext,
1930  _In_ FAT_DATE FatDate
1931  );
1932 
1935  _In_ PIRP_CONTEXT IrpContext
1936  );
1937 
1938 
1939 //
1940 // Low level verification routines, implemented in VerfySup.c
1941 //
1942 // The first routine is called to help process a verify IRP. Its job is
1943 // to walk every Fcb/Dcb and mark them as need to be verified.
1944 //
1945 // The other routines are used by every dispatch routine to verify that
1946 // an Vcb/Fcb/Dcb is still good. The routine walks as much of the opened
1947 // file/directory tree as necessary to make sure that the path is still valid.
1948 // The function result indicates if the procedure needed to block for I/O.
1949 // If the structure is bad the procedure raise the error condition
1950 // STATUS_FILE_INVALID, otherwise they simply return to their caller
1951 //
1952 
1953 typedef enum _FAT_VOLUME_STATE {
1958 
1959 VOID
1961  IN PIRP_CONTEXT IrpContext,
1962  IN PFCB Fcb,
1963  IN FCB_CONDITION FcbCondition,
1964  IN BOOLEAN Recursive
1965  );
1966 
1967 VOID
1968 FatVerifyVcb (
1969  IN PIRP_CONTEXT IrpContext,
1970  IN PVCB Vcb
1971  );
1972 
1973 _Requires_lock_held_(_Global_critical_region_)
1974 VOID
1975 FatVerifyFcb (
1976  IN PIRP_CONTEXT IrpContext,
1977  IN PFCB Fcb
1978  );
1979 
1980 
1981 KDEFERRED_ROUTINE FatCleanVolumeDpc;
1982 
1983 VOID
1984 NTAPI
1986  _In_ PKDPC Dpc,
1990  );
1991 
1992 _Requires_lock_held_(_Global_critical_region_)
1993 VOID
1994 FatMarkVolume (
1995  IN PIRP_CONTEXT IrpContext,
1998  );
1999 
2000 WORKER_THREAD_ROUTINE FatFspMarkVolumeDirtyWithRecover;
2001 
2002 VOID
2003 NTAPI
2006  );
2007 
2008 VOID
2010  IN PIRP_CONTEXT IrpContext,
2011  IN PVCB Vcb
2012  );
2013 
2014 VOID
2016  IN PIRP_CONTEXT IrpContext,
2017  IN PVCB Vcb
2018  );
2019 
2020 VOID
2022  IN PIRP_CONTEXT IrpContext
2023  );
2024 
2025 _Requires_lock_held_(_Global_critical_region_)
2026 NTSTATUS
2027 FatPerformVerify (
2028  _In_ PIRP_CONTEXT IrpContext,
2031  );
2032 
2033 
2034 //
2035 // Work queue routines for posting and retrieving an Irp, implemented in
2036 // workque.c
2037 //
2038 
2039 VOID
2040 NTAPI
2042  IN PVOID Context,
2043  IN PIRP Irp
2044  );
2045 
2046 VOID
2047 NTAPI
2048 FatPrePostIrp (
2049  IN PVOID Context,
2050  IN PIRP Irp
2051  );
2052 
2053 VOID
2055  IN PIRP_CONTEXT IrpContext,
2056  IN PIRP Irp
2057  );
2058 
2059 NTSTATUS
2061  IN PIRP_CONTEXT IrpContext,
2062  IN PIRP Irp
2063  );
2064 
2065 //
2066 // Miscellaneous support routines
2067 //
2068 
2069 //
2070 // ULONG
2071 // PtrOffset (
2072 // IN PVOID BasePtr,
2073 // IN PVOID OffsetPtr
2074 // );
2075 //
2076 
2077 #define PtrOffset(BASE,OFFSET) ((ULONG)((ULONG_PTR)(OFFSET) - (ULONG_PTR)(BASE)))
2078 
2079 //
2080 // This macro takes a pointer (or ulong) and returns its rounded up word
2081 // value
2082 //
2083 
2084 #define WordAlign(Ptr) ( \
2085  ((((ULONG)(Ptr)) + 1) & 0xfffffffe) \
2086  )
2087 
2088 //
2089 // This macro takes a pointer (or ulong) and returns its rounded up longword
2090 // value
2091 //
2092 
2093 #define LongAlign(Ptr) ( \
2094  ((((ULONG)(Ptr)) + 3) & 0xfffffffc) \
2095  )
2096 
2097 //
2098 // This macro takes a pointer (or ulong) and returns its rounded up quadword
2099 // value
2100 //
2101 
2102 #define QuadAlign(Ptr) ( \
2103  ((((ULONG)(Ptr)) + 7) & 0xfffffff8) \
2104  )
2105 
2106 //
2107 // The following types and macros are used to help unpack the packed and
2108 // misaligned fields found in the Bios parameter block
2109 //
2110 
2111 typedef union _UCHAR1 {
2112  UCHAR Uchar[1];
2114 } UCHAR1, *PUCHAR1;
2115 
2116 typedef union _UCHAR2 {
2117  UCHAR Uchar[2];
2119 } UCHAR2, *PUCHAR2;
2120 
2121 typedef union _UCHAR4 {
2122  UCHAR Uchar[4];
2124 } UCHAR4, *PUCHAR4;
2125 
2126 //
2127 // This macro copies an unaligned src byte to an aligned dst byte
2128 //
2129 
2130 #define CopyUchar1(Dst,Src) { \
2131  *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
2132  }
2133 
2134 //
2135 // This macro copies an unaligned src word to an aligned dst word
2136 //
2137 
2138 #define CopyUchar2(Dst,Src) { \
2139  *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
2140  }
2141 
2142 //
2143 // This macro copies an unaligned src longword to an aligned dsr longword
2144 //
2145 
2146 #define CopyUchar4(Dst,Src) { \
2147  *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
2148  }
2149 
2150 #define CopyU4char(Dst,Src) { \
2151  *((UNALIGNED UCHAR4 *)(Dst)) = *((UCHAR4 *)(Src)); \
2152  }
2153 
2154 //
2155 // VOID
2156 // FatNotifyReportChange (
2157 // IN PIRP_CONTEXT IrpContext,
2158 // IN PVCB Vcb,
2159 // IN PFCB Fcb,
2160 // IN ULONG Filter,
2161 // IN ULONG Action
2162 // );
2163 //
2164 
2165 #define FatNotifyReportChange(I,V,F,FL,A) { \
2166  if ((F)->FullFileName.Buffer == NULL) { \
2167  FatSetFullFileNameInFcb((I),(F)); \
2168  } \
2169  NT_ASSERT( (F)->FullFileName.Length != 0 ); \
2170  NT_ASSERT( (F)->FinalNameLength != 0 ); \
2171  NT_ASSERT( (F)->FullFileName.Length > (F)->FinalNameLength ); \
2172  NT_ASSERT( (F)->FullFileName.Buffer[((F)->FullFileName.Length - (F)->FinalNameLength)/sizeof(WCHAR) - 1] == L'\\' ); \
2173  FsRtlNotifyFullReportChange( (V)->NotifySync, \
2174  &(V)->DirNotifyList, \
2175  (PSTRING)&(F)->FullFileName, \
2176  (USHORT) ((F)->FullFileName.Length - \
2177  (F)->FinalNameLength), \
2178  (PSTRING)NULL, \
2179  (PSTRING)NULL, \
2180  (ULONG)FL, \
2181  (ULONG)A, \
2182  (PVOID)NULL ); \
2183 }
2184 
2185 
2186 //
2187 // The FSD Level dispatch routines. These routines are called by the
2188 // I/O system via the dispatch table in the Driver Object.
2189 //
2190 // They each accept as input a pointer to a device object (actually most
2191 // expect a volume device object, with the exception of the file system
2192 // control function which can also take a file system device object), and
2193 // a pointer to the IRP. They either perform the function at the FSD level
2194 // or post the request to the FSP work queue for FSP level processing.
2195 //
2196 
2199 NTSTATUS
2200 NTAPI
2201 FatFsdCleanup ( // implemented in Cleanup.c
2202  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2203  _Inout_ PIRP Irp
2204  );
2205 
2208 NTSTATUS
2209 NTAPI
2210 FatFsdClose ( // implemented in Close.c
2211  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2212  _Inout_ PIRP Irp
2213  );
2214 
2217 NTSTATUS
2218 NTAPI
2219 FatFsdCreate ( // implemented in Create.c
2220  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2221  _Inout_ PIRP Irp
2222  );
2223 
2224 
2227 NTSTATUS
2228 NTAPI
2229 FatFsdDeviceControl ( // implemented in DevCtrl.c
2230  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2231  _Inout_ PIRP Irp
2232  );
2233 
2236 NTSTATUS
2237 NTAPI
2238 FatFsdDirectoryControl ( // implemented in DirCtrl.c
2239  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2240  _Inout_ PIRP Irp
2241  );
2242 
2245 NTSTATUS
2246 NTAPI
2247 FatFsdQueryEa ( // implemented in Ea.c
2248  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2249  _Inout_ PIRP Irp
2250  );
2251 
2254 NTSTATUS
2255 NTAPI
2256 FatFsdSetEa ( // implemented in Ea.c
2257  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2258  _Inout_ PIRP Irp
2259  );
2260 
2263 NTSTATUS
2264 NTAPI
2265 FatFsdQueryInformation ( // implemented in FileInfo.c
2266  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2267  _Inout_ PIRP Irp
2268  );
2269 
2272 NTSTATUS
2273 NTAPI
2274 FatFsdSetInformation ( // implemented in FileInfo.c
2275  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2276  _Inout_ PIRP Irp
2277  );
2278 
2281 NTSTATUS
2282 NTAPI
2283 FatFsdFlushBuffers ( // implemented in Flush.c
2284  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2285  _Inout_ PIRP Irp
2286  );
2287 
2290 NTSTATUS
2291 NTAPI
2292 FatFsdFileSystemControl ( // implemented in FsCtrl.c
2293  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2294  _Inout_ PIRP Irp
2295  );
2296 
2299 NTSTATUS
2300 NTAPI
2301 FatFsdLockControl ( // implemented in LockCtrl.c
2302  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2303  _Inout_ PIRP Irp
2304  );
2305 
2308 NTSTATUS
2309 NTAPI
2310 FatFsdPnp ( // implemented in Pnp.c
2311  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2312  _Inout_ PIRP Irp
2313  );
2314 
2317 NTSTATUS
2318 NTAPI
2319 FatFsdRead ( // implemented in Read.c
2320  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2321  _Inout_ PIRP Irp
2322  );
2323 
2326 NTSTATUS
2327 NTAPI
2328 FatFsdShutdown ( // implemented in Shutdown.c
2329  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2330  _Inout_ PIRP Irp
2331  );
2332 
2335 NTSTATUS
2336 NTAPI
2337 FatFsdQueryVolumeInformation ( // implemented in VolInfo.c
2338  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2339  _Inout_ PIRP Irp
2340  );
2341 
2344 NTSTATUS
2345 NTAPI
2346 FatFsdSetVolumeInformation ( // implemented in VolInfo.c
2347  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2348  _Inout_ PIRP Irp
2349  );
2350 
2353 NTSTATUS
2354 NTAPI
2355 FatFsdWrite ( // implemented in Write.c
2356  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2357  _Inout_ PIRP Irp
2358  );
2359 
2360 //
2361 // The following macro is used to determine if an FSD thread can block
2362 // for I/O or wait for a resource. It returns TRUE if the thread can
2363 // block and FALSE otherwise. This attribute can then be used to call
2364 // the FSD & FSP common work routine with the proper wait value.
2365 //
2366 
2367 #define CanFsdWait(IRP) IoIsOperationSynchronous(Irp)
2368 
2369 
2370 //
2371 // The FSP level dispatch/main routine. This is the routine that takes
2372 // IRP's off of the work queue and calls the appropriate FSP level
2373 // work routine.
2374 //
2375 
2376 
2377 WORKER_THREAD_ROUTINE FatFspDispatch;
2378 
2379 VOID
2380 NTAPI
2381 FatFspDispatch ( // implemented in FspDisp.c
2383  );
2384 
2385 //
2386 // The following routines are the FSP work routines that are called
2387 // by the preceding FatFspDispath routine. Each takes as input a pointer
2388 // to the IRP, perform the function, and return a pointer to the volume
2389 // device object that they just finished servicing (if any). The return
2390 // pointer is then used by the main Fsp dispatch routine to check for
2391 // additional IRPs in the volume's overflow queue.
2392 //
2393 // Each of the following routines is also responsible for completing the IRP.
2394 // We moved this responsibility from the main loop to the individual routines
2395 // to allow them the ability to complete the IRP and continue post processing
2396 // actions.
2397 //
2398 
2399 _Requires_lock_held_(_Global_critical_region_)
2400 NTSTATUS
2401 FatCommonCleanup ( // implemented in Cleanup.c
2402  IN PIRP_CONTEXT IrpContext,
2403  IN PIRP Irp
2404  );
2405 
2406 _Requires_lock_held_(_Global_critical_region_)
2407 NTSTATUS
2408 FatCommonClose ( // implemented in Close.c
2409  IN PVCB Vcb,
2411  IN PCCB Ccb,
2413  IN BOOLEAN Wait,
2415  OUT PBOOLEAN VcbDeleted OPTIONAL
2416  );
2417 
2418 _Requires_lock_held_(_Global_critical_region_)
2419 VOID
2420 FatFspClose ( // implemented in Close.c
2422  );
2423 
2424 _Requires_lock_held_(_Global_critical_region_)
2425 NTSTATUS
2426 FatCommonCreate ( // implemented in Create.c
2427  _Inout_ PIRP_CONTEXT IrpContext,
2428  _Inout_ PIRP Irp
2429  );
2430 
2431 #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
2432 
2433 _Requires_lock_held_(_Global_critical_region_)
2434 NTSTATUS
2435 FatCommonCreateOnNewStack ( // implemented in Create.c
2436  _Inout_ PIRP_CONTEXT IrpContext,
2437  _Inout_ PIRP Irp
2438  );
2439 
2440 _Requires_lock_held_(_Global_critical_region_)
2441 VOID
2442 FatCommonCreateCallout ( // implemented in Create.c
2443  _In_ PFAT_CALLOUT_PARAMETERS CalloutParameters
2444  );
2445 
2446 #endif
2447 
2448 _Requires_lock_held_(_Global_critical_region_)
2449 NTSTATUS
2450 FatCommonDirectoryControl ( // implemented in DirCtrl.c
2451  IN PIRP_CONTEXT IrpContext,
2452  IN PIRP Irp
2453  );
2454 
2455 _Requires_lock_held_(_Global_critical_region_)
2456 NTSTATUS
2457 FatCommonDeviceControl ( // implemented in DevCtrl.c
2458  IN PIRP_CONTEXT IrpContext,
2459  IN PIRP Irp
2460  );
2461 
2462 NTSTATUS
2463 FatCommonQueryEa ( // implemented in Ea.c
2464  IN PIRP_CONTEXT IrpContext,
2465  IN PIRP Irp
2466  );
2467 
2468 NTSTATUS
2469 FatCommonSetEa ( // implemented in Ea.c
2470  IN PIRP_CONTEXT IrpContext,
2471  IN PIRP Irp
2472  );
2473 
2474 _Requires_lock_held_(_Global_critical_region_)
2475 NTSTATUS
2476 FatCommonQueryInformation ( // implemented in FileInfo.c
2477  IN PIRP_CONTEXT IrpContext,
2478  IN PIRP Irp
2479  );
2480 
2481 _Requires_lock_held_(_Global_critical_region_)
2482 NTSTATUS
2483 FatCommonSetInformation ( // implemented in FileInfo.c
2484  IN PIRP_CONTEXT IrpContext,
2485  IN PIRP Irp
2486  );
2487 
2488 _Requires_lock_held_(_Global_critical_region_)
2489 NTSTATUS
2490 FatCommonFlushBuffers ( // implemented in Flush.c
2491  IN PIRP_CONTEXT IrpContext,
2492  IN PIRP Irp
2493  );
2494 
2495 _Requires_lock_held_(_Global_critical_region_)
2496 NTSTATUS
2497 FatCommonFileSystemControl ( // implemented in FsCtrl.c
2498  IN PIRP_CONTEXT IrpContext,
2499  IN PIRP Irp
2500  );
2501 
2502 _Requires_lock_held_(_Global_critical_region_)
2503 NTSTATUS
2504 FatCommonLockControl ( // implemented in LockCtrl.c
2505  IN PIRP_CONTEXT IrpContext,
2506  IN PIRP Irp
2507  );
2508 
2509 _Requires_lock_held_(_Global_critical_region_)
2510 NTSTATUS
2511 FatCommonPnp ( // implemented in Pnp.c
2512  IN PIRP_CONTEXT IrpContext,
2513  IN PIRP Irp
2514  );
2515 
2516 _Requires_lock_held_(_Global_critical_region_)
2517 NTSTATUS
2518 FatCommonRead ( // implemented in Read.c
2519  IN PIRP_CONTEXT IrpContext,
2520  IN PIRP Irp
2521  );
2522 
2523 _Requires_lock_held_(_Global_critical_region_)
2524 NTSTATUS
2525 FatCommonShutdown ( // implemented in Shutdown.c
2526  IN PIRP_CONTEXT IrpContext,
2527  IN PIRP Irp
2528  );
2529 
2530 _Requires_lock_held_(_Global_critical_region_)
2531 NTSTATUS
2532 FatCommonQueryVolumeInfo ( // implemented in VolInfo.c
2533  IN PIRP_CONTEXT IrpContext,
2534  IN PIRP Irp
2535  );
2536 
2537 _Requires_lock_held_(_Global_critical_region_)
2538 NTSTATUS
2539 FatCommonSetVolumeInfo ( // implemented in VolInfo.c
2540  IN PIRP_CONTEXT IrpContext,
2541  IN PIRP Irp
2542  );
2543 
2544 _Requires_lock_held_(_Global_critical_region_)
2545 NTSTATUS
2546 FatCommonWrite ( // implemented in Write.c
2547  IN PIRP_CONTEXT IrpContext,
2548  IN PIRP Irp
2549  );
2550 
2551 //
2552 // The following is implemented in Flush.c, and does what is says.
2553 //
2554 
2555 _Requires_lock_held_(_Global_critical_region_)
2556 NTSTATUS
2557 FatFlushFile (
2558  IN PIRP_CONTEXT IrpContext,
2559  IN PFCB Fcb,
2561  );
2562 
2563 _Requires_lock_held_(_Global_critical_region_)
2564 NTSTATUS
2565 FatFlushDirectory (
2566  IN PIRP_CONTEXT IrpContext,
2567  IN PDCB Dcb,
2569  );
2570 
2571 NTSTATUS
2572 FatFlushFat (
2573  IN PIRP_CONTEXT IrpContext,
2574  IN PVCB Vcb
2575  );
2576 
2577 _Requires_lock_held_(_Global_critical_region_)
2578 NTSTATUS
2579 FatFlushVolume (
2580  IN PIRP_CONTEXT IrpContext,
2581  IN PVCB Vcb,
2583  );
2584 
2585 NTSTATUS
2587  IN PIRP_CONTEXT IrpContext,
2588  IN PIRP Irp,
2590  );
2591 
2592 VOID
2594  IN PIRP_CONTEXT IrpContext,
2595  IN PVCB Vcb,
2596  IN ULONG Cluster,
2597  IN ULONG Count
2598 );
2599 
2600 VOID
2602  IN PIRP_CONTEXT IrpContext,
2603  IN PFCB Fcb
2604 );
2605 
2606 
2607 
2608 //
2609 // The following procedure is used by the FSP and FSD routines to complete
2610 // an IRP.
2611 //
2612 // Note that this macro allows either the Irp or the IrpContext to be
2613 // null, however the only legal order to do this in is:
2614 //
2615 // FatCompleteRequest( NULL, Irp, Status ); // completes Irp & preserves context
2616 // ...
2617 // FatCompleteRequest( IrpContext, NULL, DontCare ); // deallocates context
2618 //
2619 // This would typically be done in order to pass a "naked" IrpContext off to
2620 // the Fsp for post processing, such as read ahead.
2621 //
2622 
2623 VOID
2625  IN PIRP_CONTEXT IrpContext,
2626  IN PIRP Irp,
2628  );
2629 
2630 #define FatCompleteRequest(IRPCONTEXT,IRP,STATUS) { \
2631  FatCompleteRequest_Real(IRPCONTEXT,IRP,STATUS); \
2632 }
2633 
2634 BOOLEAN
2636  IN PIRP Irp
2637  );
2638 
2639 //
2640 // The Following routine makes a popup
2641 //
2642 
2643 _Requires_lock_held_(_Global_critical_region_)
2644 VOID
2645 FatPopUpFileCorrupt (
2646  IN PIRP_CONTEXT IrpContext,
2647  IN PFCB Fcb
2648  );
2649 
2650 //
2651 // Here are the callbacks used by the I/O system for checking for fast I/O or
2652 // doing a fast query info call, or doing fast lock calls.
2653 //
2654 _Function_class_(FAST_IO_CHECK_IF_POSSIBLE)
2655 BOOLEAN
2656 NTAPI
2657 FatFastIoCheckIfPossible (
2660  IN ULONG Length,
2661  IN BOOLEAN Wait,
2662  IN ULONG LockKey,
2666  );
2667 
2668 _Function_class_(FAST_IO_QUERY_BASIC_INFO)
2669 BOOLEAN
2670 NTAPI
2671 FatFastQueryBasicInfo (
2673  IN BOOLEAN Wait,
2677  );
2678 
2679 _Function_class_(FAST_IO_QUERY_STANDARD_INFO)
2680 BOOLEAN
2681 NTAPI
2682 FatFastQueryStdInfo (
2684  IN BOOLEAN Wait,
2688  );
2689 
2690 _Function_class_(FAST_IO_QUERY_NETWORK_OPEN_INFO)
2691 BOOLEAN
2692 NTAPI
2693 FatFastQueryNetworkOpenInfo (
2695  IN BOOLEAN Wait,
2699  );
2700 
2701 _Function_class_(FAST_IO_LOCK)
2702 BOOLEAN
2703 NTAPI
2704 FatFastLock (
2709  ULONG Key,
2714  );
2715 
2716 _Function_class_(FAST_IO_UNLOCK_SINGLE)
2717 BOOLEAN
2718 NTAPI
2719 FatFastUnlockSingle (
2724  ULONG Key,
2727  );
2728 
2729 _Function_class_(FAST_IO_UNLOCK_ALL)
2730 BOOLEAN
2731 NTAPI
2732 FatFastUnlockAll (
2737  );
2738 
2739 _Function_class_(FAST_IO_UNLOCK_ALL_BY_KEY)
2740 BOOLEAN
2741 NTAPI
2742 FatFastUnlockAllByKey (
2744  PVOID ProcessId,
2745  ULONG Key,
2748  );
2749 
2750 
2751 VOID
2753  IN PIRP_CONTEXT IrpContext,
2754  IN PVCB Vcb,
2755  IN ULONG StartIndex OPTIONAL,
2756  IN ULONG EndIndex OPTIONAL,
2757  IN BOOLEAN SetupWindows,
2758  IN PFAT_WINDOW SwitchToWindow OPTIONAL,
2759  IN PULONG BitMapBuffer OPTIONAL
2760  );
2761 
2762 BOOLEAN
2764  IN PIRP_CONTEXT IrpContext,
2766  );
2767 
2768 //
2769 // The following macro is used to determine is a file has been deleted.
2770 //
2771 // BOOLEAN
2772 // IsFileDeleted (
2773 // IN PIRP_CONTEXT IrpContext,
2774 // IN PFCB Fcb
2775 // );
2776 //
2777 
2778 #define IsFileDeleted(IRPCONTEXT,FCB) \
2779  (FlagOn((FCB)->FcbState, FCB_STATE_DELETE_ON_CLOSE) && \
2780  ((FCB)->UncleanCount == 0))
2781 
2782 //
2783 // The following macro is used by the dispatch routines to determine if
2784 // an operation is to be done with or without Write Through.
2785 //
2786 // BOOLEAN
2787 // IsFileWriteThrough (
2788 // IN PFILE_OBJECT FileObject,
2789 // IN PVCB Vcb
2790 // );
2791 //
2792 
2793 #define IsFileWriteThrough(FO,VCB) ( \
2794  BooleanFlagOn((FO)->Flags, FO_WRITE_THROUGH) \
2795 )
2796 
2797 //
2798 // The following macro is used to set the is fast i/o possible field in
2799 // the common part of the nonpaged fcb. It checks that this is actually
2800 // an FCB (as opposed to a DCB) so that directory oplock code works properly.
2801 //
2802 //
2803 // BOOLEAN
2804 // FatIsFastIoPossible (
2805 // IN PFCB Fcb
2806 // );
2807 //
2808 
2809 
2810 #define FatIsFastIoPossible(FCB) ((BOOLEAN) \
2811  ((((FCB)->FcbCondition != FcbGood) || \
2812  (NodeType( (FCB) ) != FAT_NTC_FCB) || \
2813  !FsRtlOplockIsFastIoPossible( FatGetFcbOplock(FCB) )) ? \
2814  FastIoIsNotPossible \
2815  : \
2816  (!FsRtlAreThereCurrentFileLocks( &(FCB)->Specific.Fcb.FileLock ) && \
2817  ((FCB)->NonPaged->OutstandingAsyncWrites == 0) && \
2818  !FlagOn( (FCB)->Vcb->VcbState, VCB_STATE_FLAG_WRITE_PROTECTED ) ? \
2819  FastIoIsPossible \
2820  : \
2821  FastIoIsQuestionable \
2822  ) \
2823  ) \
2824 )
2825 
2826 
2827 #if (NTDDI_VERSION >= NTDDI_WIN8)
2828 
2829 //
2830 // Detect whether this file can have an oplock on it. As of Windows 8 file and
2831 // directories can have oplocks.
2832 //
2833 
2834 #define FatIsNodeTypeOplockable(N) ( \
2835  ((N) == FAT_NTC_FCB) || \
2836  ((N) == FAT_NTC_ROOT_DCB) || \
2837  ((N) == FAT_NTC_DCB) \
2838 )
2839 
2840 #else
2841 
2842 #define FatIsNodeTypeOplockable(N) ( \
2843  ((N) == FAT_NTC_FCB) \
2844 )
2845 
2846 #endif
2847 
2848 #define FatIsFileOplockable(F) ( \
2849  FatIsNodeTypeOplockable( NodeType( (F) )) \
2850 )
2851 
2852 //
2853 // The following macro is used to detemine if the file object is opened
2854 // for read only access (i.e., it is not also opened for write access or
2855 // delete access).
2856 //
2857 // BOOLEAN
2858 // IsFileObjectReadOnly (
2859 // IN PFILE_OBJECT FileObject
2860 // );
2861 //
2862 
2863 #define IsFileObjectReadOnly(FO) (!((FO)->WriteAccess | (FO)->DeleteAccess))
2864 
2865 
2866 //
2867 // The following two macro are used by the Fsd/Fsp exception handlers to
2868 // process an exception. The first macro is the exception filter used in the
2869 // Fsd/Fsp to decide if an exception should be handled at this level.
2870 // The second macro decides if the exception is to be finished off by
2871 // completing the IRP, and cleaning up the Irp Context, or if we should
2872 // bugcheck. Exception values such as STATUS_FILE_INVALID (raised by
2873 // VerfySup.c) cause us to complete the Irp and cleanup, while exceptions
2874 // such as accvio cause us to bugcheck.
2875 //
2876 // The basic structure for fsd/fsp exception handling is as follows:
2877 //
2878 // FatFsdXxx(...)
2879 // {
2880 // try {
2881 //
2882 // ...
2883 //
2884 // } except(FatExceptionFilter( IrpContext, GetExceptionCode() )) {
2885 //
2886 // Status = FatProcessException( IrpContext, Irp, GetExceptionCode() );
2887 // }
2888 //
2889 // Return Status;
2890 // }
2891 //
2892 // To explicitly raise an exception that we expect, such as
2893 // STATUS_FILE_INVALID, use the below macro FatRaiseStatus(). To raise a
2894 // status from an unknown origin (such as CcFlushCache()), use the macro
2895 // FatNormalizeAndRaiseStatus. This will raise the status if it is expected,
2896 // or raise STATUS_UNEXPECTED_IO_ERROR if it is not.
2897 //
2898 // If we are vicariously handling exceptions without using FatProcessException(),
2899 // if there is the possibility that we raised that exception, one *must*
2900 // reset the IrpContext so a subsequent raise in the course of handling this
2901 // request that is *not* explicit, i.e. like a pagein error, does not get
2902 // spoofed into believing that the first raise status is the reason the second
2903 // occured. This could have really serious consequences.
2904 //
2905 // It is an excellent idea to always FatResetExceptionState in these cases.
2906 //
2907 // Note that when using these two macros, the original status is placed in
2908 // IrpContext->ExceptionStatus, signaling FatExceptionFilter and
2909 // FatProcessException that the status we actually raise is by definition
2910 // expected.
2911 //
2912 
2913 ULONG
2915  IN PIRP_CONTEXT IrpContext,
2916  IN PEXCEPTION_POINTERS ExceptionPointer
2917  );
2918 
2919 #if DBG
2920 ULONG
2921 FatBugCheckExceptionFilter (
2922  IN PEXCEPTION_POINTERS ExceptionPointer
2923  );
2924 #endif
2925 
2926 _Requires_lock_held_(_Global_critical_region_)
2927 NTSTATUS
2928 FatProcessException (
2929  IN PIRP_CONTEXT IrpContext,
2932  );
2933 
2934 //
2935 // VOID
2936 // FatRaiseStatus (
2937 // IN PRIP_CONTEXT IrpContext,
2938 // IN NT_STATUS Status
2939 // );
2940 //
2941 //
2942 
2943 #if DBG
2944 #ifdef _MSC_VER
2945 #define DebugBreakOnStatus(S) { \
2946 __pragma(warning(push)) \
2947 __pragma(warning(disable:4127)) \
2948  if (FatTestRaisedStatus) { \
2949  if ((S) == STATUS_DISK_CORRUPT_ERROR || (S) == STATUS_FILE_CORRUPT_ERROR) { \
2950 __pragma(warning(pop)) \
2951  DbgPrint( "FAT: Breaking on interesting raised status (0x%08x)\n", (S) );\
2952  DbgPrint( "FAT: Set FatTestRaisedStatus @ 0x%p to 0 to disable\n", \
2953  &FatTestRaisedStatus ); \
2954  NT_ASSERT(FALSE); \
2955  } \
2956  } \
2957 }
2958 #else
2959 #define DebugBreakOnStatus(S) { \
2960  if (FatTestRaisedStatus) { \
2961  if ((S) == STATUS_DISK_CORRUPT_ERROR || (S) == STATUS_FILE_CORRUPT_ERROR) { \
2962  DbgPrint( "FAT: Breaking on interesting raised status (0x%08x)\n", (S) );\
2963  DbgPrint( "FAT: Set FatTestRaisedStatus @ 0x%p to 0 to disable\n", \
2964  &FatTestRaisedStatus ); \
2965  NT_ASSERT(FALSE); \
2966  } \
2967  } \
2968 }
2969 #endif
2970 #else
2971 #define DebugBreakOnStatus(S)
2972 #endif
2973 
2974 #define FatRaiseStatus(IRPCONTEXT,STATUS) { \
2975  (IRPCONTEXT)->ExceptionStatus = (STATUS); \
2976  DebugBreakOnStatus( (STATUS) ) \
2977  ExRaiseStatus( (STATUS) ); \
2978 }
2979 
2980 #define FatResetExceptionState( IRPCONTEXT ) { \
2981  (IRPCONTEXT)->ExceptionStatus = STATUS_SUCCESS; \
2982 }
2983 
2984 //
2985 // VOID
2986 // FatNormalAndRaiseStatus (
2987 // IN PRIP_CONTEXT IrpContext,
2988 // IN NT_STATUS Status
2989 // );
2990 //
2991 
2992 #define FatNormalizeAndRaiseStatus(IRPCONTEXT,STATUS) { \
2993  (IRPCONTEXT)->ExceptionStatus = (STATUS); \
2994  ExRaiseStatus(FsRtlNormalizeNtstatus((STATUS),STATUS_UNEXPECTED_IO_ERROR)); \
2995 }
2996 
2997 
2998 //
2999 // The following macros are used to establish the semantics needed
3000 // to do a return from within a try-finally clause. As a rule every
3001 // try clause must end with a label call try_exit. For example,
3002 //
3003 // try {
3004 // :
3005 // :
3006 //
3007 // try_exit: NOTHING;
3008 // } finally {
3009 //
3010 // :
3011 // :
3012 // }
3013 //
3014 // Every return statement executed inside of a try clause should use the
3015 // try_return macro. If the compiler fully supports the try-finally construct
3016 // then the macro should be
3017 //
3018 // #define try_return(S) { return(S); }
3019 //
3020 // If the compiler does not support the try-finally construct then the macro
3021 // should be
3022 //
3023 // #define try_return(S) { S; goto try_exit; }
3024 //
3025 
3026 #define try_return(S) { S; goto try_exit; }
3027 #define try_leave(S) { S; _SEH2_LEAVE; }
3028 
3029 
3032  IN PVCB Vcb,
3034  );
3035 
3036 
3037 //
3038 // These routines define the FileId for FAT. Lacking a fixed/uniquifiable
3039 // notion, we simply come up with one which is unique in a given snapshot
3040 // of the volume. As long as the parent directory is not moved or compacted,
3041 // it may even be permanent.
3042 //
3043 
3044 //
3045 // The internal information used to identify the fcb/dcb on the
3046 // volume is the byte offset of the dirent of the file on disc.
3047 // Our root always has fileid 0. FAT32 roots are chains and can
3048 // use the LBO of the cluster, 12/16 roots use the lbo in the Vcb.
3049 //
3050 
3051 #define FatGenerateFileIdFromDirentOffset(ParentDcb,DirentOffset) \
3052  ((ParentDcb) ? ((NodeType(ParentDcb) != FAT_NTC_ROOT_DCB || FatIsFat32((ParentDcb)->Vcb)) ? \
3053  FatGetLboFromIndex( (ParentDcb)->Vcb, \
3054  (ParentDcb)->FirstClusterOfFile ) : \
3055  (ParentDcb)->Vcb->AllocationSupport.RootDirectoryLbo) + \
3056  (DirentOffset) \
3057  : \
3058  0)
3059 
3060 //
3061 //
3062 
3063 #define FatGenerateFileIdFromFcb(Fcb) \
3064  FatGenerateFileIdFromDirentOffset( (Fcb)->ParentDcb, (Fcb)->DirentOffsetWithinDirectory )
3065 
3066 //
3067 // Wrap to handle the ./.. cases appropriately. Note that we commute NULL parent to 0. This would
3068 // only occur in an illegal root ".." entry.
3069 //
3070 
3071 #define FATDOT ((ULONG)0x2020202E)
3072 #define FATDOTDOT ((ULONG)0x20202E2E)
3073 
3074 #define FatGenerateFileIdFromDirentAndOffset(Dcb,Dirent,DirentOffset) \
3075  ((*((PULONG)(Dirent)->FileName)) == FATDOT ? FatGenerateFileIdFromFcb(Dcb) : \
3076  ((*((PULONG)(Dirent)->FileName)) == FATDOTDOT ? ((Dcb)->ParentDcb ? \
3077  FatGenerateFileIdFromFcb((Dcb)->ParentDcb) : \
3078  0) : \
3079  FatGenerateFileIdFromDirentOffset(Dcb,DirentOffset)))
3080 
3081 
3082 //
3083 // BOOLEAN
3084 // FatDeviceIsFatFsdo(
3085 // IN PDEVICE_OBJECT D
3086 // );
3087 //
3088 // Evaluates to TRUE if the supplied device object is one of the file system devices
3089 // we created at initialisation.
3090 //
3091 
3092 #define FatDeviceIsFatFsdo( D) (((D) == FatData.DiskFileSystemDeviceObject) || ((D) == FatData.CdromFileSystemDeviceObject))
3093 
3094 
3095 //
3096 // BlockAlign(): Aligns P on the next V boundary.
3097 // BlockAlignTruncate(): Aligns P on the prev V boundary.
3098 //
3099 
3100 #define BlockAlign(P,V) ((ASSERT( V != 0)), (((P)) + (V-1) & (0-(V))))
3101 #define BlockAlignTruncate(P,V) ((P) & (0-(V)))
3102 
3103 #define IsDirectory(FcbOrDcb) ((NodeType((FcbOrDcb)) == FAT_NTC_DCB) || (NodeType((FcbOrDcb)) == FAT_NTC_ROOT_DCB))
3104 
3105 #endif // _FATPROCS_
3106 
3107 
VOID FatRepinBcb(IN PIRP_CONTEXT IrpContext, IN PBCB Bcb)
Definition: cachesup.c:1317
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING IN PUNICODE_STRING SuggestedShortName IN OUT BOOLEAN IN OUT BOOLEAN * AllLowerExtension
Definition: fatprocs.h:1303
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING ShortName
Definition: fatprocs.h:1303
_COMPARISON
Definition: fatprocs.h:1883
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2373
ULONG ForceAlignment
Definition: cdprocs.h:1683
* PNTSTATUS
Definition: strlen.c:14
VOID FatConstructNamesInFcb(IN PIRP_CONTEXT IrpContext, PFCB Fcb, PDIRENT Dirent, PUNICODE_STRING Lfn OPTIONAL)
Definition: strucsup.c:3010
IN PVCB IN ULONG AbsoluteClusterHint
Definition: fatprocs.h:343
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
#define IN
Definition: typedefs.h:39
return
Definition: dirsup.c:529
VOID FatAppendPackedEa(IN PIRP_CONTEXT IrpContext, IN OUT PEA_SET_HEADER *EaSetHeader, IN OUT PULONG PackedEasLength, IN OUT PULONG AllocationLength, IN PFILE_FULL_EA_INFORMATION FullEa, IN ULONG BytesPerCluster)
Definition: easup.c:2967
VOID FatExtendString(_Inout_ PVOID String, _In_ USHORT DesiredBufferSize, _In_ BOOLEAN FreeOldBuffer, __out_opt PBOOLEAN NeedsFree)
PCWSTR Expression
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2706
IN PVCB IN FAT_VOLUME_STATE VolumeState
Definition: fatprocs.h:1996
VOID FatPreallocateCloseContext(IN PVCB Vcb)
OUT PVOID * CompletionContext
Definition: fatprocs.h:1599
#define TRUE
Definition: types.h:120
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
FAT_TIME_STAMP FatGetCurrentFatTime(_In_ PIRP_CONTEXT IrpContext)
Definition: timesup.c:317
ULONG FatLocateNextEa(IN PIRP_CONTEXT IrpContext, IN PPACKED_EA FirstPackedEa, IN ULONG PackedEasLength, IN ULONG PreviousOffset)
Definition: easup.c:3257
union _UCHAR2 UCHAR2
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:411
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
PCLOSE_CONTEXT FatAllocateCloseContext(IN PVCB Vcb)
#define INLINE
Definition: fatprocs.h:77
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2029
_Requires_lock_held_(_Global_critical_region_) VOID FatLookupFileAllocation(IN PIRP_CONTEXT IrpContext
VOID FatTearDownVcb(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: strucsup.c:672
#define IRP_MJ_FLUSH_BUFFERS
unsigned char Uchar
Definition: utypes.h:45
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING IN PUNICODE_STRING SuggestedShortName IN OUT BOOLEAN * AllLowerComponent
Definition: fatprocs.h:1303
LARGE_INTEGER FatFatDateToNtTime(_In_ PIRP_CONTEXT IrpContext, _In_ FAT_DATE FatDate)
Definition: timesup.c:171
VOID FatUnicodeToUpcaseOem(IN PIRP_CONTEXT IrpContext, IN POEM_STRING OemString, IN PUNICODE_STRING UnicodeString)
Definition: namesup.c:632
VOID FatMarkEaRangeDirty(IN PIRP_CONTEXT IrpContext, IN PFILE_OBJECT EaFileObject, IN OUT PEA_RANGE EaRange)
Definition: easup.c:3709
VOID FatReadEaSet(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN USHORT EaHandle, IN POEM_STRING FileName, IN BOOLEAN ReturnEntireSet, OUT PEA_RANGE EaSetRange)
Definition: easup.c:1306
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN IN BOOLEAN ExclusiveFcb
Definition: fatprocs.h:913
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2659
IN PIRP IN NTSTATUS ExceptionCode
Definition: fatprocs.h:2930
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
ERESOURCE Resource
Definition: fatstruc.h:403
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
Definition: cdstruc.h:908
VOID Fat8dot3ToString(_In_ PIRP_CONTEXT IrpContext, _In_ PDIRENT Dirent, _In_ BOOLEAN RestoreCase, _Out_ POEM_STRING OutputString)
Definition: namesup.c:179
IN PDCB IN PCCB Ccb
Definition: fatprocs.h:725
VOID FatAddToWorkque(IN PIRP_CONTEXT IrpContext, IN PIRP Irp)
Definition: workque.c:277
NTSTATUS FatToggleMediaEjectDisable(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN BOOLEAN PreventRemoval)
Definition: deviosup.c:3495
VOID FatMultipleAsync(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PIRP Irp, IN ULONG MultipleIrpCount, IN PIO_RUN IoRuns)
Definition: deviosup.c:1622
Definition: cdstruc.h:1073
ULONG32 VBO
Definition: fat.h:38
unsigned char * PUCHAR
Definition: retypes.h:3
IN PVCB IN OUT PLARGE_MCB IN PLARGE_MCB SecondMcb
Definition: fatprocs.h:373
enum _FAT_VOLUME_STATE * PFAT_VOLUME_STATE
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID _In_ ULONG _In_ BOOLEAN InternalDeviceIoControl
Definition: iofuncs.h:713
PVOID FatMapUserBuffer(IN PIRP_CONTEXT IrpContext, IN OUT PIRP Irp)
Definition: deviosup.c:3357
NTSTATUS FatCompleteMdl(IN PIRP_CONTEXT IrpContext, IN PIRP Irp)
Definition: cachesup.c:1728
IN PDCB Dcb
Definition: fatprocs.h:424
VOID NTAPI FatOplockComplete(IN PVOID Context, IN PIRP Irp)
Definition: workque.c:35
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT * Dirent
Definition: fatprocs.h:725
LONG NTSTATUS
Definition: precomp.h:26
PFCB FatFindFcb(IN PIRP_CONTEXT IrpContext, IN OUT PRTL_SPLAY_LINKS *RootNode, IN PSTRING Name, OUT PBOOLEAN FileNameDos OPTIONAL)
Definition: splaysup.c:306
USHORT ForceAlignment
Definition: cdprocs.h:1678
IN PVCB IN ULONG EaSetLength
Definition: fatprocs.h:945
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
Definition: fatprocs.h:1303
VOID FatFlushFatEntries(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN ULONG Cluster, IN ULONG Count)
Definition: flush.c:1191
IN PFCB IN VBO OUT PLBO Lbo
Definition: fatprocs.h:306
#define _Outptr_
Definition: no_sal2.h:396
IN PFCB IN PCCB IN TYPE_OF_OPEN TypeOfOpen
Definition: fatprocs.h:2410
#define IRP_MJ_SET_VOLUME_INFORMATION
PFILE_OBJECT FatOpenEaFile(IN PIRP_CONTEXT IrpContext, IN PFCB EaFcb)
Definition: cachesup.c:979
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
VOID FatPinEaRange(IN PIRP_CONTEXT IrpContext, IN PFILE_OBJECT VirtualEaFile, IN PFCB EaFcb, IN OUT PEA_RANGE EaRange, IN ULONG StartingVbo, IN ULONG Length, IN NTSTATUS ErrorStatus)
Definition: easup.c:3512
_Acquires_shared_lock_(Vcb->Resource)) FINISHED FatAcquireSharedVcb(IN PIRP_CONTEXT IrpContext
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
Definition: cdstruc.h:504
VOID FatVerifyVcb(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: verfysup.c:270
LBO * PLBO
Definition: fat.h:36
IN PVCB IN PUCHAR IN ULONG IN POEM_STRING OUT PUSHORT EaHandle
Definition: fatprocs.h:893
IN PVCB IN BOOLEAN NoOpCheck
Definition: fatprocs.h:1456
static WCHAR String[]
Definition: stringtable.c:55
enum _TYPE_OF_OPEN TYPE_OF_OPEN
IN PDCB IN ULONG IN BOOLEAN RescanDir
Definition: fatprocs.h:698
static CC_FILE_SIZES FileSizes
_Acquires_exclusive_lock_(Vcb->Resource)) FINISHED FatAcquireExclusiveVcb_Real(IN PIRP_CONTEXT IrpContext
BOOLEAN FatLookupLastMcbEntry(IN PVCB Vcb, IN PLARGE_MCB Mcb, OUT PVBO Vbo, OUT PLBO Lbo, OUT PULONG Index OPTIONAL)
Definition: fsctrl.c:494
_In_ PVOID Parameter
Definition: ldrtypes.h:241
STRING OEM_STRING
Definition: umtypes.h:203
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB ParentDcb
Definition: create.c:4137
VOID FatSingleAsync(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN LBO Lbo, IN ULONG ByteCount, IN PIRP Irp)
Definition: deviosup.c:1990
VOID FatVerifyOperationIsLegal(IN PIRP_CONTEXT IrpContext)
Definition: verfysup.c:1304
KDEFERRED_ROUTINE FatCleanVolumeDpc
Definition: fatprocs.h:1981
VOID FatCompleteRequest_Real(IN PIRP_CONTEXT IrpContext, IN PIRP Irp, IN NTSTATUS Status)
Definition: fatdata.c:733
VOID FatLockUserBuffer(IN PIRP_CONTEXT IrpContext, IN OUT PIRP Irp, IN LOCK_OPERATION Operation, IN ULONG BufferLength)
Definition: deviosup.c:3276
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN CheckForReadOperation
Definition: fatprocs.h:2659
CHAR InputBuffer[80]
Definition: conmgr.c:33
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:934
#define _In_opt_
Definition: no_sal2.h:213
VOID FatConstructLabelDirent(IN PIRP_CONTEXT IrpContext, IN OUT PDIRENT Dirent, IN POEM_STRING Label)
Definition: dirsup.c:2440
IN PFCB IN BOOLEAN ReturnOnFailure
Definition: fatprocs.h:771
_Must_inspect_result_ _In_ ULONG RunIndex
Definition: fsrtlfuncs.h:538
IN PIRP IN PFCB IN ULONG IN ULONG IN ULONG UserByteCount
Definition: fatprocs.h:589
IN PFCB IN PCCB IN TYPE_OF_OPEN IN BOOLEAN IN BOOLEAN TopLevel
Definition: fatprocs.h:2410
PVCB IN BOOLEAN Force
Definition: fatprocs.h:1802
IN PDCB Parent
Definition: fatprocs.h:1303
VOID FatInitializeCacheMap(_In_ PFILE_OBJECT FileObject, _In_ PCC_FILE_SIZES FileSizes, _In_ BOOLEAN PinAccess, _In_ PCACHE_MANAGER_CALLBACKS Callbacks, _In_ PVOID LazyWriteContext)
Definition: cachesup.c:62
IN OUT PVCB OUT PDIRENT * EaDirent
Definition: fatprocs.h:913
IN PDCB IN ULONG LfnOffset
Definition: fatprocs.h:788
NTSTATUS FatCommonQueryEa(IN PIRP_CONTEXT IrpContext, IN PIRP Irp)
Definition: ea.c:250
IN PVCB Vcb
Definition: fatprocs.h:343
BOOLEAN FatScanForDataTrack(IN PIRP_CONTEXT IrpContext, IN PDEVICE_OBJECT TargetDeviceObject)
Definition: strucsup.c:3816
IN PFCB FcbOrDcb
Definition: fatprocs.h:306
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
LARGE_INTEGER FatFatTimeToNtTime(_In_ PIRP_CONTEXT IrpContext, _In_ FAT_TIME_STAMP FatTime, _In_ UCHAR TenMilliSeconds)
Definition: timesup.c:233
IN PFCB IN VBO OUT PLBO OUT PULONG OUT PBOOLEAN OUT PBOOLEAN EndOnMax
Definition: fatprocs.h:306
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID FatDeleteCcb(IN PIRP_CONTEXT IrpContext, IN PCCB *Ccb)
Definition: strucsup.c:2242
#define __out_opt
Definition: dbghelp.h:65
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
VOID FatPagingFileIo(IN PIRP Irp, IN PFCB Fcb)
Definition: deviosup.c:211
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:848
BOOLEAN FatLookupMcbEntry(IN PVCB Vcb, IN PLARGE_MCB Mcb, IN VBO Vbo, OUT PLBO Lbo, OUT PULONG ByteCount OPTIONAL, OUT PULONG Index OPTIONAL)
Definition: fsctrl.c:418
Definition: Header.h:8
_In_ ULONG BufferLength
Definition: usbdlib.h:225
VOID FatTearDownAllocationSupport(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: allocsup.c:547
LONGLONG LBO
Definition: fat.h:34
BOOLEAN FatLocateEaByName(IN PIRP_CONTEXT IrpContext, IN PPACKED_EA FirstPackedEa, IN ULONG PackedEasLength, IN POEM_STRING EaName, OUT PULONG Offset)
Definition: easup.c:3344
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG BOOLEAN FailImmediately
Definition: fatprocs.h:2706
ULONG FatVolumeUncleanCount(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
static INLINE BOOLEAN FatIsIoRangeValid(IN PVCB Vcb, IN LARGE_INTEGER Start, IN ULONG Length)
Definition: fatprocs.h:218
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN Reversible
Definition: fatprocs.h:411
VOID FatRemoveMcbEntry(IN PVCB Vcb, IN PLARGE_MCB Mcb, IN VBO Vbo, IN ULONG SectorCount)
Definition: fsctrl.c:599
VOID FatReleaseVolumeFromClose(IN PVOID Vcb)
#define IRP_MJ_SET_EA
BOOLEAN FatIsBootSectorFat(IN PPACKED_BOOT_SECTOR BootSector)
Definition: fsctrl.c:2522
VOID FatEnsureStringBufferEnough(_Inout_ PVOID String, _In_ USHORT DesiredBufferSize)
Definition: strucsup.c:3727
CLUSTER_TYPE FatInterpretClusterType(IN PVCB Vcb, IN FAT_ENTRY Entry)
Definition: allocsup.c:3471
VOID FatEvaluateNameCase(IN PIRP_CONTEXT IrpContext, IN PUNICODE_STRING Name, IN OUT BOOLEAN *AllLowerComponent, IN OUT BOOLEAN *AllLowerExtension, IN OUT BOOLEAN *CreateLfn)
Definition: namesup.c:891
unsigned char BOOLEAN
IN PFCB IN VBO OUT PLBO OUT PULONG OUT PBOOLEAN Allocated
Definition: fatprocs.h:306
VOID FatFlushDirentForFile(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb)
Definition: flush.c:1264
VOID FatTunnelFcbOrDcb(IN PFCB FcbOrDcb, IN PCCB Ccb OPTIONAL)
Definition: dirsup.c:652
#define _Out_writes_bytes_(size)
Definition: no_sal2.h:370
#define _Out_
Definition: no_sal2.h:323
enum _FCB_CONDITION FCB_CONDITION
FINISHED FatZeroData(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PFILE_OBJECT FileObject, IN ULONG StartingZero, IN ULONG ByteCount)
Definition: cachesup.c:1659
_In_ PLARGE_INTEGER _In_ BOOLEAN Rounding
Definition: fatprocs.h:1914
Definition: bufpool.h:45
IN PFCB Fcb
Definition: fatprocs.h:820
IN PFCB IN PDELETE_CONTEXT DeleteContext IN BOOLEAN DeleteEa
Definition: fatprocs.h:715
VOID FatSetFullNameInFcb(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ PUNICODE_STRING FinalName)
Definition: create.c:6718
NTSTATUS FatPerformDevIoCtrl(IN PIRP_CONTEXT IrpContext, IN ULONG IoControlCode, IN PDEVICE_OBJECT Device, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN BOOLEAN OverrideVerify, OUT PIO_STATUS_BLOCK Iosb OPTIONAL)
Definition: deviosup.c:3621
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
PDCB FatCreateDcb(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PDCB ParentDcb, IN ULONG LfnOffsetWithinDirectory, IN ULONG DirentOffsetWithinDirectory, IN PDIRENT Dirent, IN PUNICODE_STRING Lfn OPTIONAL)
Definition: strucsup.c:1611
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
IN PDCB TargetDcb
Definition: fatprocs.h:788
BOOLEAN NTAPI FatNoOpAcquire(IN PVOID Fcb, IN BOOLEAN Wait)
Definition: resrcsup.c:795
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
BOOLEAN FatCheckManageVolumeAccess(_In_ PIRP_CONTEXT IrpContext, _In_ PACCESS_STATE AccessState, _In_ KPROCESSOR_MODE ProcessorMode)
Definition: acchksup.c:176
_Success_(return !=FALSE) BOOLEAN FatNtTimeToFatTime(_In_ PIRP_CONTEXT IrpContext
Definition: fsctrl.c:3139
COMPARISON FatCompareNames(IN PSTRING NameA, IN PSTRING NameB)
Definition: splaysup.c:421
PIRP_CONTEXT FatCreateIrpContext(IN PIRP Irp, IN BOOLEAN Wait)
Definition: strucsup.c:2289
IN PFCB IN FAT_FLUSH_TYPE FlushType
Definition: fatprocs.h:1080
BOOLEAN FatIsIrpTopLevel(IN PIRP Irp)
Definition: fatdata.c:817
PMDL FatBuildZeroMdl(__in PIRP_CONTEXT IrpContext, __in ULONG Length)
Definition: deviosup.c:3734
VOID FatWaitSync(IN PIRP_CONTEXT IrpContext)
Definition: deviosup.c:2367
VOID FatRemoveNames(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb)
Definition: splaysup.c:222
NTSTATUS FatFlushFat(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: flush.c:801
_TYPE_OF_OPEN
Definition: cdprocs.h:576
_Acquires_shared_lock_ Fcb FINISHED FatAcquireSharedFcbWaitForEx(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb)
#define IRP_MJ_QUERY_EA
NTSTATUS FatUnlockVolumeInternal(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PFILE_OBJECT FileObject OPTIONAL)
Definition: fsctrl.c:3601
union _UCHAR4 UCHAR4
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2659
#define _Out_opt_
Definition: no_sal2.h:339
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:511
VOID FatUnpinEaRange(IN PIRP_CONTEXT IrpContext, IN OUT PEA_RANGE EaRange)
Definition: easup.c:3782
VOID FatDeleteFcb(IN PIRP_CONTEXT IrpContext, IN PFCB *Fcb)
Definition: strucsup.c:1940
IN PFILE_OBJECT FileObject
Definition: fatprocs.h:837
VOID FatCheckDirtyBit(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: verfysup.c:1185
VOID FatSetFileObject(IN PFILE_OBJECT FileObject OPTIONAL, IN TYPE_OF_OPEN TypeOfOpen, IN PVOID VcbOrFcbOrDcb, IN PCCB Ccb OPTIONAL)
Definition: filobsup.c:39
BOOLEAN FatIsHandleCountZero(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: strucsup.c:3602
const struct winhelp_callbacks Callbacks
Definition: callback.c:161
IN PVCB IN PDIRENT OUT PULONG EaLength
Definition: fatprocs.h:875
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
__wchar_t WCHAR
Definition: xmlstorage.h:180
return Iosb
Definition: create.c:4402
enum _CLUSTER_TYPE CLUSTER_TYPE
struct _FAT_ENUMERATION_CONTEXT * PFAT_ENUMERATION_CONTEXT
enum _FAT_FLUSH_TYPE FAT_FLUSH_TYPE
VOID FatInsertName(IN PIRP_CONTEXT IrpContext, IN PRTL_SPLAY_LINKS *RootNode, IN PFILE_NAME_NODE Name)
Definition: splaysup.c:39
PFCB FatCreateFcb(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PDCB ParentDcb, IN ULONG LfnOffsetWithinDirectory, IN ULONG DirentOffsetWithinDirectory, IN PDIRENT Dirent, IN PUNICODE_STRING Lfn OPTIONAL, IN PUNICODE_STRING OrigLfn OPTIONAL, IN BOOLEAN IsPagingFile, IN BOOLEAN SingleResource)
Definition: strucsup.c:1240
#define IRP_MJ_FILE_SYSTEM_CONTROL
IN PVCB IN ULONG IN PBCB OUT PDIRENT OUT PUSHORT OUT PEA_RANGE EaSetRange
Definition: fatprocs.h:945
BOOLEAN FatIsEaNameValid(IN PIRP_CONTEXT IrpContext, IN OEM_STRING Name)
Definition: easup.c:3429
static const UCHAR Index[8]
Definition: usbohci.c:18
IN PVCB IN OUT PLARGE_MCB IN VBO OUT PLARGE_MCB RemainingMcb
Definition: fatprocs.h:363
#define FsRtlIsAnsiCharacterLegalHpfs(C, WILD)
Definition: fsrtlfuncs.h:1614
NTSTATUS FatPrefetchPages(IN PIRP_CONTEXT IrpContext, IN PFILE_OBJECT FileObject, IN ULONG StartingPage, IN ULONG PageCount)
Definition: cachesup.c:1929
VOID FatDeleteVcb(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: strucsup.c:760
BOOLEAN FatGetNextMcbEntry(IN PVCB Vcb, IN PLARGE_MCB Mcb, IN ULONG RunIndex, OUT PVBO Vbo, OUT PLBO Lbo, OUT PULONG ByteCount)
Definition: fsctrl.c:541
FAT8DOT3 * PFAT8DOT3
Definition: fat.h:296
UCHAR ForceAlignment
Definition: cdprocs.h:1673
#define _Inout_
Definition: no_sal2.h:244
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
* PFILE_OBJECT
Definition: iotypes.h:1955
Definition: partlist.h:33
_In_opt_ PVOID _In_opt_ PUNICODE_STRING _In_ PSECURITY_DESCRIPTOR _In_ PACCESS_STATE AccessState
Definition: sefuncs.h:414
union _UCHAR4 * PUCHAR4
PFCB FatGetNextFcbBottomUp(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb, IN PFCB TerminationFcb)
Definition: strucsup.c:2513
VOID FatMarkFcbCondition(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb, IN FCB_CONDITION FcbCondition, IN BOOLEAN Recursive)
unsigned char UCHAR
Definition: xmlstorage.h:181
UCHAR FatLogOf(IN ULONG Value)
Definition: allocsup.c:4653
IN PDCB IN PUNICODE_STRING IN PUNICODE_STRING LfnTmp
Definition: fatprocs.h:752
VOID FatReadVolumeFile(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN VBO StartingVbo, IN ULONG ByteCount, OUT PBCB *Bcb, OUT PVOID *Buffer)
Definition: cachesup.c:102
char * PBOOLEAN
Definition: retypes.h:11
_In_ PLARGE_INTEGER NtTime
Definition: fatprocs.h:1914
VOID NTAPI FatNoOpRelease(IN PVOID Fcb)
Definition: resrcsup.c:842
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN ExactMatchRequired
Definition: fatprocs.h:343
IN PDCB IN ULONG IN ULONG DirentOffset
Definition: fatprocs.h:788
VBO * PVBO
Definition: fat.h:39
struct _FAT_ENUMERATION_CONTEXT FAT_ENUMERATION_CONTEXT
Definition: fsck.fat.h:192
IN PFCB IN VBO OUT PLBO OUT PULONG ByteCount
Definition: fatprocs.h:306
Definition: ketypes.h:687
PCCB FatCreateCcb(IN PIRP_CONTEXT IrpContext)
Definition: strucsup.c:2143
IN PDCB IN PDIRENT ParentDirent
Definition: fatprocs.h:707
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB IN PDEVICE_OBJECT FsDeviceObject
Definition: fatprocs.h:1673
VOID FatSyncUninitializeCacheMap(IN PIRP_CONTEXT IrpContext, IN PFILE_OBJECT FileObject)
Definition: cachesup.c:1812
enum _TYPE_OF_OPEN TYPE_OF_OPEN
IN PVCB IN ULONG FatIndex
Definition: fatprocs.h:382
BOOLEAN FatAcquireVolumeForClose(IN PVOID Vcb, IN BOOLEAN Wait)
ULONG SectorCount
Definition: part_xbox.c:31
DRIVER_DISPATCH(nfs41_FsdDispatch)
IN PVCB IN VBO StartingVbo
Definition: fatprocs.h:411
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
IN PVCB IN PLARGE_MCB IN BOOLEAN ZeroOnDeallocate
Definition: fatprocs.h:354
VOID FatDeleteIrpContext_Real(IN PIRP_CONTEXT IrpContext)
Definition: strucsup.c:2449
Status
Definition: gdiplustypes.h:24
BOOLEAN FatAddMcbEntry(IN PVCB Vcb, IN PLARGE_MCB Mcb, IN VBO Vbo, IN LBO Lbo, IN ULONG SectorCount)
Definition: fsctrl.c:364
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
IN PVCB IN OUT PLARGE_MCB IN VBO SplitAtVbo
Definition: fatprocs.h:363
#define _In_
Definition: no_sal2.h:204
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:319
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
union _UCHAR1 * PUCHAR1
BOOLEAN FatIsNameInExpression(IN PIRP_CONTEXT IrpContext, IN OEM_STRING Expression, IN OEM_STRING Name)
Definition: namesup.c:35
union _UCHAR2 * PUCHAR2
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
enum _COMPARISON COMPARISON
ULONG FatExceptionFilter(IN PIRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
Definition: fatdata.c:204
WORKER_THREAD_ROUTINE FatFspMarkVolumeDirtyWithRecover
Definition: fatprocs.h:2000
_In_ PLARGE_INTEGER _In_ BOOLEAN _Out_ PFAT_TIME_STAMP FatTime
Definition: fatprocs.h:1914
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
enum _LOCK_OPERATION LOCK_OPERATION
PVOID FatBufferUserBuffer(IN PIRP_CONTEXT IrpContext, IN OUT PIRP Irp, IN ULONG BufferLength)
Definition: deviosup.c:3411
unsigned short USHORT
Definition: pedump.c:61
VOID FatPinMappedData(IN PIRP_CONTEXT IrpContext, IN PDCB Dcb, IN VBO StartingVbo, IN ULONG ByteCount, OUT PBCB *Bcb)
Definition: cachesup.c:1866
static INLINE BOOLEAN FatIsNameLongUnicodeValid(PIRP_CONTEXT IrpContext, PUNICODE_STRING Name, BOOLEAN CanContainWildcards, BOOLEAN PathNameOk, BOOLEAN LeadingBackslashOk)
Definition: fatprocs.h:1215
VOID FatSetupAllocationSupport(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: allocsup.c:357
enum _FAT_VOLUME_STATE FAT_VOLUME_STATE
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:343
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4137
VOID FatExamineFatEntries(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN ULONG StartIndex OPTIONAL, IN ULONG EndIndex OPTIONAL, IN BOOLEAN SetupWindows, IN PFAT_WINDOW SwitchToWindow OPTIONAL, IN PULONG BitMapBuffer OPTIONAL)
Definition: allocsup.c:4718
NTSTATUS FatCommonSetEa(IN PIRP_CONTEXT IrpContext, IN PIRP Irp)
Definition: ea.c:659
_Function_class_(FAST_IO_ACQUIRE_FOR_CCFLUSH) _Requires_lock_held_(_Global_critical_region_) NTSTATUS NTAPI FatAcquireForCcFlush(IN PFILE_OBJECT FileObject
IN PVCB IN PDIRENT OUT PULONG NeedEaCount
Definition: fatprocs.h:884
VOID FatUnpinRepinnedBcbs(IN PIRP_CONTEXT IrpContext)
Definition: cachesup.c:1407
WORKER_THREAD_ROUTINE FatFspDispatch
Definition: fatprocs.h:2377
unsigned int * PULONG
Definition: retypes.h:1
#define _When_(expr, annos)
Definition: no_sal2.h:639
IN PDCB ParentDirectory
Definition: fatprocs.h:698
VOID FatFreeStringBuffer(_Inout_ PVOID String)
Definition: strucsup.c:3772
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG BOOLEAN BOOLEAN ExclusiveLock
Definition: fatprocs.h:2706
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
Definition: fatprocs.h:411
VOID FatCloseEaFile(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN BOOLEAN FlushFirst)
Definition: cachesup.c:1079
BOOLEAN FatCheckFileAccess(PIRP_CONTEXT IrpContext, IN UCHAR DirentAttributes, IN PACCESS_MASK DesiredAccess)
Definition: acchksup.c:39
_FAT_FLUSH_TYPE
Definition: fatprocs.h:1051
#define IRP_MJ_READ
Definition: rdpdr.c:46
VOID FatStringTo8dot3(_In_ PIRP_CONTEXT IrpContext, _In_ OEM_STRING InputString, _Out_writes_bytes_(11) PFAT8DOT3 Output8dot3)
Definition: namesup.c:79
VOID FatDeletePackedEa(IN PIRP_CONTEXT IrpContext, IN OUT PEA_SET_HEADER EaSetHeader, IN OUT PULONG PackedEasLength, IN ULONG Offset)
Definition: easup.c:3148
#define IRP_MJ_CLEANUP
union _UCHAR1 UCHAR1
Definition: iotypes.h:166
NTSTATUS FatFsdPostRequest(IN PIRP_CONTEXT IrpContext, IN PIRP Irp)
Definition: workque.c:229
#define OUT
Definition: typedefs.h:40
VOID FatLookupFatEntry(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN ULONG FatIndex, IN OUT PULONG FatEntry, IN OUT PFAT_ENUMERATION_CONTEXT Context)
Definition: allocsup.c:3563
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING IN PUNICODE_STRING SuggestedShortName IN OUT BOOLEAN IN OUT BOOLEAN IN OUT BOOLEAN * CreateLfn
Definition: fatprocs.h:1303
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
unsigned int ULONG
Definition: retypes.h:1
ACCESS_MASK * PACCESS_MASK
Definition: nt_native.h:41
NTSTATUS FatExplicitDeviceAccessGranted(IN PIRP_CONTEXT IrpContext, IN PDEVICE_OBJECT DeviceObject, IN PACCESS_STATE AccessState, IN KPROCESSOR_MODE ProcessorMode)
Definition: acchksup.c:225
PWCHAR Label
Definition: format.c:70
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
NTSTATUS FatHijackIrpAndFlushDevice(IN PIRP_CONTEXT IrpContext, IN PIRP Irp, IN PDEVICE_OBJECT TargetDeviceObject)
Definition: flush.c:1101
_In_ PLARGE_INTEGER _In_ BOOLEAN _Out_ PFAT_TIME_STAMP _Out_opt_ PUCHAR TenMsecs
Definition: fatprocs.h:1914
BOOLEAN FINISHED
Definition: fatprocs.h:104
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
VOID FatConstructDirent(IN PIRP_CONTEXT IrpContext, IN OUT PDIRENT Dirent, IN POEM_STRING FileName, IN BOOLEAN ComponentReallyLowercase, IN BOOLEAN ExtensionReallyLowercase, IN PUNICODE_STRING Lfn OPTIONAL, IN USHORT Attributes, IN BOOLEAN ZeroAndSetTimeFields, IN PLARGE_INTEGER SetCreationTime OPTIONAL)
Definition: dirsup.c:2171
IN PIRP IN PFCB IN ULONG IN ULONG IN ULONG IN ULONG StreamFlags
Definition: fatprocs.h:589
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1303
IN OUT PVCB OUT PDIRENT OUT PBCB * EaBcb
Definition: fatprocs.h:913
VOID FatUnicodeRestoreShortNameCase(IN PUNICODE_STRING ShortNameWithCase, IN BOOLEAN LowerCase8, IN BOOLEAN LowerCase3)
Definition: namesup.c:1041
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1673
IN PVCB IN ULONG IN FAT_ENTRY FatEntry
Definition: fatprocs.h:382
VOID NTAPI FatPrePostIrp(IN PVOID Context, IN PIRP Irp)
Definition: workque.c:91
#define __in
Definition: dbghelp.h:35
VOID FatQuickVerifyVcb(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: verfysup.c:1662
IN PLARGE_INTEGER FileOffset
Definition: fatprocs.h:2659
unsigned short * PUSHORT
Definition: retypes.h:2
IN PFCB IN VBO Vbo
Definition: fatprocs.h:306
BOOLEAN FatSpaceInName(IN PIRP_CONTEXT IrpContext, IN PUNICODE_STRING UnicodeName)
Definition: namesup.c:1003
TYPE_OF_OPEN FatDecodeFileObject(_In_ PFILE_OBJECT FileObject, _Outptr_ PVCB *Vcb, _Outptr_ PFCB *FcbOrDcb, _Outptr_ PCCB *Ccb)
Definition: filobsup.c:176
base of all file and directory entries
Definition: entries.h:82
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1673
VOID FatDeallocateCcbStrings(IN PCCB Ccb)
Definition: strucsup.c:2197
Definition: fat.h:274
_FAT_VOLUME_STATE
Definition: fatprocs.h:1953
IN PDCB IN ULONG DirentsNeeded
Definition: fatprocs.h:698
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:725
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
IN PDCB IN PUNICODE_STRING Lfn
Definition: fatprocs.h:752
PCONFIGURATION_COMPONENT_DATA RootNode
Definition: macharm.c:19
IN BOOLEAN Wait
Definition: fatprocs.h:1538
#define NT_ASSERT
Definition: rtlfuncs.h:3312
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
PFCB FatGetNextFcbTopDown(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb, IN PFCB TerminationFcb)
Definition: strucsup.c:2615
IN PDCB IN PCCB IN VBO OffsetToStartSearchFrom
Definition: fatprocs.h:725
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675