From f301e2b222ea276fd028cee7929aece3eccda412 Mon Sep 17 00:00:00 2001 From: David Lechevalier Date: Wed, 12 Mar 2025 18:44:36 +0100 Subject: [PATCH] [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 --- channels/drive/client/drive_file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index cac5682b0..69e520dca 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -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)