Update PhDeleteFile with posix semantics
@@ -3449,24 +3449,27 @@ NTSTATUS PhDeleteFile(
_In_ HANDLE FileHandle
)
{
+ NTSTATUS status = STATUS_UNSUCCESSFUL;
+
if (WindowsVersion >= WINDOWS_10_RS5)
{
- NTSTATUS status;
- FILE_DISPOSITION_INFO_EX dispositionInfoEx;
+ FILE_DISPOSITION_INFO_EX dispositionInfo;
IO_STATUS_BLOCK isb;
- dispositionInfoEx.Flags = FILE_DISPOSITION_FLAG_DELETE | FILE_DISPOSITION_FLAG_IGNORE_READONLY_ATTRIBUTE;
+ dispositionInfo.Flags = FILE_DISPOSITION_FLAG_DELETE | FILE_DISPOSITION_FLAG_POSIX_SEMANTICS | FILE_DISPOSITION_FLAG_IGNORE_READONLY_ATTRIBUTE;
status = NtSetInformationFile(
FileHandle,
&isb,
- &dispositionInfoEx,
+ &dispositionInfo,
sizeof(FILE_DISPOSITION_INFO_EX),
FileDispositionInformationEx
);
+ }
if (!NT_SUCCESS(status))
{
FILE_DISPOSITION_INFORMATION dispositionInfo;
+ IO_STATUS_BLOCK isb;
dispositionInfo.DeleteFile = TRUE;
@@ -3481,22 +3484,6 @@ NTSTATUS PhDeleteFile(
return status;
}
- else
- {
- FILE_DISPOSITION_INFORMATION dispositionInfo;
- IO_STATUS_BLOCK isb;
-
- dispositionInfo.DeleteFile = TRUE;
-
- return NtSetInformationFile(
- FileHandle,
- &isb,
- &dispositionInfo,
- sizeof(FILE_DISPOSITION_INFORMATION),
- FileDispositionInformation
- );
- }
-}
NTSTATUS PhGetFileHandleName(
_In_ HANDLE FileHandle,
