From b19f47f9b81bdf7ed079538d103ddacb4742ce35 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 1 Apr 2020 11:34:13 +0100 Subject: [PATCH] [iso] update the handling of failure of autorun.inf creation * Commit 4c5adf092e408292a5467fa98e06418f6b8f513d moved us away from using CreateFile() when extracting a file on the target media, and as such the error code returned when failing to create an 'autorun.inf' due to a security solution has shifted. * Make sure we handle the new error and don't bail out on 'autorun.inf' creation. * Also update the actual name of the RtlDosPathNameToNtPathNameXXX function we use. * Closes #1496 --- src/iso.c | 6 ++++-- src/rufus.rc | 10 +++++----- src/stdio.c | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/iso.c b/src/iso.c index 5d1dc0b5..1a0e563e 100644 --- a/src/iso.c +++ b/src/iso.c @@ -501,7 +501,8 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha if (file_handle == INVALID_HANDLE_VALUE) { err = GetLastError(); uprintf(" Unable to create file: %s", WindowsErrorString()); - if ((err == ERROR_ACCESS_DENIED) && (safe_strcmp(&psz_sanpath[3], autorun_name) == 0)) + if (((err == ERROR_ACCESS_DENIED) || (err == ERROR_INVALID_HANDLE)) && + (safe_strcmp(&psz_sanpath[3], autorun_name) == 0)) uprintf(stupid_antivirus); else goto out; @@ -652,7 +653,8 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path) if (file_handle == INVALID_HANDLE_VALUE) { err = GetLastError(); uprintf(" Unable to create file: %s", WindowsErrorString()); - if ((err == ERROR_ACCESS_DENIED) && (safe_strcmp(&psz_sanpath[3], autorun_name) == 0)) + if (((err == ERROR_ACCESS_DENIED) || (err == ERROR_INVALID_HANDLE)) && + (safe_strcmp(&psz_sanpath[3], autorun_name) == 0)) uprintf(stupid_antivirus); else goto out; diff --git a/src/rufus.rc b/src/rufus.rc index 31badb91..432cb77f 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.10.1631" +CAPTION "Rufus 3.10.1632" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -395,8 +395,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,10,1631,0 - PRODUCTVERSION 3,10,1631,0 + FILEVERSION 3,10,1632,0 + PRODUCTVERSION 3,10,1632,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -414,13 +414,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.10.1631" + VALUE "FileVersion", "3.10.1632" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.10.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.10.1631" + VALUE "ProductVersion", "3.10.1632" END END BLOCK "VarFileInfo" diff --git a/src/stdio.c b/src/stdio.c index fcac09e5..6aa10657 100644 --- a/src/stdio.c +++ b/src/stdio.c @@ -879,7 +879,7 @@ DWORD WaitForSingleObjectWithMessages(HANDLE hHandle, DWORD dwMilliseconds) #define RtlGetProcessHeap() (NtCurrentPeb()->Reserved4[1]) // NtCurrentPeb()->ProcessHeap, mangled due to deficiencies in winternl.h PF_TYPE_DECL(NTAPI, NTSTATUS, NtCreateFile, (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK, PLARGE_INTEGER, ULONG, ULONG, ULONG, ULONG, PVOID, ULONG)); -PF_TYPE_DECL(NTAPI, BOOLEAN, RtlDosPathNameToNtPathName_U, (PCWSTR, PUNICODE_STRING, PWSTR*, PVOID)); +PF_TYPE_DECL(NTAPI, BOOLEAN, RtlDosPathNameToNtPathNameW, (PCWSTR, PUNICODE_STRING, PWSTR*, PVOID)); PF_TYPE_DECL(NTAPI, BOOLEAN, RtlFreeHeap, (PVOID, ULONG, PVOID)); PF_TYPE_DECL(NTAPI, VOID, RtlSetLastWin32ErrorAndNtStatusFromNtStatus, (NTSTATUS)); @@ -896,7 +896,7 @@ HANDLE CreatePreallocatedFile(const char* lpFileName, DWORD dwDesiredAccess, NTSTATUS status = STATUS_SUCCESS; PF_INIT_OR_SET_STATUS(NtCreateFile, Ntdll); - PF_INIT_OR_SET_STATUS(RtlDosPathNameToNtPathName_U, Ntdll); + PF_INIT_OR_SET_STATUS(RtlDosPathNameToNtPathNameW, Ntdll); PF_INIT_OR_SET_STATUS(RtlFreeHeap, Ntdll); PF_INIT_OR_SET_STATUS(RtlSetLastWin32ErrorAndNtStatusFromNtStatus, Ntdll); @@ -974,7 +974,7 @@ HANDLE CreatePreallocatedFile(const char* lpFileName, DWORD dwDesiredAccess, dwDesiredAccess |= (SYNCHRONIZE | FILE_READ_ATTRIBUTES); // Convert DOS path to NT format - if (!pfRtlDosPathNameToNtPathName_U(wlpFileName, &ntPath, NULL, NULL)) { + if (!pfRtlDosPathNameToNtPathNameW(wlpFileName, &ntPath, NULL, NULL)) { wfree(lpFileName); SetLastError(ERROR_FILE_NOT_FOUND); return INVALID_HANDLE_VALUE;