[channels,drive] Prefer using handle from IRP_CREATE when possible

Windows can query information on a file recently renamed using a
handle created before the rename
This commit is contained in:
David Lechevalier
2025-03-12 18:44:36 +01:00
committed by akallabeth
parent f450b30aed
commit f301e2b222

View File

@@ -587,6 +587,11 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w
if (!file || !output)
return FALSE;
if ((file->file_handle != INVALID_HANDLE_VALUE) &&
GetFileInformationByHandle(file->file_handle, &fileInformation))
return drive_file_query_from_handle_information(file, &fileInformation, FsInformationClass,
output);
hFile = CreateFileW(file->fullpath, 0, FILE_SHARE_DELETE, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)