ReactOS  0.4.15-dev-2704-gd5265b0
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,
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
2054 #ifdef __REACTOS__
2055 NTAPI
2056 #endif
2058  IN PIRP_CONTEXT IrpContext,
2059  IN PIRP Irp
2060  );
2061 
2062 NTSTATUS
2064  IN PIRP_CONTEXT IrpContext,
2065  IN PIRP Irp
2066  );
2067 
2068 //
2069 // Miscellaneous support routines
2070 //
2071 
2072 //
2073 // ULONG
2074 // PtrOffset (
2075 // IN PVOID BasePtr,
2076 // IN PVOID OffsetPtr
2077 // );
2078 //
2079 
2080 #define PtrOffset(BASE,OFFSET) ((ULONG)((ULONG_PTR)(OFFSET) - (ULONG_PTR)(BASE)))
2081 
2082 //
2083 // This macro takes a pointer (or ulong) and returns its rounded up word
2084 // value
2085 //
2086 
2087 #define WordAlign(Ptr) ( \
2088  ((((ULONG)(Ptr)) + 1) & 0xfffffffe) \
2089  )
2090 
2091 //
2092 // This macro takes a pointer (or ulong) and returns its rounded up longword
2093 // value
2094 //
2095 
2096 #define LongAlign(Ptr) ( \
2097  ((((ULONG)(Ptr)) + 3) & 0xfffffffc) \
2098  )
2099 
2100 //
2101 // This macro takes a pointer (or ulong) and returns its rounded up quadword
2102 // value
2103 //
2104 
2105 #define QuadAlign(Ptr) ( \
2106  ((((ULONG)(Ptr)) + 7) & 0xfffffff8) \
2107  )
2108 
2109 //
2110 // The following types and macros are used to help unpack the packed and
2111 // misaligned fields found in the Bios parameter block
2112 //
2113 
2114 typedef union _UCHAR1 {
2115  UCHAR Uchar[1];
2117 } UCHAR1, *PUCHAR1;
2118 
2119 typedef union _UCHAR2 {
2120  UCHAR Uchar[2];
2122 } UCHAR2, *PUCHAR2;
2123 
2124 typedef union _UCHAR4 {
2125  UCHAR Uchar[4];
2127 } UCHAR4, *PUCHAR4;
2128 
2129 //
2130 // This macro copies an unaligned src byte to an aligned dst byte
2131 //
2132 
2133 #define CopyUchar1(Dst,Src) { \
2134  *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
2135  }
2136 
2137 //
2138 // This macro copies an unaligned src word to an aligned dst word
2139 //
2140 
2141 #define CopyUchar2(Dst,Src) { \
2142  *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
2143  }
2144 
2145 //
2146 // This macro copies an unaligned src longword to an aligned dsr longword
2147 //
2148 
2149 #define CopyUchar4(Dst,Src) { \
2150  *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
2151  }
2152 
2153 #define CopyU4char(Dst,Src) { \
2154  *((UNALIGNED UCHAR4 *)(Dst)) = *((UCHAR4 *)(Src)); \
2155  }
2156 
2157 //
2158 // VOID
2159 // FatNotifyReportChange (
2160 // IN PIRP_CONTEXT IrpContext,
2161 // IN PVCB Vcb,
2162 // IN PFCB Fcb,
2163 // IN ULONG Filter,
2164 // IN ULONG Action
2165 // );
2166 //
2167 
2168 #define FatNotifyReportChange(I,V,F,FL,A) { \
2169  if ((F)->FullFileName.Buffer == NULL) { \
2170  FatSetFullFileNameInFcb((I),(F)); \
2171  } \
2172  NT_ASSERT( (F)->FullFileName.Length != 0 ); \
2173  NT_ASSERT( (F)->FinalNameLength != 0 ); \
2174  NT_ASSERT( (F)->FullFileName.Length > (F)->FinalNameLength ); \
2175  NT_ASSERT( (F)->FullFileName.Buffer[((F)->FullFileName.Length - (F)->FinalNameLength)/sizeof(WCHAR) - 1] == L'\\' ); \
2176  FsRtlNotifyFullReportChange( (V)->NotifySync, \
2177  &(V)->DirNotifyList, \
2178  (PSTRING)&(F)->FullFileName, \
2179  (USHORT) ((F)->FullFileName.Length - \
2180  (F)->FinalNameLength), \
2181  (PSTRING)NULL, \
2182  (PSTRING)NULL, \
2183  (ULONG)FL, \
2184  (ULONG)A, \
2185  (PVOID)NULL ); \
2186 }
2187 
2188 
2189 //
2190 // The FSD Level dispatch routines. These routines are called by the
2191 // I/O system via the dispatch table in the Driver Object.
2192 //
2193 // They each accept as input a pointer to a device object (actually most
2194 // expect a volume device object, with the exception of the file system
2195 // control function which can also take a file system device object), and
2196 // a pointer to the IRP. They either perform the function at the FSD level
2197 // or post the request to the FSP work queue for FSP level processing.
2198 //
2199 
2202 NTSTATUS
2203 NTAPI
2204 FatFsdCleanup ( // implemented in Cleanup.c
2205  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2206  _Inout_ PIRP Irp
2207  );
2208 
2211 NTSTATUS
2212 NTAPI
2213 FatFsdClose ( // implemented in Close.c
2214  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2215  _Inout_ PIRP Irp
2216  );
2217 
2220 NTSTATUS
2221 NTAPI
2222 FatFsdCreate ( // implemented in Create.c
2223  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2224  _Inout_ PIRP Irp
2225  );
2226 
2227 
2230 NTSTATUS
2231 NTAPI
2232 FatFsdDeviceControl ( // implemented in DevCtrl.c
2233  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2234  _Inout_ PIRP Irp
2235  );
2236 
2239 NTSTATUS
2240 NTAPI
2241 FatFsdDirectoryControl ( // implemented in DirCtrl.c
2242  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2243  _Inout_ PIRP Irp
2244  );
2245 
2248 NTSTATUS
2249 NTAPI
2250 FatFsdQueryEa ( // implemented in Ea.c
2251  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2252  _Inout_ PIRP Irp
2253  );
2254 
2257 NTSTATUS
2258 NTAPI
2259 FatFsdSetEa ( // implemented in Ea.c
2260  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2261  _Inout_ PIRP Irp
2262  );
2263 
2266 NTSTATUS
2267 NTAPI
2268 FatFsdQueryInformation ( // implemented in FileInfo.c
2269  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2270  _Inout_ PIRP Irp
2271  );
2272 
2275 NTSTATUS
2276 NTAPI
2277 FatFsdSetInformation ( // implemented in FileInfo.c
2278  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2279  _Inout_ PIRP Irp
2280  );
2281 
2284 NTSTATUS
2285 NTAPI
2286 FatFsdFlushBuffers ( // implemented in Flush.c
2287  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2288  _Inout_ PIRP Irp
2289  );
2290 
2293 NTSTATUS
2294 NTAPI
2295 FatFsdFileSystemControl ( // implemented in FsCtrl.c
2296  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2297  _Inout_ PIRP Irp
2298  );
2299 
2302 NTSTATUS
2303 NTAPI
2304 FatFsdLockControl ( // implemented in LockCtrl.c
2305  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2306  _Inout_ PIRP Irp
2307  );
2308 
2311 NTSTATUS
2312 NTAPI
2313 FatFsdPnp ( // implemented in Pnp.c
2314  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2315  _Inout_ PIRP Irp
2316  );
2317 
2320 NTSTATUS
2321 NTAPI
2322 FatFsdRead ( // implemented in Read.c
2323  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2324  _Inout_ PIRP Irp
2325  );
2326 
2329 NTSTATUS
2330 NTAPI
2331 FatFsdShutdown ( // implemented in Shutdown.c
2332  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2333  _Inout_ PIRP Irp
2334  );
2335 
2338 NTSTATUS
2339 NTAPI
2340 FatFsdQueryVolumeInformation ( // implemented in VolInfo.c
2341  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2342  _Inout_ PIRP Irp
2343  );
2344 
2347 NTSTATUS
2348 NTAPI
2349 FatFsdSetVolumeInformation ( // implemented in VolInfo.c
2350  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2351  _Inout_ PIRP Irp
2352  );
2353 
2356 NTSTATUS
2357 NTAPI
2358 FatFsdWrite ( // implemented in Write.c
2359  _In_ PVOLUME_DEVICE_OBJECT VolumeDeviceObject,
2360  _Inout_ PIRP Irp
2361  );
2362 
2363 //
2364 // The following macro is used to determine if an FSD thread can block
2365 // for I/O or wait for a resource. It returns TRUE if the thread can
2366 // block and FALSE otherwise. This attribute can then be used to call
2367 // the FSD & FSP common work routine with the proper wait value.
2368 //
2369 
2370 #define CanFsdWait(IRP) IoIsOperationSynchronous(Irp)
2371 
2372 
2373 //
2374 // The FSP level dispatch/main routine. This is the routine that takes
2375 // IRP's off of the work queue and calls the appropriate FSP level
2376 // work routine.
2377 //
2378 
2379 
2380 WORKER_THREAD_ROUTINE FatFspDispatch;
2381 
2382 VOID
2383 NTAPI
2384 FatFspDispatch ( // implemented in FspDisp.c
2386  );
2387 
2388 //
2389 // The following routines are the FSP work routines that are called
2390 // by the preceding FatFspDispath routine. Each takes as input a pointer
2391 // to the IRP, perform the function, and return a pointer to the volume
2392 // device object that they just finished servicing (if any). The return
2393 // pointer is then used by the main Fsp dispatch routine to check for
2394 // additional IRPs in the volume's overflow queue.
2395 //
2396 // Each of the following routines is also responsible for completing the IRP.
2397 // We moved this responsibility from the main loop to the individual routines
2398 // to allow them the ability to complete the IRP and continue post processing
2399 // actions.
2400 //
2401 
2402 _Requires_lock_held_(_Global_critical_region_)
2403 NTSTATUS
2404 FatCommonCleanup ( // implemented in Cleanup.c
2405  IN PIRP_CONTEXT IrpContext,
2406  IN PIRP Irp
2407  );
2408 
2409 _Requires_lock_held_(_Global_critical_region_)
2410 NTSTATUS
2411 FatCommonClose ( // implemented in Close.c
2412  IN PVCB Vcb,
2414  IN PCCB Ccb,
2416  IN BOOLEAN Wait,
2418  OUT PBOOLEAN VcbDeleted OPTIONAL
2419  );
2420 
2421 _Requires_lock_held_(_Global_critical_region_)
2422 VOID
2423 FatFspClose ( // implemented in Close.c
2425  );
2426 
2427 _Requires_lock_held_(_Global_critical_region_)
2428 NTSTATUS
2429 FatCommonCreate ( // implemented in Create.c
2430  _Inout_ PIRP_CONTEXT IrpContext,
2431  _Inout_ PIRP Irp
2432  );
2433 
2434 #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
2435 
2436 _Requires_lock_held_(_Global_critical_region_)
2437 NTSTATUS
2438 FatCommonCreateOnNewStack ( // implemented in Create.c
2439  _Inout_ PIRP_CONTEXT IrpContext,
2440  _Inout_ PIRP Irp
2441  );
2442 
2443 _Requires_lock_held_(_Global_critical_region_)
2444 VOID
2445 FatCommonCreateCallout ( // implemented in Create.c
2446  _In_ PFAT_CALLOUT_PARAMETERS CalloutParameters
2447  );
2448 
2449 #endif
2450 
2451 _Requires_lock_held_(_Global_critical_region_)
2452 NTSTATUS
2453 FatCommonDirectoryControl ( // implemented in DirCtrl.c
2454  IN PIRP_CONTEXT IrpContext,
2455  IN PIRP Irp
2456  );
2457 
2458 _Requires_lock_held_(_Global_critical_region_)
2459 NTSTATUS
2460 FatCommonDeviceControl ( // implemented in DevCtrl.c
2461  IN PIRP_CONTEXT IrpContext,
2462  IN PIRP Irp
2463  );
2464 
2465 NTSTATUS
2466 FatCommonQueryEa ( // implemented in Ea.c
2467  IN PIRP_CONTEXT IrpContext,
2468  IN PIRP Irp
2469  );
2470 
2471 NTSTATUS
2472 FatCommonSetEa ( // implemented in Ea.c
2473  IN PIRP_CONTEXT IrpContext,
2474  IN PIRP Irp
2475  );
2476 
2477 _Requires_lock_held_(_Global_critical_region_)
2478 NTSTATUS
2479 FatCommonQueryInformation ( // implemented in FileInfo.c
2480  IN PIRP_CONTEXT IrpContext,
2481  IN PIRP Irp
2482  );
2483 
2484 _Requires_lock_held_(_Global_critical_region_)
2485 NTSTATUS
2486 FatCommonSetInformation ( // implemented in FileInfo.c
2487  IN PIRP_CONTEXT IrpContext,
2488  IN PIRP Irp
2489  );
2490 
2491 _Requires_lock_held_(_Global_critical_region_)
2492 NTSTATUS
2493 FatCommonFlushBuffers ( // implemented in Flush.c
2494  IN PIRP_CONTEXT IrpContext,
2495  IN PIRP Irp
2496  );
2497 
2498 _Requires_lock_held_(_Global_critical_region_)
2499 NTSTATUS
2500 FatCommonFileSystemControl ( // implemented in FsCtrl.c
2501  IN PIRP_CONTEXT IrpContext,
2502  IN PIRP Irp
2503  );
2504 
2505 _Requires_lock_held_(_Global_critical_region_)
2506 NTSTATUS
2507 FatCommonLockControl ( // implemented in LockCtrl.c
2508  IN PIRP_CONTEXT IrpContext,
2509  IN PIRP Irp
2510  );
2511 
2512 _Requires_lock_held_(_Global_critical_region_)
2513 NTSTATUS
2514 FatCommonPnp ( // implemented in Pnp.c
2515  IN PIRP_CONTEXT IrpContext,
2516  IN PIRP Irp
2517  );
2518 
2519 _Requires_lock_held_(_Global_critical_region_)
2520 NTSTATUS
2521 FatCommonRead ( // implemented in Read.c
2522  IN PIRP_CONTEXT IrpContext,
2523  IN PIRP Irp
2524  );
2525 
2526 _Requires_lock_held_(_Global_critical_region_)
2527 NTSTATUS
2528 FatCommonShutdown ( // implemented in Shutdown.c
2529  IN PIRP_CONTEXT IrpContext,
2530  IN PIRP Irp
2531  );
2532 
2533 _Requires_lock_held_(_Global_critical_region_)
2534 NTSTATUS
2535 FatCommonQueryVolumeInfo ( // implemented in VolInfo.c
2536  IN PIRP_CONTEXT IrpContext,
2537  IN PIRP Irp
2538  );
2539 
2540 _Requires_lock_held_(_Global_critical_region_)
2541 NTSTATUS
2542 FatCommonSetVolumeInfo ( // implemented in VolInfo.c
2543  IN PIRP_CONTEXT IrpContext,
2544  IN PIRP Irp
2545  );
2546 
2547 _Requires_lock_held_(_Global_critical_region_)
2548 NTSTATUS
2549 FatCommonWrite ( // implemented in Write.c
2550  IN PIRP_CONTEXT IrpContext,
2551  IN PIRP Irp
2552  );
2553 
2554 //
2555 // The following is implemented in Flush.c, and does what is says.
2556 //
2557 
2558 _Requires_lock_held_(_Global_critical_region_)
2559 NTSTATUS
2560 FatFlushFile (
2561  IN PIRP_CONTEXT IrpContext,
2562  IN PFCB Fcb,
2564  );
2565 
2566 _Requires_lock_held_(_Global_critical_region_)
2567 NTSTATUS
2568 FatFlushDirectory (
2569  IN PIRP_CONTEXT IrpContext,
2570  IN PDCB Dcb,
2572  );
2573 
2574 NTSTATUS
2575 FatFlushFat (
2576  IN PIRP_CONTEXT IrpContext,
2577  IN PVCB Vcb
2578  );
2579 
2580 _Requires_lock_held_(_Global_critical_region_)
2581 NTSTATUS
2582 FatFlushVolume (
2583  IN PIRP_CONTEXT IrpContext,
2584  IN PVCB Vcb,
2586  );
2587 
2588 NTSTATUS
2590  IN PIRP_CONTEXT IrpContext,
2591  IN PIRP Irp,
2593  );
2594 
2595 VOID
2597  IN PIRP_CONTEXT IrpContext,
2598  IN PVCB Vcb,
2599  IN ULONG Cluster,
2600  IN ULONG Count
2601 );
2602 
2603 VOID
2605  IN PIRP_CONTEXT IrpContext,
2606  IN PFCB Fcb
2607 );
2608 
2609 
2610 
2611 //
2612 // The following procedure is used by the FSP and FSD routines to complete
2613 // an IRP.
2614 //
2615 // Note that this macro allows either the Irp or the IrpContext to be
2616 // null, however the only legal order to do this in is:
2617 //
2618 // FatCompleteRequest( NULL, Irp, Status ); // completes Irp & preserves context
2619 // ...
2620 // FatCompleteRequest( IrpContext, NULL, DontCare ); // deallocates context
2621 //
2622 // This would typically be done in order to pass a "naked" IrpContext off to
2623 // the Fsp for post processing, such as read ahead.
2624 //
2625 
2626 VOID
2628  IN PIRP_CONTEXT IrpContext,
2629  IN PIRP Irp,
2631  );
2632 
2633 #define FatCompleteRequest(IRPCONTEXT,IRP,STATUS) { \
2634  FatCompleteRequest_Real(IRPCONTEXT,IRP,STATUS); \
2635 }
2636 
2637 BOOLEAN
2639  IN PIRP Irp
2640  );
2641 
2642 //
2643 // The Following routine makes a popup
2644 //
2645 
2646 _Requires_lock_held_(_Global_critical_region_)
2647 VOID
2648 FatPopUpFileCorrupt (
2649  IN PIRP_CONTEXT IrpContext,
2650  IN PFCB Fcb
2651  );
2652 
2653 //
2654 // Here are the callbacks used by the I/O system for checking for fast I/O or
2655 // doing a fast query info call, or doing fast lock calls.
2656 //
2657 _Function_class_(FAST_IO_CHECK_IF_POSSIBLE)
2658 BOOLEAN
2659 NTAPI
2660 FatFastIoCheckIfPossible (
2663  IN ULONG Length,
2664  IN BOOLEAN Wait,
2665  IN ULONG LockKey,
2669  );
2670 
2671 _Function_class_(FAST_IO_QUERY_BASIC_INFO)
2672 BOOLEAN
2673 NTAPI
2674 FatFastQueryBasicInfo (
2676  IN BOOLEAN Wait,
2680  );
2681 
2682 _Function_class_(FAST_IO_QUERY_STANDARD_INFO)
2683 BOOLEAN
2684 NTAPI
2685 FatFastQueryStdInfo (
2687  IN BOOLEAN Wait,
2691  );
2692 
2693 _Function_class_(FAST_IO_QUERY_NETWORK_OPEN_INFO)
2694 BOOLEAN
2695 NTAPI
2696 FatFastQueryNetworkOpenInfo (
2698  IN BOOLEAN Wait,
2702  );
2703 
2704 _Function_class_(FAST_IO_LOCK)
2705 BOOLEAN
2706 NTAPI
2707 FatFastLock (
2712  ULONG Key,
2717  );
2718 
2719 _Function_class_(FAST_IO_UNLOCK_SINGLE)
2720 BOOLEAN
2721 NTAPI
2722 FatFastUnlockSingle (
2727  ULONG Key,
2730  );
2731 
2732 _Function_class_(FAST_IO_UNLOCK_ALL)
2733 BOOLEAN
2734 NTAPI
2735 FatFastUnlockAll (
2740  );
2741 
2742 _Function_class_(FAST_IO_UNLOCK_ALL_BY_KEY)
2743 BOOLEAN
2744 NTAPI
2745 FatFastUnlockAllByKey (
2747  PVOID ProcessId,
2748  ULONG Key,
2751  );
2752 
2753 
2754 VOID
2756  IN PIRP_CONTEXT IrpContext,
2757  IN PVCB Vcb,
2758  IN ULONG StartIndex OPTIONAL,
2759  IN ULONG EndIndex OPTIONAL,
2760  IN BOOLEAN SetupWindows,
2761  IN PFAT_WINDOW SwitchToWindow OPTIONAL,
2762  IN PULONG BitMapBuffer OPTIONAL
2763  );
2764 
2765 BOOLEAN
2767  IN PIRP_CONTEXT IrpContext,
2769  );
2770 
2771 //
2772 // The following macro is used to determine is a file has been deleted.
2773 //
2774 // BOOLEAN
2775 // IsFileDeleted (
2776 // IN PIRP_CONTEXT IrpContext,
2777 // IN PFCB Fcb
2778 // );
2779 //
2780 
2781 #define IsFileDeleted(IRPCONTEXT,FCB) \
2782  (FlagOn((FCB)->FcbState, FCB_STATE_DELETE_ON_CLOSE) && \
2783  ((FCB)->UncleanCount == 0))
2784 
2785 //
2786 // The following macro is used by the dispatch routines to determine if
2787 // an operation is to be done with or without Write Through.
2788 //
2789 // BOOLEAN
2790 // IsFileWriteThrough (
2791 // IN PFILE_OBJECT FileObject,
2792 // IN PVCB Vcb
2793 // );
2794 //
2795 
2796 #define IsFileWriteThrough(FO,VCB) ( \
2797  BooleanFlagOn((FO)->Flags, FO_WRITE_THROUGH) \
2798 )
2799 
2800 //
2801 // The following macro is used to set the is fast i/o possible field in
2802 // the common part of the nonpaged fcb. It checks that this is actually
2803 // an FCB (as opposed to a DCB) so that directory oplock code works properly.
2804 //
2805 //
2806 // BOOLEAN
2807 // FatIsFastIoPossible (
2808 // IN PFCB Fcb
2809 // );
2810 //
2811 
2812 
2813 #define FatIsFastIoPossible(FCB) ((BOOLEAN) \
2814  ((((FCB)->FcbCondition != FcbGood) || \
2815  (NodeType( (FCB) ) != FAT_NTC_FCB) || \
2816  !FsRtlOplockIsFastIoPossible( FatGetFcbOplock(FCB) )) ? \
2817  FastIoIsNotPossible \
2818  : \
2819  (!FsRtlAreThereCurrentFileLocks( &(FCB)->Specific.Fcb.FileLock ) && \
2820  ((FCB)->NonPaged->OutstandingAsyncWrites == 0) && \
2821  !FlagOn( (FCB)->Vcb->VcbState, VCB_STATE_FLAG_WRITE_PROTECTED ) ? \
2822  FastIoIsPossible \
2823  : \
2824  FastIoIsQuestionable \
2825  ) \
2826  ) \
2827 )
2828 
2829 
2830 #if (NTDDI_VERSION >= NTDDI_WIN8)
2831 
2832 //
2833 // Detect whether this file can have an oplock on it. As of Windows 8 file and
2834 // directories can have oplocks.
2835 //
2836 
2837 #define FatIsNodeTypeOplockable(N) ( \
2838  ((N) == FAT_NTC_FCB) || \
2839  ((N) == FAT_NTC_ROOT_DCB) || \
2840  ((N) == FAT_NTC_DCB) \
2841 )
2842 
2843 #else
2844 
2845 #define FatIsNodeTypeOplockable(N) ( \
2846  ((N) == FAT_NTC_FCB) \
2847 )
2848 
2849 #endif
2850 
2851 #define FatIsFileOplockable(F) ( \
2852  FatIsNodeTypeOplockable( NodeType( (F) )) \
2853 )
2854 
2855 //
2856 // The following macro is used to detemine if the file object is opened
2857 // for read only access (i.e., it is not also opened for write access or
2858 // delete access).
2859 //
2860 // BOOLEAN
2861 // IsFileObjectReadOnly (
2862 // IN PFILE_OBJECT FileObject
2863 // );
2864 //
2865 
2866 #define IsFileObjectReadOnly(FO) (!((FO)->WriteAccess | (FO)->DeleteAccess))
2867 
2868 
2869 //
2870 // The following two macro are used by the Fsd/Fsp exception handlers to
2871 // process an exception. The first macro is the exception filter used in the
2872 // Fsd/Fsp to decide if an exception should be handled at this level.
2873 // The second macro decides if the exception is to be finished off by
2874 // completing the IRP, and cleaning up the Irp Context, or if we should
2875 // bugcheck. Exception values such as STATUS_FILE_INVALID (raised by
2876 // VerfySup.c) cause us to complete the Irp and cleanup, while exceptions
2877 // such as accvio cause us to bugcheck.
2878 //
2879 // The basic structure for fsd/fsp exception handling is as follows:
2880 //
2881 // FatFsdXxx(...)
2882 // {
2883 // try {
2884 //
2885 // ...
2886 //
2887 // } except(FatExceptionFilter( IrpContext, GetExceptionCode() )) {
2888 //
2889 // Status = FatProcessException( IrpContext, Irp, GetExceptionCode() );
2890 // }
2891 //
2892 // Return Status;
2893 // }
2894 //
2895 // To explicitly raise an exception that we expect, such as
2896 // STATUS_FILE_INVALID, use the below macro FatRaiseStatus(). To raise a
2897 // status from an unknown origin (such as CcFlushCache()), use the macro
2898 // FatNormalizeAndRaiseStatus. This will raise the status if it is expected,
2899 // or raise STATUS_UNEXPECTED_IO_ERROR if it is not.
2900 //
2901 // If we are vicariously handling exceptions without using FatProcessException(),
2902 // if there is the possibility that we raised that exception, one *must*
2903 // reset the IrpContext so a subsequent raise in the course of handling this
2904 // request that is *not* explicit, i.e. like a pagein error, does not get
2905 // spoofed into believing that the first raise status is the reason the second
2906 // occured. This could have really serious consequences.
2907 //
2908 // It is an excellent idea to always FatResetExceptionState in these cases.
2909 //
2910 // Note that when using these two macros, the original status is placed in
2911 // IrpContext->ExceptionStatus, signaling FatExceptionFilter and
2912 // FatProcessException that the status we actually raise is by definition
2913 // expected.
2914 //
2915 
2916 ULONG
2918  IN PIRP_CONTEXT IrpContext,
2919  IN PEXCEPTION_POINTERS ExceptionPointer
2920  );
2921 
2922 #if DBG
2923 ULONG
2924 FatBugCheckExceptionFilter (
2925  IN PEXCEPTION_POINTERS ExceptionPointer
2926  );
2927 #endif
2928 
2929 _Requires_lock_held_(_Global_critical_region_)
2930 NTSTATUS
2931 FatProcessException (
2932  IN PIRP_CONTEXT IrpContext,
2935  );
2936 
2937 //
2938 // VOID
2939 // FatRaiseStatus (
2940 // IN PRIP_CONTEXT IrpContext,
2941 // IN NT_STATUS Status
2942 // );
2943 //
2944 //
2945 
2946 #if DBG
2947 #ifdef _MSC_VER
2948 #define DebugBreakOnStatus(S) { \
2949 __pragma(warning(push)) \
2950 __pragma(warning(disable:4127)) \
2951  if (FatTestRaisedStatus) { \
2952  if ((S) == STATUS_DISK_CORRUPT_ERROR || (S) == STATUS_FILE_CORRUPT_ERROR) { \
2953 __pragma(warning(pop)) \
2954  DbgPrint( "FAT: Breaking on interesting raised status (0x%08x)\n", (S) );\
2955  DbgPrint( "FAT: Set FatTestRaisedStatus @ 0x%p to 0 to disable\n", \
2956  &FatTestRaisedStatus ); \
2957  NT_ASSERT(FALSE); \
2958  } \
2959  } \
2960 }
2961 #else
2962 #define DebugBreakOnStatus(S) { \
2963  if (FatTestRaisedStatus) { \
2964  if ((S) == STATUS_DISK_CORRUPT_ERROR || (S) == STATUS_FILE_CORRUPT_ERROR) { \
2965  DbgPrint( "FAT: Breaking on interesting raised status (0x%08x)\n", (S) );\
2966  DbgPrint( "FAT: Set FatTestRaisedStatus @ 0x%p to 0 to disable\n", \
2967  &FatTestRaisedStatus ); \
2968  NT_ASSERT(FALSE); \
2969  } \
2970  } \
2971 }
2972 #endif
2973 #else
2974 #define DebugBreakOnStatus(S)
2975 #endif
2976 
2977 #define FatRaiseStatus(IRPCONTEXT,STATUS) { \
2978  (IRPCONTEXT)->ExceptionStatus = (STATUS); \
2979  DebugBreakOnStatus( (STATUS) ) \
2980  ExRaiseStatus( (STATUS) ); \
2981 }
2982 
2983 #define FatResetExceptionState( IRPCONTEXT ) { \
2984  (IRPCONTEXT)->ExceptionStatus = STATUS_SUCCESS; \
2985 }
2986 
2987 //
2988 // VOID
2989 // FatNormalAndRaiseStatus (
2990 // IN PRIP_CONTEXT IrpContext,
2991 // IN NT_STATUS Status
2992 // );
2993 //
2994 
2995 #define FatNormalizeAndRaiseStatus(IRPCONTEXT,STATUS) { \
2996  (IRPCONTEXT)->ExceptionStatus = (STATUS); \
2997  ExRaiseStatus(FsRtlNormalizeNtstatus((STATUS),STATUS_UNEXPECTED_IO_ERROR)); \
2998 }
2999 
3000 
3001 //
3002 // The following macros are used to establish the semantics needed
3003 // to do a return from within a try-finally clause. As a rule every
3004 // try clause must end with a label call try_exit. For example,
3005 //
3006 // try {
3007 // :
3008 // :
3009 //
3010 // try_exit: NOTHING;
3011 // } finally {
3012 //
3013 // :
3014 // :
3015 // }
3016 //
3017 // Every return statement executed inside of a try clause should use the
3018 // try_return macro. If the compiler fully supports the try-finally construct
3019 // then the macro should be
3020 //
3021 // #define try_return(S) { return(S); }
3022 //
3023 // If the compiler does not support the try-finally construct then the macro
3024 // should be
3025 //
3026 // #define try_return(S) { S; goto try_exit; }
3027 //
3028 
3029 #define try_return(S) { S; goto try_exit; }
3030 #define try_leave(S) { S; _SEH2_LEAVE; }
3031 
3032 
3035  IN PVCB Vcb,
3037  );
3038 
3039 
3040 //
3041 // These routines define the FileId for FAT. Lacking a fixed/uniquifiable
3042 // notion, we simply come up with one which is unique in a given snapshot
3043 // of the volume. As long as the parent directory is not moved or compacted,
3044 // it may even be permanent.
3045 //
3046 
3047 //
3048 // The internal information used to identify the fcb/dcb on the
3049 // volume is the byte offset of the dirent of the file on disc.
3050 // Our root always has fileid 0. FAT32 roots are chains and can
3051 // use the LBO of the cluster, 12/16 roots use the lbo in the Vcb.
3052 //
3053 
3054 #define FatGenerateFileIdFromDirentOffset(ParentDcb,DirentOffset) \
3055  ((ParentDcb) ? ((NodeType(ParentDcb) != FAT_NTC_ROOT_DCB || FatIsFat32((ParentDcb)->Vcb)) ? \
3056  FatGetLboFromIndex( (ParentDcb)->Vcb, \
3057  (ParentDcb)->FirstClusterOfFile ) : \
3058  (ParentDcb)->Vcb->AllocationSupport.RootDirectoryLbo) + \
3059  (DirentOffset) \
3060  : \
3061  0)
3062 
3063 //
3064 //
3065 
3066 #define FatGenerateFileIdFromFcb(Fcb) \
3067  FatGenerateFileIdFromDirentOffset( (Fcb)->ParentDcb, (Fcb)->DirentOffsetWithinDirectory )
3068 
3069 //
3070 // Wrap to handle the ./.. cases appropriately. Note that we commute NULL parent to 0. This would
3071 // only occur in an illegal root ".." entry.
3072 //
3073 
3074 #define FATDOT ((ULONG)0x2020202E)
3075 #define FATDOTDOT ((ULONG)0x20202E2E)
3076 
3077 #define FatGenerateFileIdFromDirentAndOffset(Dcb,Dirent,DirentOffset) \
3078  ((*((PULONG)(Dirent)->FileName)) == FATDOT ? FatGenerateFileIdFromFcb(Dcb) : \
3079  ((*((PULONG)(Dirent)->FileName)) == FATDOTDOT ? ((Dcb)->ParentDcb ? \
3080  FatGenerateFileIdFromFcb((Dcb)->ParentDcb) : \
3081  0) : \
3082  FatGenerateFileIdFromDirentOffset(Dcb,DirentOffset)))
3083 
3084 
3085 //
3086 // BOOLEAN
3087 // FatDeviceIsFatFsdo(
3088 // IN PDEVICE_OBJECT D
3089 // );
3090 //
3091 // Evaluates to TRUE if the supplied device object is one of the file system devices
3092 // we created at initialisation.
3093 //
3094 
3095 #define FatDeviceIsFatFsdo( D) (((D) == FatData.DiskFileSystemDeviceObject) || ((D) == FatData.CdromFileSystemDeviceObject))
3096 
3097 
3098 //
3099 // BlockAlign(): Aligns P on the next V boundary.
3100 // BlockAlignTruncate(): Aligns P on the prev V boundary.
3101 //
3102 
3103 #define BlockAlign(P,V) ((ASSERT( V != 0)), (((P)) + (V-1) & (0-(V))))
3104 #define BlockAlignTruncate(P,V) ((P) & (0-(V)))
3105 
3106 #define IsDirectory(FcbOrDcb) ((NodeType((FcbOrDcb)) == FAT_NTC_DCB) || (NodeType((FcbOrDcb)) == FAT_NTC_ROOT_DCB))
3107 
3108 #endif // _FATPROCS_
3109 
3110 
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
ULONG ForceAlignment
Definition: cdprocs.h:1673
* PNTSTATUS
Definition: strlen.c:14
VOID FatConstructNamesInFcb(IN PIRP_CONTEXT IrpContext, PFCB Fcb, PDIRENT Dirent, PUNICODE_STRING Lfn OPTIONAL)
Definition: strucsup.c:3022
IN PVCB IN ULONG AbsoluteClusterHint
Definition: fatprocs.h:343
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
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:2709
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
IN PVCB IN FAT_VOLUME_STATE VolumeState
Definition: fatprocs.h:1996
VOID FatPreallocateCloseContext(IN PVCB Vcb)
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
FAT_TIME_STAMP FatGetCurrentFatTime(_In_ PIRP_CONTEXT IrpContext)
Definition: timesup.c:317
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG FatLocateNextEa(IN PIRP_CONTEXT IrpContext, IN PPACKED_EA FirstPackedEa, IN ULONG PackedEasLength, IN ULONG PreviousOffset)
Definition: easup.c:3257
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:107
union _UCHAR2 UCHAR2
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:411
PCLOSE_CONTEXT FatAllocateCloseContext(IN PVCB Vcb)
#define INLINE
Definition: fatprocs.h:77
_Requires_lock_held_(_Global_critical_region_) VOID FatLookupFileAllocation(IN PIRP_CONTEXT IrpContext
VOID FatTearDownVcb(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: strucsup.c:684
#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
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE _In_opt_ __drv_aliasesMem WDFCONTEXT CompletionContext
Definition: wdfrequest.h:893
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 PIRP IN NTSTATUS ExceptionCode
Definition: fatprocs.h:2933
#define IRP_MJ_SHUTDOWN
ERESOURCE Resource
Definition: fatstruc.h:403
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
Definition: cdstruc.h:902
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:280
NTSTATUS FatToggleMediaEjectDisable(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN BOOLEAN PreventRemoval)
Definition: deviosup.c:3495
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
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:1067
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:715
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:1668
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:262
IN PFCB IN PCCB IN TYPE_OF_OPEN TypeOfOpen
Definition: fatprocs.h:2413
#define IRP_MJ_SET_VOLUME_INFORMATION
PFILE_OBJECT FatOpenEaFile(IN PIRP_CONTEXT IrpContext, IN PFCB EaFcb)
Definition: cachesup.c:979
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
Definition: cdstruc.h:498
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
enum _TYPE_OF_OPEN TYPE_OF_OPEN
IN PDCB IN ULONG IN BOOLEAN RescanDir
Definition: fatprocs.h:698
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:318
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:2662
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:934
#define _In_opt_
Definition: no_sal2.h:212
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:2413
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_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:318
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
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
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
BOOLEAN FatScanForDataTrack(IN PIRP_CONTEXT IrpContext, IN PDEVICE_OBJECT TargetDeviceObject)
Definition: strucsup.c:3828
IN PFCB FcbOrDcb
Definition: fatprocs.h:306
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
VOID FatDeleteCcb(IN PIRP_CONTEXT IrpContext, IN PCCB *Ccb)
Definition: strucsup.c:2254
#define __out_opt
Definition: dbghelp.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
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:843
#define FALSE
Definition: types.h:117
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
_In_ PIRP Irp
Definition: csq.h:116
Definition: Header.h:8
VOID FatTearDownAllocationSupport(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
Definition: allocsup.c:549
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:2709
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:3739
CLUSTER_TYPE FatInterpretClusterType(IN PVCB Vcb, IN FAT_ENTRY Entry)
Definition: allocsup.c:3473
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_
Definition: no_sal2.h:160
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
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:1623
#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:2301
IN PFCB IN FAT_FLUSH_TYPE FlushType
Definition: fatprocs.h:1080
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
BOOLEAN FatIsIrpTopLevel(IN PIRP Irp)
Definition: fatdata.c:817
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:859
PMDL FatBuildZeroMdl(__in PIRP_CONTEXT IrpContext, __in ULONG Length)
Definition: deviosup.c:3734
VOID FatWaitSync(IN PIRP_CONTEXT IrpContext)
Definition: deviosup.c:2367
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
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:571
_Acquires_shared_lock_ Fcb FINISHED FatAcquireSharedFcbWaitForEx(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb)
Status
Definition: gdiplustypes.h:24
#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:2662
#define _Out_opt_
Definition: no_sal2.h:214
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:949
int Count
Definition: noreturn.cpp:7
VOID FatUnpinEaRange(IN PIRP_CONTEXT IrpContext, IN OUT PEA_RANGE EaRange)
Definition: easup.c:3782
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
VOID FatDeleteFcb(IN PIRP_CONTEXT IrpContext, IN PFCB *Fcb)
Definition: strucsup.c:1952
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:3614
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
_In_ WDFCOLLECTION _In_ ULONG Index
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:1252
#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
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:772
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:1663
#define _Inout_
Definition: no_sal2.h:162
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
* PFILE_OBJECT
Definition: iotypes.h:1998
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:2525
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:4655
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:2155
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
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
enum _TYPE_OF_OPEN TYPE_OF_OPEN
IN PVCB IN ULONG FatIndex
Definition: fatprocs.h:382
BOOLEAN FatAcquireVolumeForClose(IN PVOID Vcb, IN BOOLEAN Wait)
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
ULONG SectorCount
Definition: part_xbox.c:31
DRIVER_DISPATCH(nfs41_FsdDispatch)
IN PVCB IN VBO StartingVbo
Definition: fatprocs.h:411
IN PVCB IN PLARGE_MCB IN BOOLEAN ZeroOnDeallocate
Definition: fatprocs.h:354
VOID FatDeleteIrpContext_Real(IN PIRP_CONTEXT IrpContext)
Definition: strucsup.c:2461
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define _In_
Definition: no_sal2.h:158
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:319
union _UCHAR1 * PUCHAR1
BOOLEAN FatIsNameInExpression(IN PIRP_CONTEXT IrpContext, IN OEM_STRING Expression, IN OEM_STRING Name)
Definition: namesup.c:35
union _UCHAR2 * PUCHAR2
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
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
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:359
enum _FAT_VOLUME_STATE FAT_VOLUME_STATE
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:343
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:4720
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:2380
unsigned int * PULONG
Definition: retypes.h:1
IN PDCB ParentDirectory
Definition: fatprocs.h:698
VOID FatFreeStringBuffer(_Inout_ PVOID String)
Definition: strucsup.c:3784
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG BOOLEAN BOOLEAN ExclusiveLock
Definition: fatprocs.h:2709
#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
#define _When_(c, a)
Definition: no_sal2.h:38
Definition: iotypes.h:189
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:3565
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
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
#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:2662
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:2209
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
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
#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:2627
IN PDCB IN PCCB IN VBO OffsetToStartSearchFrom
Definition: fatprocs.h:725
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675