diff --git a/res/loc/ChangeLog.txt b/res/loc/ChangeLog.txt index 8618735a..2c071100 100644 --- a/res/loc/ChangeLog.txt +++ b/res/loc/ChangeLog.txt @@ -2,19 +2,31 @@ This file lists all the changes that have been applied to the en-US translation rufus.loc since its original version. To edit a translation, please make sure to follow: -https://github.com/pbatard/rufus/wiki/Localization#Editing_a_translation -Or simply download the latest pollock.exe from https://rufus.ie/locale/ and follow -its directions. +https://github.com/pbatard/rufus/wiki/Localization#Editing_an_existing_translation +Or simply download https://rufus-web.akeo.ie/locale/pollock.exe and follow its directions. -o v3.5 +o v3.5 (2019.03.12) + The following 3 messages can be tested by creating a UEFI:NTFS drive in Rufus ('Show advanced drive properties' must be enabled + and then you can just select 'UEFI:NTFS' under 'Boot selection' and click 'START'. Then, when the drive creation is complete, you + will see a dialog using the 3 messages below) - *NEW* MSG_127 "Do not show this message again" - - *NEW* MSG_128 "Important notice about %s" where %s will be one of "MBR", "Secure Boot", "Windows To Go" + In the following '%s' will be one of "MBR", "Secure Boot", "Windows To Go" (in English). Please be mindful that the (...) below + means that there is MORE DATA to this message and that you need to look at the English version in the loc file for the full text. + - *NEW* MSG_128 "Important notice about %s" - *NEW* MSG_129 "You have just created a media that includes the UEFI:NTFS bootloader (...)" + The following 2 messages can be tested when creating a Windows image from the latest Windows 10 retail ISOs - *NEW* MSG_130 "Windows image selection" - *NEW* MSG_131 "This ISO contains multiple Windows images.\nPlease select the image you wish to use for this installation:" + You should be able to see this message if you open a command prompt to the root of your flash drive and then attempt to format + it in Rufus. For instance, if your flash drive is E: just open cmd.exe and then type E: to navigate to that drive. - *NEW* MSG_132 "Another program or process is accessing this drive. Do you want to format it anyway?" + The following message will appear if you create a Windows To Go drive from a Windows 10 1809 ISO. Please be mindful that the (...) + below means that there is MORE DATA to this message and that you need to look at the English version to translate it. - *NEW* MSG_133 "Rufus has detected that you are attempting to create a Windows To Go media based on a 1809 ISO. (...)" + The following will appear if you attempt to format a drive that is larger than 2 TB. Again, please be mindful that (...) means + that there is more data to this message and that you must look at the English version to translate it. - *NEW* MSG_134 "Because MBR has been selected for the partition scheme, Rufus can only create a partition up to 2 TB (...)" + MSG_135 to 149 appear in the "Download ISO Image" dialog that is proposed from the SELECT split button when clicking DOWNLOAD - *NEW* MSG_135 "Version" - *NEW* MSG_136 "Release" - *NEW* MSG_137 "Edition" @@ -23,10 +35,15 @@ o v3.5 - *NEW* MSG_140 "Confirm" - *NEW* MSG_141 "Back" - *NEW* MSG_142 "Please wait..." - - *NEW* MSG_143 "Download ISO Image" - - *NEW* MSG_144 "Download using a browser" - - *NEW* MSG_149 "Running download script..." - - *UPDATED* MSG_165 + - *NEW* MSG_143 "Download using a browser" + - *NEW* MSG_144 "Temporarily banned by Microsoft for requesting too many downloads - Please try again later..." + The following 2 messages should only appear on vanilla Windows 7 platforms when launching the 'Download ISO Image' script + - *NEW* MSG_145 "PowerShell 3.0 or later is required to run this script." + - *NEW* MSG_146 "Do you want to go online and download it?" + - *NEW* MSG_148 "Running download script..." + - *NEW* MSG_149 "Download ISO Image" + The tooltip for the SELECT button has been updated to mention downloads + - *UPDATED* MSG_165 "Click to select an image..." -> "Click to select or download an image..." o v3.2 (2018.07.20) The following appears in Advanced format options → Check device for bad blocks → dropdown menu with diff --git a/res/loc/po/fr-FR.po b/res/loc/po/fr-FR.po index 76422778..9f3407dd 100644 --- a/res/loc/po/fr-FR.po +++ b/res/loc/po/fr-FR.po @@ -1,9 +1,9 @@ msgid "" msgstr "" -"Project-Id-Version: 3.2\n" +"Project-Id-Version: 3.5\n" "Report-Msgid-Bugs-To: pete@akeo.ie\n" -"POT-Creation-Date: 2019-02-01 12:29+0000\n" -"PO-Revision-Date: 2019-02-01 12:29+0000\n" +"POT-Creation-Date: 2019-03-12 13:52+0000\n" +"PO-Revision-Date: 2019-03-12 13:52+0000\n" "Language: fr_FR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -583,8 +583,8 @@ msgstr "" "Note : Le nouveau fichier sera téléchargé dans le répertoire courant. Si un '%s' existe à cet endroit, il sera réutilisé automatiquement." #. • MSG_085 -msgid "Downloading '%s'" -msgstr "Téléchargement de '%s'" +msgid "Downloading %s" +msgstr "Téléchargement de %s" #. • MSG_086 msgid "No image selected" @@ -910,6 +910,62 @@ msgstr "" "\n" "Etes-vous sûr de vouloir continuer ?" +#. • MSG_135 +msgid "Version" +msgstr "" + +#. • MSG_136 +msgid "Release" +msgstr "" + +#. • MSG_137 +msgid "Edition" +msgstr "Édition" + +#. • MSG_138 +msgid "Language" +msgstr "Langue de produit" + +#. • MSG_139 +msgid "Architecture" +msgstr "" + +#. • MSG_140 +msgid "Continue" +msgstr "Continuer" + +#. • MSG_141 +msgid "Back" +msgstr "Retour" + +#. • MSG_142 +msgid "Please wait..." +msgstr "Veuillez patienter..." + +#. • MSG_143 +msgid "Download using a browser" +msgstr "Télécharger avec un navigateur" + +#. • MSG_144 +msgid "Temporarily banned by Microsoft for requesting too many downloads - Please try again later..." +msgstr "Temporairement banni par Microsoft pour trop de téléchargements - Veuillez réessayer plus tard..." + +#. • MSG_145 +msgid "PowerShell 3.0 or later is required to run this script." +msgstr "PowerShell 3.0 ou ultérieur est nécessaire pour lancer ce script." + +#. • MSG_146 +msgid "Do you want to go online and download it?" +msgstr "Voulez-vous aller en ligne pour le télécharger ?" + +#. • MSG_148 +msgid "Running download script..." +msgstr "Execution du script de téléchargement..." + +#. • MSG_149 +msgid "Download ISO Image" +msgstr "Télécharger une image ISO" + #. • MSG_150 msgid "Type of computer you plan to use this bootable drive with. It is your responsibility to determine whether your target is of BIOS or UEFI type before you start creating the drive, as it may fail to boot otherwise." msgstr "Type d'ordinateur avec lequel vous comptez utiliser ce disque démarrable. Il est de votre responsabilité de déterminer s'il s'agit d'un type BIOS ou UEFI avant de commencer a créer votre périphérique, car il risque de ne pas démarrer sinon." @@ -977,8 +1033,8 @@ msgid "Method that will be used to make the drive bootable" msgstr "Méthode à utiliser pour rendre le périphérique démarrable" #. • MSG_165 -msgid "Click to select an image..." -msgstr "Cliquez ici pour sélectionner une image..." +msgid "Click to select or download an image..." +msgstr "Cliquez ici pour sélectionner ou télécharger une image..." #. • MSG_166 msgid "Check this box to allow the display of international labels and set a device icon (creates an autorun.inf)" diff --git a/res/loc/rufus.loc b/res/loc/rufus.loc index 7d4f02c4..f243abe0 100644 --- a/res/loc/rufus.loc +++ b/res/loc/rufus.loc @@ -3,7 +3,7 @@ ######################################################################### # List of all languages included in this file (with version) -# • v3.2 "en-US" "English (English)" +# • v3.5 "en-US" "English (English)" # • v3.2 "ar-SA" "Arabic (العربية)" # • v3.0 "az-AZ" "Azerbaijani (Azərbaycanca)" # • v3.2 "bg-BG" "Bulgarian (Български)" @@ -14,7 +14,7 @@ # • v3.2 "da-DK" "Danish (Dansk)" # • v3.2 "nl-NL" "Dutch (Nederlands)" # • v3.2 "fi-FI" "Finnish (Suomi)" -# • v3.2 "fr-FR" "French (Français)" +# • v3.5 "fr-FR" "French (Français)" # • v3.2 "de-DE" "German (Deutsch)" # • v3.2 "el-GR" "Greek (Ελληνικά)" # • v3.2 "he-IL" "Hebrew (עברית)" @@ -45,7 +45,7 @@ ######################################################################### l "en-US" "English (English)" 0x0409, 0x0809, 0x0c09, 0x1009, 0x1409, 0x1809, 0x1c09, 0x2009, 0x2409, 0x2809, 0x2c09, 0x3009, 0x3409, 0x3809, 0x3c09, 0x4009, 0x4409, 0x4809 -v 3.2 +v 3.5 g IDD_DIALOG t IDS_DRIVE_PROPERTIES_TXT "Drive Properties" @@ -346,9 +346,12 @@ t MSG_139 "Architecture" t MSG_140 "Continue" t MSG_141 "Back" t MSG_142 "Please wait..." -t MSG_143 "Download ISO Image" -t MSG_144 "Download using a browser" -t MSG_149 "Running download script..." +t MSG_143 "Download using a browser" +t MSG_144 "Temporarily banned by Microsoft for requesting too many downloads - Please try again later..." +t MSG_145 "PowerShell 3.0 or later is required to run this script." +t MSG_146 "Do you want to go online and download it?" +t MSG_148 "Running download script..." +t MSG_149 "Download ISO Image" t MSG_150 "Type of computer you plan to use this bootable drive with. It is your responsibility to determine whether " "your target is of BIOS or UEFI type before you start creating the drive, as it may fail to boot otherwise." # You shouldn't translate 'Legacy Mode' as this is an option that usually appears in English in the UEFI settings. @@ -4093,7 +4096,7 @@ t MSG_306 "Pikanollataan asemaa: %0.1f%% suoritettu" ######################################################################### l "fr-FR" "French (Français)" 0x040c, 0x080c, 0x0c0c, 0x100c, 0x140c, 0x180c, 0x1c0c, 0x200c, 0x240c, 0x280c, 0x2c0c, 0x300c, 0x340c, 0x380c, 0xe40c -v 3.2 +v 3.5 b "en-US" g IDD_ABOUTBOX @@ -4288,9 +4291,12 @@ t MSG_138 "Langue de produit" t MSG_140 "Continuer" t MSG_141 "Retour" t MSG_142 "Veuillez patienter..." -t MSG_143 "Télécharger une image ISO" -t MSG_144 "Télécharger avec un navigateur" -t MSG_149 "Execution du script de téléchargement..." +t MSG_143 "Télécharger avec un navigateur" +t MSG_144 "Temporairement banni par Microsoft pour trop de téléchargements - Veuillez réessayer plus tard..." +t MSG_145 "PowerShell 3.0 ou ultérieur est nécessaire pour lancer ce script." +t MSG_146 "Voulez-vous aller en ligne pour le télécharger ?" +t MSG_148 "Execution du script de téléchargement..." +t MSG_149 "Télécharger une image ISO" t MSG_150 "Type d'ordinateur avec lequel vous comptez utiliser ce disque démarrable. Il est de votre responsabilité de déterminer s'il s'agit d'un type BIOS ou UEFI avant de commencer a créer votre périphérique, car il risque de ne pas démarrer sinon." t MSG_151 "'UEFI-CSM' signifie que le périphérique démarrera seulement en mode émulation BIOS (i.e. 'Legacy Mode') sous UEFI, et non pas en mode UEFI natif." t MSG_152 "'non CSM' signifie que le périphérique démarrera seulement en mode UEFI natif, et non pas en mode émulation BIOS (i.e. 'Legacy Mode')." diff --git a/src/net.c b/src/net.c index 80cd4168..a87d84c8 100644 --- a/src/net.c +++ b/src/net.c @@ -234,7 +234,7 @@ static char* GetShortName(const char* url) if (len < 5) return NULL; - for (i = len - 1; i > 0; i--) { + for (i = len - 2; i > 0; i--) { if (url[i] == '/') { i++; break; @@ -306,8 +306,10 @@ out: * If hProgressDialog is not NULL, this function will send INIT and EXIT messages * to the dialog in question, with WPARAM being set to nonzero for EXIT on success * and also attempt to indicate progress using an IDC_PROGRESS control + * Note that when a buffer is used, the actual size of the buffer is one more than its reported + * size (with the extra byte set to 0) to accomodate for calls that need a NUL-terminated buffer. */ -static uint64_t DownloadToFileOrBuffer(const char* url, const char* file, BYTE** buffer, HWND hProgressDialog, BOOL bTaskBarProgress) +uint64_t DownloadToFileOrBuffer(const char* url, const char* file, BYTE** buffer, HWND hProgressDialog, BOOL bTaskBarProgress) { const char* accept_types[] = {"*/*\0", NULL}; const char* short_name; @@ -344,6 +346,7 @@ static uint64_t DownloadToFileOrBuffer(const char* url, const char* file, BYTE** // Use the progress control provided, if any hProgressBar = GetDlgItem(hProgressDialog, IDC_PROGRESS); if (hProgressBar != NULL) { + SendMessage(hProgressBar, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0); SendMessage(hProgressBar, PBM_SETMARQUEE, FALSE, 0); SendMessage(hProgressBar, PBM_SETPOS, 0, 0); } @@ -427,7 +430,8 @@ static uint64_t DownloadToFileOrBuffer(const char* url, const char* file, BYTE** uprintf("No buffer pointer provided for download"); goto out; } - *buffer = malloc((size_t)total_size); + // Allocate one extra byte, so that caller can rely on NUL-terminated text if needed + *buffer = calloc((size_t)total_size + 1, 1); if (*buffer == NULL) { uprintf("Could not allocate buffer for download"); goto out; @@ -526,6 +530,8 @@ DWORD DownloadSignedFile(const char* url, const char* file, HWND hProgressDialog uprintf("FATAL: Download signature is invalid ✗"); DownloadStatus = 403; // Forbidden FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_BAD_SIGNATURE); + SendMessage(GetDlgItem(hProgressDialog, IDC_PROGRESS), PBM_SETSTATE, (WPARAM)PBST_ERROR, 0); + SetTaskbarProgressState(TASKBAR_ERROR); goto out; } @@ -866,7 +872,7 @@ BOOL CheckForUpdates(BOOL force) */ static DWORD WINAPI DownloadISOThread(LPVOID param) { - char cmdline[512], locale_str[1024], pipe[64] = "\\\\.\\pipe\\"; + char locale_str[1024], cmdline[sizeof(locale_str) + 512], pipe[64] = "\\\\.\\pipe\\"; char powershell_path[MAX_PATH], icon_path[MAX_PATH] = "", script_path[MAX_PATH] = ""; char *url = NULL, sig_url[128]; BYTE *sig = NULL; @@ -879,7 +885,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) // Use a GUID as random unique string, else ill-intentioned security "researchers" // may either spam our pipe or replace our script to fool antivirus solutions into // thinking that Rufus is doing something malicious... - CoCreateGuid(&guid); + IGNORE_RETVAL(CoCreateGuid(&guid)); strcpy(&pipe[9], GuidToString(&guid)); static_sprintf(icon_path, "%s%s.ico", temp_dir, APPLICATION_NAME); ExtractAppIcon(icon_path, TRUE); @@ -892,7 +898,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) static_strcpy(script_path, "D:\\Projects\\Fido\\Fido.ps1"); #else // If we don't have the script, download it - if (fido_len == 0) { + if (fido_script == NULL) { fido_len = (DWORD)DownloadToFileOrBuffer(fido_url, NULL, &fido_script, hMainDialog, FALSE); if (fido_len == 0) goto out; @@ -900,6 +906,10 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) dwSize = (DWORD)DownloadToFileOrBuffer(sig_url, NULL, &sig, NULL, FALSE); if ((dwSize != RSA_SIGNATURE_SIZE) || (!ValidateOpensslSignature(fido_script, fido_len, sig, dwSize))) { uprintf("FATAL: Signature is invalid ✗"); + FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_BAD_SIGNATURE); + SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0); + SetTaskbarProgressState(TASKBAR_ERROR); + safe_free(fido_script); free(sig); goto out; } @@ -910,7 +920,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) SetTaskbarProgressValue(0, MAX_PROGRESS); SendMessage(hProgress, PBM_SETPOS, 0, 0); } - PrintInfo(0, MSG_149); + PrintInfo(0, MSG_148); assert((fido_script != NULL) && (fido_len != 0)); @@ -928,11 +938,11 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) safe_closehandle(hFile); #endif static_sprintf(powershell_path, "%s\\WindowsPowerShell\\v1.0\\powershell.exe", system_dir); - static_sprintf(locale_str, "%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", + static_sprintf(locale_str, "%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", selected_locale->txt[0], lmprintf(MSG_135), lmprintf(MSG_136), lmprintf(MSG_137), - lmprintf(MSG_138), lmprintf(MSG_139), lmprintf(MSG_040), lmprintf(MSG_140), - lmprintf(MSG_141), lmprintf(MSG_006), lmprintf(MSG_007), lmprintf(MSG_042), - lmprintf(MSG_142), lmprintf(MSG_143)); + lmprintf(MSG_138), lmprintf(MSG_139), lmprintf(MSG_040), lmprintf(MSG_140), lmprintf(MSG_141), + lmprintf(MSG_006), lmprintf(MSG_007), lmprintf(MSG_042), lmprintf(MSG_142), lmprintf(MSG_143), + lmprintf(MSG_144), lmprintf(MSG_145), lmprintf(MSG_146)); hPipe = CreateNamedPipeA(pipe, PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, @@ -942,9 +952,9 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) } static_sprintf(cmdline, "%s -NonInteractive -Sta -NoProfile –ExecutionPolicy Bypass " - "-File %s -PipeName %s -LocData \"%s\" -Icon %s -AppTitle \"%s\"", - powershell_path, script_path, &pipe[9], locale_str, icon_path, lmprintf(MSG_143)); - // Signal our Windows alerts hook that it should close the IE cookie prompts from Fido + "-File %s -DisableFirstRunCustomize -PipeName %s -LocData \"%s\" -Icon %s -AppTitle \"%s\"", + powershell_path, script_path, &pipe[9], locale_str, icon_path, lmprintf(MSG_149)); + // Signal our Windows alert hook that it should close the IE cookie prompts from Fido close_fido_cookie_prompts = TRUE; FormatStatus = RunCommand(cmdline, app_dir, TRUE); close_fido_cookie_prompts = FALSE; @@ -1008,8 +1018,6 @@ BOOL DownloadISO() SendMessage(hMainDialog, UM_ENABLE_CONTROLS, 0, 0); return FALSE; } - // TODO: Can we locate our modal Window and position it/set it on top? - // TODO: Send close message to Fido if the user closes Rufus return TRUE; } @@ -1083,81 +1091,3 @@ out: return (dwTotalSize > 0); } - -// Resolve an HTTP 301/302 redirect (for a *SINGLE* level) -// If no redirect is in effect, or if there is an error, the original URL is returned -const char* ResolveRedirect(const char* url) -{ - static char ret_url[128]; - const char* accept_types[] = { "*/*\0", NULL }; - char hostname[64], urlpath[128]; - BOOL r = FALSE; - DWORD dwSize; - HINTERNET hSession = NULL, hConnection = NULL, hRequest = NULL; - URL_COMPONENTSA UrlParts = { sizeof(URL_COMPONENTSA), NULL, 1, (INTERNET_SCHEME)0, - hostname, sizeof(hostname), 0, NULL, 1, urlpath, sizeof(urlpath), NULL, 1 }; - - PF_TYPE_DECL(WINAPI, BOOL, InternetCrackUrlA, (LPCSTR, DWORD, DWORD, LPURL_COMPONENTSA)); - PF_TYPE_DECL(WINAPI, HINTERNET, InternetConnectA, (HINTERNET, LPCSTR, INTERNET_PORT, LPCSTR, LPCSTR, DWORD, DWORD, DWORD_PTR)); - PF_TYPE_DECL(WINAPI, BOOL, InternetReadFile, (HINTERNET, LPVOID, DWORD, LPDWORD)); - PF_TYPE_DECL(WINAPI, BOOL, InternetCloseHandle, (HINTERNET)); - PF_TYPE_DECL(WINAPI, HINTERNET, HttpOpenRequestA, (HINTERNET, LPCSTR, LPCSTR, LPCSTR, LPCSTR, LPCSTR*, DWORD, DWORD_PTR)); - PF_TYPE_DECL(WINAPI, BOOL, HttpSendRequestA, (HINTERNET, LPCSTR, DWORD, LPVOID, DWORD)); - PF_TYPE_DECL(WINAPI, BOOL, HttpQueryInfoA, (HINTERNET, DWORD, LPVOID, LPDWORD, LPDWORD)); - PF_INIT_OR_OUT(InternetCrackUrlA, WinInet); - PF_INIT_OR_OUT(InternetConnectA, WinInet); - PF_INIT_OR_OUT(InternetReadFile, WinInet); - PF_INIT_OR_OUT(InternetCloseHandle, WinInet); - PF_INIT_OR_OUT(HttpOpenRequestA, WinInet); - PF_INIT_OR_OUT(HttpSendRequestA, WinInet); - PF_INIT_OR_OUT(HttpQueryInfoA, WinInet); - - if (url == NULL) - return NULL; - - if ((!pfInternetCrackUrlA(url, (DWORD)safe_strlen(url), 0, &UrlParts)) - || (UrlParts.lpszHostName == NULL) || (UrlParts.lpszUrlPath == NULL)) - goto out; - hostname[sizeof(hostname) - 1] = 0; - - hSession = GetInternetSession(FALSE); - if (hSession == NULL) - goto out; - - hConnection = pfInternetConnectA(hSession, UrlParts.lpszHostName, UrlParts.nPort, NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)NULL); - if (hConnection == NULL) - goto out; - - hRequest = pfHttpOpenRequestA(hConnection, "GET", UrlParts.lpszUrlPath, NULL, NULL, accept_types, - INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | INTERNET_FLAG_NO_AUTO_REDIRECT | - INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI | INTERNET_FLAG_HYPERLINK | - ((UrlParts.nScheme == INTERNET_SCHEME_HTTPS) ? INTERNET_FLAG_SECURE : 0), (DWORD_PTR)NULL); - if (hRequest == NULL) - goto out; - - if (!pfHttpSendRequestA(hRequest, NULL, 0, NULL, 0)) - goto out; - - DownloadStatus = 404; - dwSize = sizeof(DownloadStatus); - pfHttpQueryInfoA(hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, (LPVOID)&DownloadStatus, &dwSize, NULL); - switch (DownloadStatus) { - case 301: - case 302: - dwSize = sizeof(ret_url); - r = (pfHttpQueryInfoA(hRequest, HTTP_QUERY_LOCATION, (LPVOID)ret_url, &dwSize, NULL) && (dwSize > 0)); - break; - default: - break; - } - -out: - if (hRequest) - pfInternetCloseHandle(hRequest); - if (hConnection) - pfInternetCloseHandle(hConnection); - if (hSession) - pfInternetCloseHandle(hSession); - - return r ? ret_url : url; -} diff --git a/src/parser.c b/src/parser.c index 3f7f568e..5cd47441 100644 --- a/src/parser.c +++ b/src/parser.c @@ -907,7 +907,7 @@ void parse_update(char* buf, size_t len) char *arch_names[CPU_ARCH_MAX] = { "x86", "x64", "arm", "arm64", "none" }; // strchr includes the NUL terminator in the search, so take care of backslash before NUL - if ((buf == NULL) || (len < 2) || (len > 65536) || (buf[len-1] != 0) || (buf[len-2] == '\\')) + if ((buf == NULL) || (len < 2) || (len > 64 * KB) || (buf[len-1] != 0) || (buf[len-2] == '\\')) return; // Sanitize the data - Not a silver bullet, but it helps len = safe_strlen(buf)+1; // Someone may be inserting NULs diff --git a/src/rufus.c b/src/rufus.c index 6e52a6ef..5055fa6e 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -117,7 +117,7 @@ char embedded_sl_version_str[2][12] = { "?.??", "?.??" }; char embedded_sl_version_ext[2][32]; char ClusterSizeLabel[MAX_CLUSTER_SIZES][64]; char msgbox[1024], msgbox_title[32], *ini_file = NULL, *image_path = NULL, *short_image_path; -char image_option_txt[128], fido_url[128]; +char image_option_txt[128], *fido_url = NULL; StrArray DriveID, DriveLabel, DriveHub, BlockingProcess, ImageList; // Number of steps for each FS for FCC_STRUCTURE_PROGRESS const int nb_steps[FS_MAX] = { 5, 5, 12, 1, 10 }; @@ -1880,7 +1880,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA case WM_COMMAND: #ifdef RUFUS_TEST if (LOWORD(wParam) == IDC_TEST) { - uprintf("%s -> %s", FIDO_BASE, ResolveRedirect(FIDO_BASE)); break; } #endif @@ -2264,10 +2263,17 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA KillTimer(hMainDialog, TID_APP_TIMER); if (!IS_ERROR(FormatStatus)) PrintInfo(0, MSG_210); - else if (SCODE_CODE(FormatStatus)) + else switch (SCODE_CODE(FormatStatus)) { + case ERROR_CANCELLED: PrintInfo(0, MSG_211); - else + break; + case ERROR_BAD_SIGNATURE: + PrintInfo(0, MSG_283); + break; + default: PrintInfo(0, MSG_212); + break; + } EnableControls(TRUE); break; case UM_TIMER_START: @@ -3114,6 +3120,7 @@ relaunch: image_options = IMOP_WINTOGO; image_option_txt[0] = 0; select_index = 0; + safe_free(fido_url); enable_fido = FALSE; SetProcessDefaultLayout(right_to_left_mode?LAYOUT_RTL:0); if (get_loc_data_file(loc_file, selected_locale)) @@ -3407,6 +3414,7 @@ out: safe_free(update.download_url); safe_free(update.release_notes); safe_free(grub2_buf); + safe_free(fido_url); safe_free(fido_script); if (argv != NULL) { for (i=0; i #include +#include #include "rufus.h" #include "missing.h" @@ -685,40 +686,6 @@ BOOL IsFontAvailable(const char* font_name) /* * Set or restore a Local Group Policy DWORD key indexed by szPath/SzPolicy */ -#pragma push_macro("INTERFACE") -#undef INTERFACE -#define INTERFACE IGroupPolicyObject -#define REGISTRY_EXTENSION_GUID { 0x35378EACL, 0x683F, 0x11D2, {0xA8, 0x9A, 0x00, 0xC0, 0x4F, 0xBB, 0xCF, 0xA2} } -#define GPO_OPEN_LOAD_REGISTRY 1 -#define GPO_SECTION_MACHINE 2 -typedef enum _GROUP_POLICY_OBJECT_TYPE { - GPOTypeLocal = 0, GPOTypeRemote, GPOTypeDS -} GROUP_POLICY_OBJECT_TYPE, *PGROUP_POLICY_OBJECT_TYPE; -DECLARE_INTERFACE_(IGroupPolicyObject, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(New) (THIS_ LPOLESTR pszDomainName, LPOLESTR pszDisplayName, DWORD dwFlags) PURE; - STDMETHOD(OpenDSGPO) (THIS_ LPOLESTR pszPath, DWORD dwFlags) PURE; - STDMETHOD(OpenLocalMachineGPO) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(OpenRemoteMachineGPO) (THIS_ LPOLESTR pszComputerName, DWORD dwFlags) PURE; - STDMETHOD(Save) (THIS_ BOOL bMachine, BOOL bAdd,GUID *pGuidExtension, GUID *pGuid) PURE; - STDMETHOD(Delete) (THIS) PURE; - STDMETHOD(GetName) (THIS_ LPOLESTR pszName, int cchMaxLength) PURE; - STDMETHOD(GetDisplayName) (THIS_ LPOLESTR pszName, int cchMaxLength) PURE; - STDMETHOD(SetDisplayName) (THIS_ LPOLESTR pszName) PURE; - STDMETHOD(GetPath) (THIS_ LPOLESTR pszPath, int cchMaxPath) PURE; - STDMETHOD(GetDSPath) (THIS_ DWORD dwSection, LPOLESTR pszPath ,int cchMaxPath) PURE; - STDMETHOD(GetFileSysPath) (THIS_ DWORD dwSection, LPOLESTR pszPath, int cchMaxPath) PURE; - STDMETHOD(GetRegistryKey) (THIS_ DWORD dwSection, HKEY *hKey) PURE; - STDMETHOD(GetOptions) (THIS_ DWORD *dwOptions) PURE; - STDMETHOD(SetOptions) (THIS_ DWORD dwOptions, DWORD dwMask) PURE; - STDMETHOD(GetType) (THIS_ GROUP_POLICY_OBJECT_TYPE *gpoType) PURE; - STDMETHOD(GetMachineName) (THIS_ LPOLESTR pszName, int cchMaxLength) PURE; - STDMETHOD(GetPropertySheetPages) (THIS_ HPROPSHEETPAGE **hPages, UINT *uPageCount) PURE; -}; -typedef IGroupPolicyObject *LPGROUPPOLICYOBJECT; - // I've seen rare cases where pLGPO->lpVtbl->Save(...) gets stuck, which prevents the // application from launching altogether. To alleviate this, use a thread that we can // terminate if needed... @@ -740,7 +707,7 @@ DWORD WINAPI SetLGPThread(LPVOID param) // Along with global 'existing_key', this static value is used to restore initial state static DWORD original_val; HKEY path_key = NULL, policy_key = NULL; - // MSVC is finicky about these ones => redefine them + // MSVC is finicky about these ones even if you link against gpedit.lib => redefine them const IID my_IID_IGroupPolicyObject = { 0xea502723L, 0xa23d, 0x11d1, { 0xa7, 0xd3, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3 } }; const IID my_CLSID_GroupPolicyObject = @@ -771,7 +738,6 @@ DWORD WINAPI SetLGPThread(LPVOID param) goto error; } - // The DisableSystemRestore is set in Software\Policies\Microsoft\Windows\DeviceInstall\Settings r = RegCreateKeyExA(path_key, p->szPath, 0, NULL, 0, KEY_SET_VALUE | KEY_QUERY_VALUE, NULL, &policy_key, &disp); if (r != ERROR_SUCCESS) { @@ -829,7 +795,6 @@ error: pLGPO->lpVtbl->Release(pLGPO); return FALSE; } -#pragma pop_macro("INTERFACE") BOOL SetLGP(BOOL bRestore, BOOL* bExistingKey, const char* szPath, const char* szPolicy, DWORD dwValue) { diff --git a/src/stdlg.c b/src/stdlg.c index 549708fe..f122779f 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -1544,27 +1544,24 @@ BOOL SetUpdateCheck(void) WriteSetting32(SETTING_UPDATE_INTERVAL, 86400); } // Also detect if we can use Fido, which depends on: + // - Powershell being installed // - Update check being enabled // - URL for the script being reachable - if (ReadSetting32(SETTING_UPDATE_INTERVAL) > 0) { - char *p, url[128]; - // Obviously, we could fetch https://api.github.com/repos/pbatard/Fido/releases/latest - // and then parse 'browser_download_url' in the JSON data to get the direct link we - // want. But that would force us to download an extra 5 KB of data, which we *really* - // don't want to do when we need a superfast availability check. - // Therefore, since we don't expect GitHub to change their scheme anytime soon, we - // just hack the redirected URL we got back to replace '/tag/' with '/download/'... - static_sprintf(url, "%s/%s", ResolveRedirect(FIDO_BASE), FIDO_NAME); - p = strstr(url, "/tag/"); - if (p != NULL) { - *p = 0; - strcpy(fido_url, url); - strcat(fido_url, "/download/"); - strcat(fido_url, &p[5]); - } else { - strcpy(fido_url, url); + if (((ReadRegistryKey32(REGKEY_HKLM, "Microsoft\\PowerShell\\1\\Install") > 0) || + (ReadRegistryKey32(REGKEY_HKLM, "Microsoft\\PowerShell\\3\\Install") > 0)) && + (ReadSetting32(SETTING_UPDATE_INTERVAL) > 0)) { + char *loc = NULL; + // Get the Fido URL from parsing a 'Fido.ver' on our server. This enables the use of different + // Fido versions from different versions of Rufus, if needed, as opposed to always downloading + // the latest release from GitHub, which may contain incompatible changes... + uint64_t loc_len = DownloadToFileOrBuffer(RUFUS_URL "/Fido.ver", NULL, (BYTE**)&loc, NULL, FALSE); + if ((loc_len != 0) && (loc_len < 4 * KB)) { + loc_len++; // DownloadToFileOrBuffer allocated an extra NUL character if needed + fido_url = get_token_data_buffer(FIDO_VERSION, 1, loc, (size_t)loc_len); + uprintf("Fido URL is %s", fido_url); + enable_fido = IsDownloadable(fido_url); } - enable_fido = IsDownloadable(fido_url); + safe_free(loc); } if (!enable_fido) uprintf("Note: ISO download feature will be disabled"); @@ -2015,7 +2012,7 @@ BOOL SetAlertPromptHook(void) } FreeLibrary(mui_lib); } - static_strcpy(title_str[2], lmprintf(MSG_143)); + static_strcpy(title_str[2], lmprintf(MSG_149)); ap_weh = SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, NULL, AlertPromptHook, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);