178{
180
182
184
189
191
193
196
199
200#if (NTDDI_VERSION >= NTDDI_WIN8)
202#endif
203
205
207
211
212
213
214
215
218
219
220
221
222
223
224
226
228
230
231 DebugTrace(-1,
Dbg,
"FatCommonCleanup -> STATUS_SUCCESS\n", 0);
233 }
234
235
236
237
238
239
241
246
247
248
249
250
252
254
256 }
257 }
258
260
261 DebugTrace(-1,
Dbg,
"FatCommonCleanup -> STATUS_SUCCESS\n", 0);
263 }
264
265
266
267
268
269
271
273
274 (
VOID)FatAcquireExclusiveFcb( IrpContext,
Fcb );
275
277
278
279
280
281
282
284
286
287
288
289
290
291
292
293
296
297#if (NTDDI_VERSION >= NTDDI_WIN8)
298 ProcessingDeleteOnClose =
TRUE;
299#endif
300
301
302
303
304
306
307#ifdef _MSC_VER
308#pragma prefast( suppress:6309, "FullDirectoryName may be NULL if NotifyIrp is also NULL. this indicates the object is being deleted." )
309#endif
316 0,
320 }
321 }
322
323
324
325
326
327
328
333
336
339
340 (
VOID)FatAcquireExclusiveFcb( IrpContext,
Fcb );
342 }
343 }
344
345
346
347
348
350
353 }
354
355
356
357
358
360
364 }
365
366
367
368
369
370
371
373
374
375
376
377
379
381
382 FatVerifyFcb( IrpContext,
Fcb );
383
386
389
391
393
394
395
396
397
400 }
402 }
403
405
406#if (NTDDI_VERSION >= NTDDI_WIN8)
407
408
409
410
411
412
413
414 if (ProcessingDeleteOnClose &&
417 FatIsDirectoryEmpty( IrpContext,
Fcb ))) {
418
421 OPLOCK_FLAG_CLOSING_DELETE_ON_CLOSE,
422 IrpContext,
425
427
429
432
433 } else {
434
436 }
437 }
438 }
439#endif
440
441
442
443
444
445
446
447
448
449
451
454
455 DebugTrace(0,
Dbg,
"Cleanup VirtualVolumeFile/DirectoryFile\n", 0);
456
458
459 break;
460
461
463
465
467
468 FatCheckForDismount( IrpContext,
Vcb,
TRUE );
469
470
471
472
473
474
475
478
481 Vcb->TargetDeviceObject );
482
484 }
485
486
487
488
489
490
493
495 SendUnlockNotification =
TRUE;
496 }
497
499
500 break;
501
503
505
507
508 break;
509
511
513
515
516
517
518
519
525
526
527
528
529
531 }
532
533
534
535
536
538
541 }
542
545
547
548
549
550
551
552
553
559
560 if (!FatIsDirectoryEmpty(IrpContext,
Fcb)) {
561
562
563
564
565
566
568
569 } else {
570
571#if (NTDDI_VERSION >= NTDDI_WIN8)
573#endif
574
575
576
577
578
580
582
583
584
585
586
587
588
591
592
593
594
595
598
600
602
603
604
605
606
608
609 FatTruncateFileAllocation( IrpContext,
Fcb, 0 );
610
611 if (
Fcb->
Header.AllocationSize.LowPart == 0) {
612
613
614
615
616
618
620
622
623
624
625
626
632 }
633
636
639
640
641
642
643
644
645
646
647
649
650#if (NTDDI_VERSION >= NTDDI_WIN8)
651
652
653
654
655
656
659 (OPLOCK_FLAG_PARENT_OBJECT |
660 OPLOCK_FLAG_REMOVING_FILE_OR_LINK),
664
666#endif
667 }
668 }
669 }
670
671
672
673
674
677
678 break;
679
681
683
685
686
687
688
689
690 if ((
FileObject->SectionObjectPointer->DataSectionObject ==
NULL) &&
697
698
699
700
701
703 }
704
705
706
707
708
710
713 }
714
715
716
717
718
723
724
725
726
727
728
729
730
731
734
736
737
739
740 }
741
742
743
744
745
746
748
750
751
752
753
754
755
756
759
760
761
762
763
764
767
769
770
771
772
773
776
780
782
784
785 FatSetFileSizeInDirent( IrpContext,
Fcb,
NULL );
786
789
792
794
795 } else {
796
797
798
799
800
803
804 ULONG ValidDataLength;
805
806 ValidDataLength =
Fcb->
Header.ValidDataLength.LowPart;
807
808 if (ValidDataLength < Fcb->ValidDataToDisk) {
810 }
811
812
813
814
815
816 if (ValidDataLength < Fcb->
Header.FileSize.LowPart) {
817
819
823 ValidDataLength,
825 ValidDataLength );
826
827
828
829
830
831
835
836
837
838
839
840
841
842
843
844
845
846
847
848
851 }
852
855
858 }
859 }
860 }
861
862
863
864
865
866
868
870
872
874
875
876 FatTruncateFileAllocation( IrpContext,
879
880
881 }
882
883
884
885
886
887
888
889 LocalTruncateSize =
Fcb->
Header.FileSize;
890 TruncateSize = &LocalTruncateSize;
891
892
893
894
895
896
898 }
899
900
901
902
903
904
906 Fcb->
Header.AllocationSize.LowPart == 0) {
907
909
910
911
912
913
915
917
918
919
920
921
927 }
928
931
934
936
937#if (NTDDI_VERSION >= NTDDI_WIN8)
939#endif
940
941
942
943
944
945
946
947
948
949
951
952#if (NTDDI_VERSION >= NTDDI_WIN8)
953
954
955
956
957
958
961 (OPLOCK_FLAG_PARENT_OBJECT |
962 OPLOCK_FLAG_REMOVING_FILE_OR_LINK),
966
968#endif
969 }
970 }
971 }
972
973
974
975
976
977
978
984 }
985
986
987
988
989
990
991
992
997
999
1000
1001
1002
1003
1004
1005
1008
1011 0,
1013 }
1014
1015
1016
1017
1018
1020
1022 }
1023
1024
1025
1026
1027
1029
1030 break;
1031
1032 default:
1033
1034#ifdef _MSC_VER
1035#pragma prefast( suppress: 28159, "if the type of open is unknown then things are very bad." )
1036#endif
1038 }
1039
1040
1041
1042
1043
1044
1045
1047
1050 }
1051
1054 ||
1056#endif
1057 ) {
1058
1059
1060
1061
1062
1063
1066 IrpContext,
1069
1071 }
1072
1073
1074
1075
1076
1078
1080
1081
1082
1083
1084
1086
1087
1088
1089
1090
1091
1092
1095
1096
1097
1098
1099
1102
1104 }
1105
1106
1107
1108
1109
1112
1114
1115
1116
1117
1118
1120
1122 }
1123 }
1124
1126
1128 }
1129 }
1130
1131#if (NTDDI_VERSION >= NTDDI_WIN8)
1132
1134
1135#endif
1136
1138
1140
1143
1144 if (SendUnlockNotification) {
1145
1147 }
1148
1149
1150
1151
1152
1155
1157 }
1158
1161
1163}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
VOID DeleteContext(PWSTR pszName)
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
#define CcIsFileCached(FO)
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN TypeOfOpen
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
enum _TYPE_OF_OPEN TYPE_OF_OPEN
#define NT_SUCCESS(StatCode)
VOID FatAutoUnlock(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
_In_ PIO_STACK_LOCATION IrpSp
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
#define FatBugCheck(A, B, C)
#define ExAcquireResourceExclusiveLite(res, wait)
#define ClearFlag(_F, _SF)
VOID FatUnpinRepinnedBcbs(IN PIRP_CONTEXT IrpContext)
FINISHED FatZeroData(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PFILE_OBJECT FileObject, IN ULONG StartingZero, IN ULONG ByteCount)
VOID FatTunnelFcbOrDcb(IN PFCB FcbOrDcb, IN PCCB Ccb OPTIONAL)
LARGE_INTEGER FatLargeZero
TYPE_OF_OPEN FatDecodeFileObject(_In_ PFILE_OBJECT FileObject, _Outptr_ PVCB *Vcb, _Outptr_ PFCB *FcbOrDcb, _Outptr_ PCCB *Ccb)
#define FatCompleteRequest(IRPCONTEXT, IRP, STATUS)
#define FatNotifyReportChange(I, V, F, FL, A)
#define FatReleaseFcb(IRPCONTEXT, Fcb)
NTSTATUS FatFlushFat(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb)
VOID NTAPI FatPrePostIrp(IN PVOID Context, IN PIRP Irp)
#define FatResetExceptionState(IRPCONTEXT)
#define FatAcquireExclusiveVcb(IC, V)
#define FatIsFastIoPossible(FCB)
VOID NTAPI FatOplockComplete(IN PVOID Context, IN PIRP Irp)
#define FatNormalizeAndRaiseStatus(IRPCONTEXT, STATUS)
#define FatGetFcbOplock(F)
VOID FatRemoveNames(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb)
#define FatIsFileOplockable(F)
#define FatReleaseVcb(IRPCONTEXT, Vcb)
NTSTATUS FatHijackIrpAndFlushDevice(IN PIRP_CONTEXT IrpContext, IN PIRP Irp, IN PDEVICE_OBJECT TargetDeviceObject)
#define FCB_STATE_FLUSH_FAT
#define VCB_STATE_FLAG_LOCKED
#define VCB_STATE_FLAG_SHUTDOWN
#define VCB_STATE_FLAG_DEFERRED_FLUSH
#define IRP_CONTEXT_FLAG_CLEANUP_BREAKING_OPLOCK
#define FCB_STATE_DENY_DEFRAG
#define VCB_STATE_FLAG_WRITE_PROTECTED
#define FCB_STATE_DELETE_ON_CLOSE
#define FCB_STATE_TRUNCATE_ON_CLOSE
#define FCB_STATE_PAGING_FILE
#define CCB_FLAG_DENY_DEFRAG
#define CCB_FLAG_DELETE_ON_CLOSE
#define CCB_FLAG_COMPLETE_DISMOUNT
#define FCB_STATE_DELAY_CLOSE
NTSTATUS NTAPI FsRtlFastUnlockAll(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN PVOID Context OPTIONAL)
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
#define EXCEPTION_EXECUTE_HANDLER
#define EXCEPTION_CONTINUE_SEARCH
#define FSRTL_VOLUME_UNLOCK
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
BOOLEAN NTAPI FsRtlIsNtstatusExpected(IN NTSTATUS NtStatus)
VOID NTAPI FsRtlNotifyCleanup(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext)
VOID NTAPI FsRtlNotifyFullChangeDirectory(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext, IN PSTRING FullDirectoryName, IN BOOLEAN WatchTree, IN BOOLEAN IgnoreBuffer, IN ULONG CompletionFilter, IN PIRP NotifyIrp, IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL)
NTSTATUS NTAPI FsRtlNotifyVolumeEvent(IN PFILE_OBJECT FileObject, IN ULONG EventCode)
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
PEPROCESS NTAPI IoGetRequestorProcess(IN PIRP Irp)
NTSTATUS NTAPI FsRtlCheckOplock(IN POPLOCK Oplock, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
#define _SEH2_AbnormalTermination()
FCB_CONDITION FcbCondition
FSRTL_ADVANCED_FCB_HEADER Header
CLONG NonCachedUncleanCount
struct _FCB::@731::@734 Fcb
union _FCB::@731 Specific
struct _FCB::@731::@733 Dcb
SECTION_OBJECT_POINTERS SectionObjectPointers
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
#define FILE_ACTION_REMOVED
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FO_CLEANUP_COMPLETE
#define FO_CACHE_SUPPORTED
#define FILE_NOTIFY_CHANGE_DIR_NAME