@@ -2528,6 +2528,24 @@ NTSTATUS PhSetFileSize(
2528
2528
);
2529
2529
}
2530
2530
2531
+ NTSTATUS PhDeleteFile (
2532
+ _In_ HANDLE FileHandle
2533
+ )
2534
+ {
2535
+ FILE_DISPOSITION_INFORMATION dispositionInfo ;
2536
+ IO_STATUS_BLOCK isb ;
2537
+
2538
+ dispositionInfo .DeleteFile = TRUE;
2539
+
2540
+ return NtSetInformationFile (
2541
+ FileHandle ,
2542
+ & isb ,
2543
+ & dispositionInfo ,
2544
+ sizeof (FILE_DISPOSITION_INFORMATION ),
2545
+ FileDispositionInformation
2546
+ );
2547
+ }
2548
+
2531
2549
NTSTATUS PhGetFileHandleName (
2532
2550
_In_ HANDLE FileHandle ,
2533
2551
_Out_ PPH_STRING * FileName
@@ -7315,20 +7333,10 @@ static BOOLEAN PhpDeleteDirectoryCallback(
7315
7333
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
7316
7334
)))
7317
7335
{
7318
- IO_STATUS_BLOCK isb ;
7319
- FILE_DISPOSITION_INFORMATION fileInfo ;
7320
-
7321
7336
PhEnumDirectoryFile (directoryHandle , NULL , PhpDeleteDirectoryCallback , fullName );
7322
7337
7323
7338
// Delete the directory.
7324
- fileInfo .DeleteFile = TRUE;
7325
- NtSetInformationFile (
7326
- directoryHandle ,
7327
- & isb ,
7328
- & fileInfo ,
7329
- sizeof (FILE_DISPOSITION_INFORMATION ),
7330
- FileDispositionInformation
7331
- );
7339
+ PhDeleteFile (directoryHandle );
7332
7340
7333
7341
NtClose (directoryHandle );
7334
7342
}
@@ -7401,9 +7409,6 @@ NTSTATUS PhDeleteDirectory(
7401
7409
7402
7410
if (NT_SUCCESS (status ))
7403
7411
{
7404
- IO_STATUS_BLOCK isb ;
7405
- FILE_DISPOSITION_INFORMATION fileInfo ;
7406
-
7407
7412
// Remove any files or folders inside the directory.
7408
7413
status = PhEnumDirectoryFile (
7409
7414
directoryHandle ,
@@ -7413,14 +7418,7 @@ NTSTATUS PhDeleteDirectory(
7413
7418
);
7414
7419
7415
7420
// Remove the directory.
7416
- fileInfo .DeleteFile = TRUE;
7417
- status = NtSetInformationFile (
7418
- directoryHandle ,
7419
- & isb ,
7420
- & fileInfo ,
7421
- sizeof (FILE_DISPOSITION_INFORMATION ),
7422
- FileDispositionInformation
7423
- );
7421
+ PhDeleteFile (directoryHandle );
7424
7422
7425
7423
NtClose (directoryHandle );
7426
7424
}
0 commit comments