2728{
2737 BOOLEAN RenamedAcrossDirectories;
2739
2742
2744
2746
2749 UCHAR OemNameBuffer[24*2];
2750
2755 PBCB TargetDirentBcb;
2756
2759
2767
2769
2772
2774
2776
2777 ULONG BytesInFirstPage = 0;
2778 ULONG DirentsInFirstPage = 0;
2779 ULONG DirentsRequired = 0;
2780 ULONG NewOffset = 0;
2781 ULONG NotifyAction = 0;
2782 ULONG SecondPageOffset = 0;
2783 ULONG ShortDirentOffset = 0;
2784 ULONG TargetDirentOffset = 0;
2785 ULONG TargetLfnOffset = 0;
2786
2787
2788
2790
2791
2792
2799
2801
2803 WCHAR UniTunneledShortNameBuffer[12];
2805 WCHAR UniTunneledLongNameBuffer[26];
2806
2808 ULONG TunneledDataSize;
2811
2813
2816
2818
2820
2821
2822
2823
2824
2825 CaseOnlyRename =
FALSE;
2826 ContinueWithRename =
FALSE;
2827 DeleteSourceDirent =
FALSE;
2828 DeleteTarget =
FALSE;
2829 NewDirentFromPool =
FALSE;
2830 RenamedAcrossDirectories =
FALSE;
2831
2833 NewDirentBcb =
NULL;
2834 OldDirentBcb =
NULL;
2835 SecondPageBcb =
NULL;
2836 TargetDirentBcb =
NULL;
2837
2838 NewOemName.Length = 0;
2839 NewOemName.MaximumLength = 24;
2840 NewOemName.Buffer = (
PCHAR)&OemNameBuffer[0];
2841
2842 OldOemName.Length = 0;
2843 OldOemName.MaximumLength = 24;
2844 OldOemName.Buffer = (
PCHAR)&OemNameBuffer[24];
2845
2849
2850 NewUpcasedName.
Length = 0;
2852 NewUpcasedName.
Buffer = &UnicodeBuffer[0];
2853
2857
2858 OldUpcasedName.
Length = 0;
2861
2865
2869
2870 UniTunneledShortName.
Length = 0;
2871 UniTunneledShortName.
MaximumLength =
sizeof(UniTunneledShortNameBuffer);
2872 UniTunneledShortName.
Buffer = &UniTunneledShortNameBuffer[0];
2873
2874 UniTunneledLongName.
Length = 0;
2875 UniTunneledLongName.
MaximumLength =
sizeof(UniTunneledLongNameBuffer);
2876 UniTunneledLongName.
Buffer = &UniTunneledLongNameBuffer[0];
2877
2878
2879
2880
2881
2882
2885 OldOemName.Length );
2886
2887
2888
2889
2890
2892
2893
2894
2895
2896
2901
2903
2904
2905
2906
2907
2908
2909
2911
2912
2913
2914
2915
2917
2919 }
2920
2921
2922
2923
2924
2925
2926
2927
2929
2930 PFCB BatchOplockFcb;
2931 ULONG BatchOplockCount;
2932
2933
2934
2935
2936
2937
2939
2940 BatchOplockFcb =
NULL;
2941 BatchOplockCount = 0;
2942
2943
2944
2945
2946
2947
2951
2953
2954
2955
2956
2957
2958
2959
2962#if (NTDDI_VERSION >= NTDDI_WIN7)
2963 ||
2965#endif
2966 )) {
2967
2968 BatchOplockCount += 1;
2969 if ( BatchOplockFcb ==
NULL ) {
2970
2971 BatchOplockFcb = TempFcb;
2972 }
2973
2974 } else {
2975
2977 }
2978 }
2979 }
2980
2981
2982
2983
2984
2985
2986 if ( BatchOplockFcb !=
NULL ) {
2987
2988 if ( (
Irp->IoStatus.Information != 0) &&
2989 (BatchOplockCount >=
Irp->IoStatus.Information) ) {
2990
2992 }
2993
2994
2995
2996
2997
2998 Irp->IoStatus.Information = BatchOplockCount;
3001 IrpContext,
3004
3005
3006
3007
3008
3009
3011
3012 continue;
3013 }
3014
3015
3016
3017
3018
3019
3021 }
3022
3023 break;
3024 }
3025
3026
3027
3028
3029
3030
3031 FatPurgeReferencedFileObjects( IrpContext,
Fcb,
Flush );
3032
3033
3034
3035
3036
3037
3038
3039
3043
3044 FatAcquireExclusiveFcb( IrpContext, TempFcb );
3045
3047
3050 }
3051
3053 }
3054 }
3055
3056
3057
3058
3059
3060
3061
3062 if (TargetFileObject ==
NULL) {
3063
3064
3065
3066
3067
3068
3069
3071
3072 Buffer =
Irp->AssociatedIrp.SystemBuffer;
3073
3075
3078
3079
3080
3081
3082
3084
3086 }
3087
3089
3090 } else {
3091
3092
3093
3094
3095
3096
3097
3100
3102 &TargetVcb,
3105 (TargetVcb !=
Vcb)) {
3106
3108 }
3109
3110
3111
3112
3113
3115
3117
3118 }
3119
3120
3121
3122
3123
3124
3126
3128
3130 }
3131
3132 FatGetUnicodeNameFromFcb( IrpContext,
Fcb, &OldName );
3133
3135
3138 }
3139
3140
3141
3142
3143
3144
3146
3147
3148
3149
3150
3151
3152
3154 &OldName,
3157
3159 }
3160
3161
3162
3163
3164
3165
3167 &OldUpcasedName,
3170
3171 CaseOnlyRename =
TRUE;
3172 }
3173
3174 } else {
3175
3176 RenamedAcrossDirectories =
TRUE;
3177 }
3178
3179
3180
3181
3182
3183
3184
3185
3187
3189
3190
3191
3192
3193
3196
3197 NewOemName.Length = 0;
3198 }
3199
3200 } else {
3201
3202 NewOemName.Length = 0;
3203 }
3204
3205
3206
3207
3208
3213 &UniTunneledShortName,
3214 &UniTunneledLongName,
3215 &TunneledDataSize,
3216 &TunneledCreationTime );
3218
3219
3220
3221
3222
3223
3224
3225 if ((NewOemName.Length == 0) ||
3227 &NewNameCopy,
3232
3234
3235 } else {
3236
3237
3238
3239
3240
3241
3242 if (UniTunneledLongName.
Length &&
3243 !FatLfnDirentExists(IrpContext,
TargetDcb, &UniTunneledLongName, &TargetLfn)) {
3244
3247
3248 } else {
3249
3250
3251
3252
3253
3254
3255 DirentsRequired = 1;
3256
3257
3258 }
3259 }
3260
3261
3262
3263
3264
3266
3267
3268
3269
3270
3271 if (NewOemName.Length == 0) {
3272
3274 }
3275
3276
3277
3278
3279
3283 UsingTunneledLfn =
FALSE;
3284 }
3285
3286 if (!CaseOnlyRename) {
3287
3288
3289
3290
3291
3292
3293 if (NewOemName.Length != 0) {
3294
3296 NewOemName,
3298
3299 } else {
3300
3302 }
3303
3306
3308
3309
3310 FatLocateDirent( IrpContext,
3312 &LocalCcb,
3313 0,
3315 &TargetDirent,
3316 &TargetDirentBcb,
3317 (
PVBO)&TargetDirentOffset,
3319 &TargetLfn,
3320 &TargetOrigLfn );
3321
3322 if (TargetDirent !=
NULL) {
3323
3324
3325
3326
3327
3328
3329
3330
3331 if ((!ReplaceIfExists) ||
3334
3336 }
3337
3338
3339
3340
3341
3342
3343
3344
3345
3348
3350
3351
3352
3353
3354
3355
3356
3357 Links = Links->
Flink;
3358
3362 MmFlushForDelete))) {
3363
3364
3365
3366
3367
3368
3370
3374 ||
3376#endif
3377 )) {
3378
3379
3380
3381
3382
3383
3385
3388 IrpContext,
3391
3393
3395 }
3396 }
3397
3399 }
3400 }
3401
3402
3403
3404
3405
3406 TargetLfnOffset = TargetDirentOffset -
3409
3410 DeleteTarget =
TRUE;
3411 }
3412 }
3413
3414
3415
3416
3417
3418
3420 (DirentsRequired !=
3423
3424
3425
3426
3427
3428 NewOffset = FatCreateNewDirent( IrpContext,
3430 DirentsRequired,
3432
3433 DeleteSourceDirent =
TRUE;
3434
3435 } else {
3436
3438 }
3439
3440 ContinueWithRename =
TRUE;
3441
3443
3445
3446 if (!ContinueWithRename) {
3447
3448
3449
3450
3451
3454
3455 }
3457
3458
3459
3460
3461
3462 if (!ContinueWithRename) {
3463
3465 }
3466
3467
3468
3469
3470
3472
3473
3474
3475
3476
3477
3478
3479
3480 if (!RenamedAcrossDirectories && !DeleteTarget) {
3481
3483
3484 } else {
3485
3487 }
3488
3495 NotifyAction );
3496
3498
3499
3500
3501
3502
3503 FatGetDirentFromFcbOrDcb( IrpContext,
Fcb,
FALSE, &OldDirent, &OldDirentBcb );
3504
3506
3507
3508
3509
3510
3511
3513
3514
3515
3516
3517
3518
3519
3520
3521 InvalidateFcbOnRaise =
TRUE;
3522
3523
3524
3525
3526
3527 if (DeleteSourceDirent) {
3528
3530 }
3531
3532
3533
3534
3535
3536 if (DeleteTarget) {
3537
3538 FatDeleteFile( IrpContext,
3540 TargetLfnOffset,
3541 TargetDirentOffset,
3542 TargetDirent,
3543 &TargetLfn );
3544 }
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556 FatSelectNames( IrpContext,
3558 &NewOemName,
3559 &NewNameCopy,
3560 &NewOemName,
3561 (HaveTunneledInformation ? &UniTunneledShortName :
NULL),
3565
3567
3570
3571
3572
3573
3574
3577 }
3578
3579
3580
3581
3582
3583 FatPrepareWriteDirectoryFile( IrpContext,
3585 NewOffset,
3587 &NewDirentBcb,
3588#ifndef __REACTOS__
3589 &NewDirent,
3590#else
3591 (
PVOID *)&NewDirent,
3592#endif
3596
3598
3599
3600
3601
3602
3603
3606
3608
3609 BytesInFirstPage = SecondPageOffset - NewOffset;
3610
3611 DirentsInFirstPage = BytesInFirstPage /
sizeof(
DIRENT);
3612
3613 FatPrepareWriteDirectoryFile( IrpContext,
3615 SecondPageOffset,
3617 &SecondPageBcb,
3618#ifndef __REACTOS__
3619 &SecondPageDirent,
3620#else
3621 (
PVOID *)&SecondPageDirent,
3622#endif
3626
3628
3629 FirstPageDirent = NewDirent;
3630
3632 DirentsRequired *
sizeof(
DIRENT),
3634
3635 NewDirentFromPool =
TRUE;
3636 }
3637
3638
3639
3640
3641
3642 ShortDirent = NewDirent + DirentsRequired - 1;
3643 ShortDirentOffset = NewOffset + (DirentsRequired - 1) *
sizeof(
DIRENT);
3644
3645
3646
3647
3648
3650
3652 ShortDirent,
3653 &NewOemName,
3659 (HaveTunneledInformation ? &TunneledCreationTime :
NULL) );
3660
3661 if (HaveTunneledInformation) {
3662
3663
3664
3665
3666
3667
3671 }
3672
3673
3674
3675
3676
3677
3678
3679 if (NewDirentFromPool) {
3680
3681 RtlCopyMemory( FirstPageDirent, NewDirent, BytesInFirstPage );
3682
3684 NewDirent + DirentsInFirstPage,
3685 DirentsRequired*
sizeof(
DIRENT) - BytesInFirstPage );
3686
3687 ShortDirent = SecondPageDirent +
3688 (DirentsRequired - DirentsInFirstPage) - 1;
3689 }
3690
3692
3694
3695
3696
3697
3698
3699
3700
3701
3703
3705
3708 }
3709
3711
3714 }
3715
3721
3722
3723
3724
3725
3726
3727
3730
3732
3733
3734
3735
3736
3737
3738
3739
3741
3744
3745 } else {
3746
3749 }
3750
3753
3754#if (NTDDI_VERSION >= NTDDI_WIN8)
3755
3756
3757
3758
3759
3760
3762 IrpContext->OriginatingIrp,
3763 OPLOCK_FLAG_PARENT_OBJECT,
3767#endif
3768
3769
3770
3771
3772
3773 if (RenamedAcrossDirectories) {
3774
3775#if (NTDDI_VERSION >= NTDDI_WIN8)
3776
3777
3778
3779
3780
3781
3783 IrpContext->OriginatingIrp,
3784 OPLOCK_FLAG_PARENT_OBJECT,
3788#endif
3789
3790
3791
3792
3793
3794
3795
3799
3801
3802 DirectoryFileObject = OldParentDcb->
Specific.
Dcb.DirectoryFile;
3803
3805 }
3806
3807
3808
3809
3810
3811
3813
3814 FatPrepareWriteDirectoryFile( IrpContext,
3818 &DotDotBcb,
3819#ifndef __REACTOS__
3820 &DotDotDirent,
3821#else
3822 (
PVOID *)&DotDotDirent,
3823#endif
3827
3829
3830 DotDotDirent->FirstClusterOfFile = (
USHORT)
3833
3835
3836 DotDotDirent->FirstClusterOfFileHi = (
USHORT)
3839 }
3840 }
3841 }
3842
3843
3844
3845
3846
3847
3850
3851
3856
3858
3859
3860
3861
3862
3863
3864
3865 InvalidateFcbOnRaise =
FALSE;
3866
3867
3868
3869
3870
3871
3872
3874
3877 }
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891 if (DeleteTarget) {
3892
3903
3904 } else if (RenamedAcrossDirectories) {
3905
3913
3914 } else {
3915
3923 }
3924
3925
3926
3927
3928
3929
3930
3931
3933 Dirent.ExtendedAttributes != 0) {
3934
3935 FatRenameEAs( IrpContext,
3937 Dirent.ExtendedAttributes,
3938 &OldOemName );
3939 }
3940
3942
3944
3945
3946
3947
3948
3950
3952
3954
3956
3957 if (UniTunneledLongName.
Buffer != UniTunneledLongNameBuffer) {
3958
3959
3960
3961
3962
3964 }
3965
3966 if (NewDirentFromPool) {
3967
3969 }
3970
3973
3974
3975
3976
3977
3978 if (DirectoryFileObject) {
3979
3980 DebugTrace(0,
Dbg,
"Uninitialize our parent Stream Cache Map\n", 0);
3981
3983
3985 }
3986
3987
3988
3989
3990
3991
3992
3994
3996 }
3997
4000
4002}
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
#define NT_SUCCESS(StatCode)
_In_ PIO_STACK_LOCATION IrpSp
VOID FatSetFullNameInFcb(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ PUNICODE_STRING FinalName)
#define FAT_DIRENT_ATTR_READ_ONLY
#define FAT_DIRENT_ATTR_DIRECTORY
NTSTATUS FatSetRenameInfo(IN PIRP_CONTEXT IrpContext, IN PIRP Irp, IN PVCB Vcb, IN PFCB Fcb, IN PCCB Ccb)
#define MAX_LFN_CHARACTERS
#define FAT_LFN_DIRENTS_NEEDED(NAME)
#define TAG_FILENAME_BUFFER
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
UNICODE_STRING * PUNICODE_STRING
#define IsListEmpty(ListHead)
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
VOID FatUnpinRepinnedBcbs(IN PIRP_CONTEXT IrpContext)
VOID FatTunnelFcbOrDcb(IN PFCB FcbOrDcb, IN PCCB Ccb OPTIONAL)
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)
VOID FatUnicodeToUpcaseOem(IN PIRP_CONTEXT IrpContext, IN POEM_STRING OemString, IN PUNICODE_STRING UnicodeString)
VOID FatStringTo8dot3(_In_ PIRP_CONTEXT IrpContext, _In_ OEM_STRING InputString, _Out_writes_bytes_(11) PFAT8DOT3 Output8dot3)
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
TYPE_OF_OPEN FatDecodeFileObject(_In_ PFILE_OBJECT FileObject, _Outptr_ PVCB *Vcb, _Outptr_ PFCB *FcbOrDcb, _Outptr_ PCCB *Ccb)
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING IN PUNICODE_STRING SuggestedShortName IN OUT BOOLEAN * AllLowerComponent
#define FatNotifyReportChange(I, V, F, FL, A)
VOID FatEvaluateNameCase(IN PIRP_CONTEXT IrpContext, IN PUNICODE_STRING Name, IN OUT BOOLEAN *AllLowerComponent, IN OUT BOOLEAN *AllLowerExtension, IN OUT BOOLEAN *CreateLfn)
#define FatReleaseFcb(IRPCONTEXT, Fcb)
BOOLEAN FatSpaceInName(IN PIRP_CONTEXT IrpContext, IN PUNICODE_STRING UnicodeName)
VOID FatConstructNamesInFcb(IN PIRP_CONTEXT IrpContext, PFCB Fcb, PDIRENT Dirent, PUNICODE_STRING Lfn OPTIONAL)
PFCB FatGetNextFcbBottomUp(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb, IN PFCB TerminationFcb)
VOID NTAPI FatOplockComplete(IN PVOID Context, IN PIRP Irp)
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING IN PUNICODE_STRING SuggestedShortName IN OUT BOOLEAN IN OUT BOOLEAN * AllLowerExtension
#define FatIsNameShortOemValid(IRPCONTEXT, NAME, CAN_CONTAIN_WILD_CARDS, PATH_NAME_OK, LEADING_BACKSLASH_OK)
#define FatGetFcbOplock(F)
VOID FatRemoveNames(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb)
#define FatIsFileOplockable(F)
LARGE_INTEGER FatFatTimeToNtTime(_In_ PIRP_CONTEXT IrpContext, _In_ FAT_TIME_STAMP FatTime, _In_ UCHAR TenMilliSeconds)
#define FatDirectoryKey(FcbOrDcb)
LARGE_INTEGER FatFatDateToNtTime(_In_ PIRP_CONTEXT IrpContext, _In_ FAT_DATE FatDate)
#define CCB_FLAG_USER_SET_LAST_WRITE
#define CCB_FLAG_SKIP_SHORT_NAME_COMPARE
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
PVOID NTAPI FsRtlAllocatePoolWithTag(IN POOL_TYPE PoolType, IN ULONG NumberOfBytes, IN ULONG Tag)
BOOLEAN NTAPI FsRtlAreNamesEqual(IN PCUNICODE_STRING Name1, IN PCUNICODE_STRING Name2, IN BOOLEAN IgnoreCase, IN PCWCH UpcaseTable OPTIONAL)
BOOLEAN NTAPI FsRtlCurrentBatchOplock(IN POPLOCK Oplock)
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()
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
union _CCB::@733::@735::@737 OemQueryTemplate
UNICODE_STRING UnicodeQueryTemplate
BOOLEAN ContainsWildCards
LIST_ENTRY ParentDcbLinks
VBO LfnOffsetWithinDirectory
union _FCB::@729 Specific
UNICODE_STRING ExactCaseLongName
UNICODE_STRING FullFileName
FCB_CONDITION FcbCondition
struct _FCB::@729::@731 Dcb
VBO DirentOffsetWithinDirectory
struct _IO_STACK_LOCATION::@3974::@3984 SetFile
union _IO_STACK_LOCATION::@1575 Parameters
struct _LIST_ENTRY * Flink
SECTION_OBJECT_POINTERS SectionObjectPointers
BOOLEAN NTAPI FsRtlFindInTunnelCache(IN PTUNNEL Cache, IN ULONGLONG DirectoryKey, IN PUNICODE_STRING Name, OUT PUNICODE_STRING ShortName, OUT PUNICODE_STRING LongName, IN OUT PULONG DataLength, OUT PVOID Data)
union _LARGE_INTEGER LARGE_INTEGER
#define CONTAINING_RECORD(address, type, field)
#define STATUS_ACCESS_DENIED
#define STATUS_OBJECT_NAME_COLLISION
#define STATUS_OBJECT_NAME_INVALID
_Must_inspect_result_ _In_ ULONG Flags
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_ACTION_MODIFIED
#define FILE_ACTION_RENAMED_OLD_NAME
#define FILE_NOTIFY_CHANGE_LAST_ACCESS
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
#define FILE_ACTION_REMOVED
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FILE_ACTION_RENAMED_NEW_NAME
#define FILE_NOTIFY_CHANGE_CREATION
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define FILE_NOTIFY_CHANGE_EA
#define FILE_ACTION_ADDED
#define FILE_NOTIFY_CHANGE_DIR_NAME
#define ObDereferenceObject
_In_ PUNICODE_STRING NewName