From e1f8b276c829b02d7d01a36225bd2ec47c3ce020 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 18 Oct 2015 21:31:47 +0100 Subject: [PATCH] [loc] fix various RTL issues * MSG_002 doesn't display in RTL * Update Policy dialog loses RTL setting after the first paragraph * Some text displayed in native Windows message boxes is not using RTL (even as the Message Box itself will display the rest of the UI elements as RTL) * Detect if the relevant language pack is installed and use MessageBoxEx to display native message box buttons using the selected language. * All theses issues are part of #621 * Also remove trailing whitespaces --- ChangeLog.txt | 3 +- src/format.c | 48 ++++++++++---------- src/license.h | 8 ++-- src/localization.c | 56 +++++++++++++++++++++-- src/localization.h | 1 + src/msapi_utf8.h | 16 ++++++- src/net.c | 12 ++--- src/pki.c | 8 ++-- src/rufus.c | 109 ++++++++++++++++++++++++--------------------- src/rufus.h | 13 ++++-- src/rufus.rc | 10 ++--- src/stdlg.c | 16 +++---- 12 files changed, 190 insertions(+), 110 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index b9035a51..a9fe4bb4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,7 +2,8 @@ o Version 2.5 (2015.10.??) Add SHA-256 checksum verification Add a cheat mode to disable exclusive USB drive locking (Alt-,) Add digital signature check on update downloads - Report Windows build number in the log (for Windows 8 and later) + Report Windows build number in the log (Windows 8 or later) + Localization improvements Additional translation updates o Version 2.4 (2015.09.27) diff --git a/src/format.c b/src/format.c index 86b5d136..a2e5f4bf 100644 --- a/src/format.c +++ b/src/format.c @@ -64,7 +64,7 @@ uint8_t *grub2_buf = NULL; long grub2_len; static BOOL WritePBR(HANDLE hLogicalDrive); -/* +/* * Convert the fmifs outputs messages (that use an OEM code page) to UTF-8 */ static void OutputUTF8Message(const char* src) @@ -312,13 +312,13 @@ static void ToValidLabel(WCHAR* name, BOOL bFAT) * For example, say a disk was formatted on 26 Dec 95 at 9:55 PM and 41.94 * seconds. DOS takes the date and time just before it writes it to the * disk. - * + * * Low order word is calculated: Volume Serial Number is: * Month & Day 12/26 0c1ah * Sec & Hundredths 41:94 295eh 3578:1d02 * ----- * 3578h - * + * * High order word is calculated: * Hours & Minutes 21:55 1537h * Year 1995 07cbh @@ -346,7 +346,7 @@ static DWORD GetVolumeID(void) /* * This is the Microsoft calculation from FATGEN - * + * * DWORD RootDirSectors = 0; * DWORD TmpVal1, TmpVal2, FATSz; * @@ -363,7 +363,7 @@ static DWORD GetFATSizeSectors(DWORD DskSize, DWORD ReservedSecCnt, DWORD SecPer ULONGLONG FatElementSize = 4; ULONGLONG FatSz; - // This is based on + // This is based on // http://hjem.get2net.dk/rune_moeller_barnkob/filesystems/fat.html Numerator = FatElementSize * (DskSize - ReservedSecCnt); Denominator = (SecPerClus * BytesPerSect) + (FatElementSize * NumFATs); @@ -399,7 +399,7 @@ static BOOL FormatFAT32(DWORD DriveIndex) DWORD BurstSize = 128; // Zero in blocks of 64K typically // Calculated later - DWORD FatSize = 0; + DWORD FatSize = 0; DWORD BytesPerSect = 0; DWORD ClusterSize = 0; DWORD SectorsPerCluster = 0; @@ -510,7 +510,7 @@ static BOOL FormatFAT32(DWORD DriveIndex) TotalSectors = (DWORD) (piDrive.PartitionLength.QuadPart/dgDrive.BytesPerSector); pFAT32BootSect->dTotSec32 = TotalSectors; - FatSize = GetFATSizeSectors(pFAT32BootSect->dTotSec32, pFAT32BootSect->wRsvdSecCnt, + FatSize = GetFATSizeSectors(pFAT32BootSect->dTotSec32, pFAT32BootSect->wRsvdSecCnt, pFAT32BootSect->bSecPerClus, pFAT32BootSect->bNumFATs, BytesPerSect); pFAT32BootSect->dFATSz32 = FatSize; @@ -529,11 +529,11 @@ static BOOL FormatFAT32(DWORD DriveIndex) ((BYTE*)pFAT32BootSect)[510] = 0x55; ((BYTE*)pFAT32BootSect)[511] = 0xaa; - // FATGEN103.DOC says "NOTE: Many FAT documents mistakenly say that this 0xAA55 signature occupies the "last 2 bytes of - // the boot sector". This statement is correct if - and only if - BPB_BytsPerSec is 512. If BPB_BytsPerSec is greater than - // 512, the offsets of these signature bytes do not change (although it is perfectly OK for the last two bytes at the end - // of the boot sector to also contain this signature)." - // + // FATGEN103.DOC says "NOTE: Many FAT documents mistakenly say that this 0xAA55 signature occupies the "last 2 bytes of + // the boot sector". This statement is correct if - and only if - BPB_BytsPerSec is 512. If BPB_BytsPerSec is greater than + // 512, the offsets of these signature bytes do not change (although it is perfectly OK for the last two bytes at the end + // of the boot sector to also contain this signature)." + // // Windows seems to only check the bytes at offsets 510 and 511. Other OSs might check the ones at the end of the sector, // so we'll put them there too. if (BytesPerSect != 512) { @@ -555,7 +555,7 @@ static BOOL FormatFAT32(DWORD DriveIndex) // Write boot sector, fats // Sector 0 Boot Sector - // Sector 1 FSInfo + // Sector 1 FSInfo // Sector 2 More boot code - we write zeros here // Sector 3 unused // Sector 4 unused @@ -572,7 +572,7 @@ static BOOL FormatFAT32(DWORD DriveIndex) UserAreaSize = TotalSectors - ReservedSectCount - (NumFATs*FatSize); ClusterCount = UserAreaSize / SectorsPerCluster; - // Sanity check for a cluster count of >2^28, since the upper 4 bits of the cluster values in + // Sanity check for a cluster count of >2^28, since the upper 4 bits of the cluster values in // the FAT are reserved. if (ClusterCount > 0x0FFFFFFF) { die("This drive has more than 2^28 clusters, try to specify a larger cluster size or use the default\n", @@ -586,7 +586,7 @@ static BOOL FormatFAT32(DWORD DriveIndex) } // Sanity check, make sure the fat is big enough - // Convert the cluster count into a Fat sector count, and check the fat size value we calculated + // Convert the cluster count into a Fat sector count, and check the fat size value we calculated // earlier is OK. FatNeeded = ClusterCount * 4; FatNeeded += (BytesPerSect-1); @@ -901,7 +901,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) } if ((IsChecked(IDC_BOOT)) && (tt == TT_BIOS)) { // Set first partition bootable - masquerade as per the DiskID selected - buf[0x1be] = IsChecked(IDC_RUFUS_MBR) ? + buf[0x1be] = IsChecked(IDC_RUFUS_MBR) ? (BYTE)ComboBox_GetItemData(hDiskID, ComboBox_GetCurSel(hDiskID)):0x80; uprintf("Set bootable USB partition as 0x%02X\n", buf[0x1be]); } @@ -926,7 +926,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) r = write_zero_mbr(fp); goto notify; } - + // Syslinux if ( (bt == BT_SYSLINUX_V4) || (bt == BT_SYSLINUX_V6) || ((bt == BT_ISO) && (HAS_SYSLINUX(img_report)) && (IS_FAT(fs))) ) { @@ -954,7 +954,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) uprintf(using_msg, "ReactOS"); r = write_reactos_mbr(fp); goto notify; - } + } // KolibriOS if ( (bt == BT_ISO) && (img_report.has_kolibrios) && (IS_FAT(fs))) { @@ -1498,7 +1498,7 @@ DWORD WINAPI FormatThread(void* param) char efi_dst[] = "?:\\efi\\boot\\bootx64.efi"; char kolibri_dst[] = "?:\\MTLD_F32"; char grub4dos_dst[] = "?:\\grldr"; - + PF_TYPE_DECL(WINAPI, LANGID, GetThreadUILanguage, (void)); PF_TYPE_DECL(WINAPI, LANGID, SetThreadUILanguage, (LANGID)); PF_INIT(GetThreadUILanguage, Kernel32); @@ -1635,8 +1635,8 @@ DWORD WINAPI FormatThread(void* param) fprintf(log_fd, APPLICATION_NAME " bad blocks check ended on: %04d.%02d.%02d %02d:%02d:%02d\n", lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond); fclose(log_fd); - r = MessageBoxU(hMainDialog, lmprintf(MSG_012, bb_msg, logfile), - lmprintf(MSG_010), MB_ABORTRETRYIGNORE|MB_ICONWARNING|MB_IS_RTL); + r = MessageBoxExU(hMainDialog, lmprintf(MSG_012, bb_msg, logfile), + lmprintf(MSG_010), MB_ABORTRETRYIGNORE|MB_ICONWARNING|MB_IS_RTL, selected_langid); } else { // We didn't get any errors => delete the log file fclose(log_fd); @@ -1782,7 +1782,7 @@ DWORD WINAPI FormatThread(void* param) uprintf("Logical drive was not found!"); // We try to continue even if this fails, just in case CHECK_FOR_USER_CANCEL; - // If FAT32 is requested and we have a large drive (>32 GB) use + // If FAT32 is requested and we have a large drive (>32 GB) use // large FAT32 format, else use MS's FormatEx. ret = use_large_fat32?FormatFAT32(DriveIndex):FormatDrive(DriveIndex); if (!ret) { @@ -1838,7 +1838,7 @@ DWORD WINAPI FormatThread(void* param) FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE; } } else { - // We still have a lock, which we need to modify the volume boot record + // We still have a lock, which we need to modify the volume boot record // => no need to reacquire the lock... hLogicalVolume = GetLogicalHandle(DriveIndex, TRUE, FALSE); if ((hLogicalVolume == INVALID_HANDLE_VALUE) || (hLogicalVolume == NULL)) { @@ -2016,7 +2016,7 @@ DWORD WINAPI SaveImageThread(void* param) // With Windows' default optimizations, sync read + sync write for sequential operations // will be as fast, if not faster, than whatever async scheme you can come up with. for (wb = 0; ; wb += wSize) { - s = ReadFile(hPhysicalDrive, buffer, + s = ReadFile(hPhysicalDrive, buffer, (DWORD)MIN(DD_BUFFER_SIZE, SelectedDrive.DiskSize - wb), &rSize, NULL); if (!s) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_READ_FAULT; diff --git a/src/license.h b/src/license.h index 4345cb6c..2078f167 100644 --- a/src/license.h +++ b/src/license.h @@ -124,12 +124,12 @@ const char* additional_copyrights = "All other references can be found in the source.\\line\n}"; const char* update_policy = -"{\\rtf1\\ansi{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}{\\f1\\fnil\\fcharset2 Symbol;}}\n" +"{\\rtf1\\ansi{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}}\n" "\\fs16\\b %s\\b0\\line\n" "%s\\par\n" -"\\pard{\\pntext\\f1\\'B7\\tab}{\\*\\pn\\pnlvlblt\\pnf2\\pnindent0{\\pntxtb\\'B7}}\\fi-150\\li220 %s\\par\n" -"{\\pntext\\f1\\'B7\\tab}%s\\par\n" -"{\\pntext\\f1\\'B7\\tab}%s\\line\\pard\n" +"\\fs20•\\fs16 %s\\par\n" +"\\fs20•\\fs16 %s\\par\n" +"\\fs20•\\fs16 %s\\line\n" "\\line\n" "%s\\line\n\\line\n" "\\b %s\\b0\\line\n" diff --git a/src/localization.c b/src/localization.c index 15509404..95ed6c11 100644 --- a/src/localization.c +++ b/src/localization.c @@ -35,7 +35,7 @@ #include "localization.h" #include "localization_data.h" -/* +/* * List of supported locale commands, with their parameter syntax: * c control ID (no space, no quotes) * s: quoted string @@ -137,7 +137,7 @@ void add_message_command(loc_cmd* lcmd) uprintf("localization: invalid MSG_ index\n"); return; } - + safe_free(msg_table[lcmd->ctrl_id-MSG_000]); msg_table[lcmd->ctrl_id-MSG_000] = lcmd->txt[1]; lcmd->txt[1] = NULL; // String would be freed after this call otherwise @@ -547,7 +547,7 @@ loc_cmd* get_locale_from_name(char* locale_name, BOOL fallback) return lcmd; } -/* +/* * This call is used to toggle the issuing of messages with the default locale * (usually en-US) instead of the current (usually non en) one. */ @@ -573,3 +573,53 @@ const char* get_name_from_id(int id) } return "UNKNOWN ID"; } + +/* + * This call is used to get a supported Windows Language identifier we + * should pass to MessageBoxEx to try to get the buttons displayed in + * the currently selected language. This relies on the relevant language + * pack having been installed. + */ +static BOOL found_lang; +static BOOL CALLBACK EnumUILanguagesProc(LPTSTR lpUILanguageString, LONG_PTR lParam) +{ + wchar_t* wlang = (wchar_t*)lParam; + if (wcscmp(wlang, lpUILanguageString) == 0) + found_lang = TRUE; + return TRUE; +} + +WORD get_language_id(loc_cmd* lcmd) +{ + int i; + wchar_t wlang[5]; + LANGID lang_id = GetUserDefaultUILanguage(); + + if (lcmd == NULL) + return MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT); + + // Find if the selected language is the user default + for (i = 0; iunum_size; i++) { + if (lcmd->unum[i] == lang_id) { + uprintf("localization: will use default UI language 0x%04X", lang_id); + return MAKELANGID(lang_id, SUBLANG_DEFAULT); + } + } + + // Selected language is not user default - find if a language pack is installed for it + found_lang = FALSE; + for (i = 0; (iunum_size); i++) { + // Always uppercase + swprintf_s(wlang, ARRAYSIZE(wlang), L"%04X", lcmd->unum[i]); + // This callback enumeration from Microsoft is retarded. Now we need a global + // boolean to tell us that we found what we were after. + EnumUILanguages(EnumUILanguagesProc, 0x4, (LONG_PTR)wlang); // 0x04 = MUI_LANGUAGE_ID + if (found_lang) { + uprintf("localization: will use installed language pack for 0x%04X", lcmd->unum[i]); + return MAKELANGID(lcmd->unum[i], SUBLANG_DEFAULT); + } + } + + uprintf("localization: no matching language pack - some messages will be displayed using default locale"); + return MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT); +} diff --git a/src/localization.h b/src/localization.h index 09522bb1..e63bd80f 100644 --- a/src/localization.h +++ b/src/localization.h @@ -174,3 +174,4 @@ loc_cmd* get_locale_from_lcid(int lcid, BOOL fallback); loc_cmd* get_locale_from_name(char* locale_name, BOOL fallback); void toggle_default_locale(void); const char* get_name_from_id(int id); +WORD get_language_id(loc_cmd* lcmd); diff --git a/src/msapi_utf8.h b/src/msapi_utf8.h index 9b18375a..7e3df329 100644 --- a/src/msapi_utf8.h +++ b/src/msapi_utf8.h @@ -66,7 +66,7 @@ extern "C" { #define isdigitU(c) isdigit((unsigned char)(c)) #define isspaceU(c) isspace((unsigned char)(c)) #define isxdigitU(c) isxdigit((unsigned char)(c)) -// NB: other issomething() calls are not implemented as they may require multibyte UTF-8 sequences to be converted +// NB: other issomething() calls are not implemented as they may require multibyte UTF-8 sequences to be converted #define sfree(p) do {if (p != NULL) {free((void*)(p)); p = NULL;}} while(0) #define wconvert(p) wchar_t* w ## p = utf8_to_wchar(p) @@ -209,6 +209,20 @@ static __inline int MessageBoxU(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT return ret; } +static __inline int MessageBoxExU(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType, WORD wLanguageId) +{ + int ret; + DWORD err = ERROR_INVALID_DATA; + wconvert(lpText); + wconvert(lpCaption); + ret = MessageBoxExW(hWnd, wlpText, wlpCaption, uType, wLanguageId); + err = GetLastError(); + wfree(lpText); + wfree(lpCaption); + SetLastError(err); + return ret; +} + static __inline int DrawTextU(HDC hDC, LPCSTR lpText, int nCount, LPRECT lpRect, UINT uFormat) { int ret; diff --git a/src/net.c b/src/net.c index ac1094c3..a3d272a8 100644 --- a/src/net.c +++ b/src/net.c @@ -235,7 +235,7 @@ const char* WinInetErrorString(void) } } -/* +/* * Download a file from an URL * Mostly taken from http://support.microsoft.com/kb/234913 * If hProgressDialog is not NULL, this function will send INIT and EXIT messages @@ -247,7 +247,7 @@ DWORD DownloadFile(const char* url, const char* file, HWND hProgressDialog) HWND hProgressBar = NULL; BOOL r = FALSE; DWORD dwFlags, dwSize, dwDownloaded, dwTotalSize; - FILE* fd = NULL; + FILE* fd = NULL; LONG progress_style; const char* accept_types[] = {"*/*\0", NULL}; unsigned char buf[DOWNLOAD_BUFFER_SIZE]; @@ -386,8 +386,8 @@ out: if (PromptOnError) { PrintInfo(0, MSG_242); SetLastError(error_code); - MessageBoxU(hMainDialog, IS_ERROR(FormatStatus)?StrError(FormatStatus, FALSE):WinInetErrorString(), - lmprintf(MSG_044), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, IS_ERROR(FormatStatus)?StrError(FormatStatus, FALSE):WinInetErrorString(), + lmprintf(MSG_044), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); } } if (hRequest) InternetCloseHandle(hRequest); @@ -538,7 +538,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param) dwSize = sizeof(dwStatus); dwStatus = 404; HttpQueryInfoA(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwStatus, &dwSize, NULL); - if (dwStatus == 200) + if (dwStatus == 200) break; InternetCloseHandle(hRequest); hRequest = NULL; @@ -572,7 +572,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param) // Might as well let the user know if (!force_update_check) { if ((local_time > server_time + 600) || (local_time < server_time - 600)) { - uprintf("IMPORTANT: Your local clock is more than 10 minutes in the %s. Unless you fix this, " APPLICATION_NAME " may not be able to check for updates...", + uprintf("IMPORTANT: Your local clock is more than 10 minutes in the %s. Unless you fix this, " APPLICATION_NAME " may not be able to check for updates...", (local_time > server_time + 600)?"future":"past"); } } diff --git a/src/pki.c b/src/pki.c index de019f73..76e4d9dd 100644 --- a/src/pki.c +++ b/src/pki.c @@ -141,11 +141,11 @@ LONG ValidateSignature(HWND hDlg, const char* path) // Check the signature name. Make it specific enough (i.e. don't simply check for "Akeo") // so that, besides hacking our server, it'll place an extra hurdle on any malicious entity - // into also fooling a C.A. to issue a certificate that passes our test. + // into also fooling a C.A. to issue a certificate that passes our test. signature_name = GetSignatureName(path); if (signature_name == NULL) { uprintf("PKI: Could not get signature name"); - MessageBoxU(hDlg, lmprintf(MSG_284), lmprintf(MSG_283), MB_OK | MB_ICONERROR | MB_IS_RTL); + MessageBoxExU(hDlg, lmprintf(MSG_284), lmprintf(MSG_283), MB_OK | MB_ICONERROR | MB_IS_RTL, selected_langid); return TRUST_E_NOSIGNATURE; } for (i = 0; i < ARRAYSIZE(valid_cert_names); i++) { @@ -158,8 +158,8 @@ LONG ValidateSignature(HWND hDlg, const char* path) } if (i >= ARRAYSIZE(valid_cert_names)) { uprintf("PKI: Signature '%s' is unexpected...", signature_name); - if (MessageBoxU(hDlg, lmprintf(MSG_285, signature_name), lmprintf(MSG_283), - MB_YESNO | MB_ICONWARNING | MB_IS_RTL) != IDYES) + if (MessageBoxExU(hDlg, lmprintf(MSG_285, signature_name), lmprintf(MSG_283), + MB_YESNO | MB_ICONWARNING | MB_IS_RTL, selected_langid) != IDYES) return TRUST_E_EXPLICIT_DISTRUST; } diff --git a/src/rufus.c b/src/rufus.c index 64a2db98..92db7d83 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -134,6 +134,7 @@ char* image_path = NULL; float fScale = 1.0f; int default_fs; uint32_t dur_mins, dur_secs; +WORD selected_langid = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT); HWND hDeviceList, hPartitionScheme, hFileSystem, hClusterSize, hLabel, hBootType, hNBPasses, hLog = NULL; HWND hLogDlg = NULL, hProgress = NULL, hInfo, hDiskID, hStatusToolbar; BOOL use_own_c32[NB_OLD_C32] = {FALSE, FALSE}, mbr_selected_by_user = FALSE, togo_mode; @@ -629,7 +630,7 @@ static void SetTargetSystem(void) if (SelectedDrive.PartitionType == PARTITION_STYLE_GPT) { ts = 2; // GPT/UEFI } else if (SelectedDrive.has_protective_mbr || SelectedDrive.has_mbr_uefi_marker || ((img_report.has_efi) && - (!HAS_SYSLINUX(img_report)) && (!img_report.has_bootmgr) && (!IS_REACTOS(img_report)) && + (!HAS_SYSLINUX(img_report)) && (!img_report.has_bootmgr) && (!IS_REACTOS(img_report)) && (!img_report.has_kolibrios) && (!IS_GRUB(img_report)) && (!IS_WINPE(img_report.winpe))) ) { ts = 1; // MBR/UEFI } else { @@ -944,7 +945,8 @@ static void CALLBACK BlockingTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD // A write or close operation hasn't made any progress since our last check user_notified = TRUE; uprintf("Blocking I/O operation detected\n"); - MessageBoxU(hMainDialog, lmprintf(MSG_080), lmprintf(MSG_048), MB_OK|MB_ICONINFORMATION|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_080), lmprintf(MSG_048), + MB_OK|MB_ICONINFORMATION|MB_IS_RTL, selected_langid); } else { last_iso_blocking_status = iso_blocking_status; } @@ -1058,7 +1060,7 @@ DWORD WINAPI ISOScanThread(LPVOID param) PrintInfo(0, MSG_081); safe_free(image_path); EnableWindow(hStatusToolbar, FALSE); - MessageBoxU(hMainDialog, lmprintf(MSG_082), lmprintf(MSG_081), MB_OK|MB_ICONINFORMATION|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_082), lmprintf(MSG_081), MB_OK|MB_ICONINFORMATION|MB_IS_RTL, selected_langid); PrintStatus(0, MSG_086); SetMBRProps(); } else { @@ -1086,7 +1088,7 @@ DWORD WINAPI ISOScanThread(LPVOID param) // Lose the focus from Close and set it back to Start SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)hStart, TRUE); } - + // Need to invalidate as we may have changed the UI and may get artifacts if we don't // Oh and we need to invoke BOTH RedrawWindow() and InvalidateRect() because UI refresh // in the Microsoft worlds SUCKS!!!! (we may lose the disabled "Start" button otherwise) @@ -1230,7 +1232,7 @@ static void ToggleToGo(void) MoveCtrlY(hMainDialog, IDC_RUFUS_MBR, dialog_shift); MoveCtrlY(hMainDialog, IDC_DISK_ID, dialog_shift); ResizeMoveCtrl(hMainDialog, GetDlgItem(hMainDialog, IDS_FORMAT_OPTIONS_GRP), 0, 0, 0, (int)dialog_shift, fScale); - + #ifdef RUFUS_TEST MoveCtrlY(hMainDialog, IDC_TEST, dialog_shift); #endif @@ -1284,18 +1286,18 @@ static BOOL BootCheck(void) if ((bt == BT_ISO) || (bt == BT_IMG)) { if (image_path == NULL) { // Please click on the disc button to select a bootable ISO - MessageBoxU(hMainDialog, lmprintf(MSG_087), lmprintf(MSG_086), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_087), lmprintf(MSG_086), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } if ((size_check) && (img_report.projected_size > (uint64_t)SelectedDrive.DiskSize)) { // This ISO image is too big for the selected target - MessageBoxU(hMainDialog, lmprintf(MSG_089), lmprintf(MSG_088), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_089), lmprintf(MSG_088), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } if (bt == BT_IMG) { if (!img_report.is_bootable_img) // The selected image doesn't match the boot option selected. - MessageBoxU(hMainDialog, lmprintf(MSG_188), lmprintf(MSG_187), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_188), lmprintf(MSG_187), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return (img_report.is_bootable_img); } fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); @@ -1303,29 +1305,29 @@ static BOOL BootCheck(void) if ((togo_mode) && (Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) == BST_CHECKED)) { if (fs != FS_NTFS) { // Windows To Go only works for NTFS - MessageBoxU(hMainDialog, lmprintf(MSG_097, "Windows To Go"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_097, "Windows To Go"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } else if (SelectedDrive.Geometry.MediaType != FixedMedia) { if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT)) { // We're screwed since we need access to 2 partitions at the same time to set this, which // Windows can't do. Cue in Arthur's Theme: "♫ I know it's stupid... but it's true. ♫" - MessageBoxU(hMainDialog, lmprintf(MSG_198), lmprintf(MSG_190), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_198), lmprintf(MSG_190), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } // I never had any success with drives that have the REMOVABLE attribute set, no matter the // method or tool I tried. If you manage to get this working, I'd like to hear from you! - if (MessageBoxU(hMainDialog, lmprintf(MSG_098), lmprintf(MSG_190), MB_YESNO|MB_ICONWARNING|MB_IS_RTL) != IDYES) + if (MessageBoxExU(hMainDialog, lmprintf(MSG_098), lmprintf(MSG_190), MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid) != IDYES) return FALSE; } } else if (tt == TT_UEFI) { if (!img_report.has_efi) { // Unsupported ISO - MessageBoxU(hMainDialog, lmprintf(MSG_091), lmprintf(MSG_090), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_091), lmprintf(MSG_090), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } if (IS_WIN7_EFI(img_report) && (!WimExtractCheck())) { // Your platform cannot extract files from WIM archives => download 7-zip? - if (MessageBoxU(hMainDialog, lmprintf(MSG_102), lmprintf(MSG_101), MB_YESNO|MB_ICONERROR|MB_IS_RTL) == IDYES) + if (MessageBoxExU(hMainDialog, lmprintf(MSG_102), lmprintf(MSG_101), MB_YESNO|MB_ICONERROR|MB_IS_RTL, selected_langid) == IDYES) ShellExecuteA(hMainDialog, "open", SEVENZIP_URL, NULL, NULL, SW_SHOWNORMAL); return FALSE; } @@ -1333,16 +1335,16 @@ static BOOL BootCheck(void) || ((IS_FAT(fs)) && (!HAS_SYSLINUX(img_report)) && (!allow_dual_uefi_bios) && (!img_report.has_efi) && (!IS_REACTOS(img_report)) && (!img_report.has_kolibrios) && (!IS_GRUB(img_report))) ) { // Incompatible FS and ISO - MessageBoxU(hMainDialog, lmprintf(MSG_096), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_096), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } else if ((fs == FS_FAT16) && (img_report.has_kolibrios)) { // KolibriOS doesn't support FAT16 - MessageBoxU(hMainDialog, lmprintf(MSG_189), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_189), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } if ((IS_FAT(fs)) && (img_report.has_4GB_file)) { // This ISO image contains a file larger than 4GB file (FAT32) - MessageBoxU(hMainDialog, lmprintf(MSG_100), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_100), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } @@ -1371,8 +1373,8 @@ static BOOL BootCheck(void) } fclose(fd); } else { - r = MessageBoxU(hMainDialog, lmprintf(MSG_116, img_report.grub2_version, GRUB2_PACKAGE_VERSION), - lmprintf(MSG_115), MB_YESNOCANCEL|MB_ICONWARNING|MB_IS_RTL); + r = MessageBoxExU(hMainDialog, lmprintf(MSG_116, img_report.grub2_version, GRUB2_PACKAGE_VERSION), + lmprintf(MSG_115), MB_YESNOCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid); if (r == IDCANCEL) return FALSE; else if (r == IDYES) { @@ -1420,8 +1422,8 @@ static BOOL BootCheck(void) use_own_c32[i] = TRUE; } else { PrintInfo(0, MSG_204, old_c32_name[i]); - if (MessageBoxU(hMainDialog, lmprintf(MSG_084, old_c32_name[i], old_c32_name[i]), - lmprintf(MSG_083, old_c32_name[i]), MB_YESNO|MB_ICONWARNING|MB_IS_RTL) == IDYES) { + if (MessageBoxExU(hMainDialog, lmprintf(MSG_084, old_c32_name[i], old_c32_name[i]), + lmprintf(MSG_083, old_c32_name[i]), MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDYES) { static_sprintf(tmp, "%s-%s", syslinux, embedded_sl_version_str[0]); IGNORE_RETVAL(_mkdir(tmp)); static_sprintf(tmp, "%s/%s-%s/%s", FILES_URL, syslinux, embedded_sl_version_str[0], old_c32_name[i]); @@ -1458,9 +1460,9 @@ static BOOL BootCheck(void) ldlinux, ldlinux_ext[0], ldlinux, ldlinux_ext[1], FILES_DIR, syslinux, img_report.sl_version_str, img_report.sl_version_ext); } else { - r = MessageBoxU(hMainDialog, lmprintf(MSG_114, img_report.sl_version_str, img_report.sl_version_ext, + r = MessageBoxExU(hMainDialog, lmprintf(MSG_114, img_report.sl_version_str, img_report.sl_version_ext, embedded_sl_version_str[1], embedded_sl_version_ext[1]), - lmprintf(MSG_115), MB_YESNO|MB_ICONWARNING|MB_IS_RTL); + lmprintf(MSG_115), MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid); if (r != IDYES) return FALSE; for (i=0; i<2; i++) { @@ -1487,7 +1489,7 @@ static BOOL BootCheck(void) if (syslinux_ldlinux_len[i] != 0) { // Duplicate the file so that the user won't be prompted to download again static_sprintf(tmp, "%s-%s\\%s.%s", syslinux, img_report.sl_version_str, ldlinux, ldlinux_ext[i]); - static_sprintf(tmp2, "%s-%s\\%s\\%s.%s", syslinux, img_report.sl_version_str, + static_sprintf(tmp2, "%s-%s\\%s\\%s.%s", syslinux, img_report.sl_version_str, &img_report.sl_version_ext[1], ldlinux, ldlinux_ext[i]); CopyFileA(tmp, tmp2, FALSE); } @@ -1513,8 +1515,8 @@ static BOOL BootCheck(void) static_sprintf(tmp, "%s.%s", ldlinux, ldlinux_ext[2]); PrintInfo(0, MSG_206, tmp); // MSG_104: "Syslinux v5.0 or later requires a '%s' file to be installed" - r = MessageBoxU(hMainDialog, lmprintf(MSG_104, "Syslinux v5.0", tmp, "Syslinux v5+", tmp), - lmprintf(MSG_103, tmp), MB_YESNOCANCEL|MB_ICONWARNING|MB_IS_RTL); + r = MessageBoxExU(hMainDialog, lmprintf(MSG_104, "Syslinux v5.0", tmp, "Syslinux v5+", tmp), + lmprintf(MSG_103, tmp), MB_YESNOCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid); if (r == IDCANCEL) return FALSE; if (r == IDYES) { @@ -1529,7 +1531,7 @@ static BOOL BootCheck(void) } else if (bt == BT_MSDOS) { if ((size_check) && (ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize)) >= 65536)) { // MS-DOS cannot boot from a drive using a 64 kilobytes Cluster size - MessageBoxU(hMainDialog, lmprintf(MSG_110), lmprintf(MSG_111), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_110), lmprintf(MSG_111), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } } else if (bt == BT_GRUB4DOS) { @@ -1544,8 +1546,8 @@ static BOOL BootCheck(void) } else { static_sprintf(tmp, "grldr"); PrintInfo(0, MSG_206, tmp); - r = MessageBoxU(hMainDialog, lmprintf(MSG_104, "Grub4DOS 0.4", tmp, "Grub4DOS", tmp), - lmprintf(MSG_103, tmp), MB_YESNOCANCEL|MB_ICONWARNING|MB_IS_RTL); + r = MessageBoxExU(hMainDialog, lmprintf(MSG_104, "Grub4DOS 0.4", tmp, "Grub4DOS", tmp), + lmprintf(MSG_103, tmp), MB_YESNOCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid); if (r == IDCANCEL) return FALSE; if (r == IDYES) { @@ -1561,7 +1563,7 @@ static BOOL BootCheck(void) } else if (bt == BT_UEFI_NTFS) { fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); if (fs != FS_NTFS) { - MessageBoxU(hMainDialog, lmprintf(MSG_097, "UEFI:NTFS"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_097, "UEFI:NTFS"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } } @@ -1743,7 +1745,7 @@ void InitDialog(HWND hDlg) IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_095)), BT_IMG)); SetComboEntry(hBootType, selection_default); // Fill up the MBR masqueraded disk IDs ("8 disks should be enough for anybody") - IGNORE_RETVAL(ComboBox_SetItemData(hDiskID, ComboBox_AddStringU(hDiskID, lmprintf(MSG_030, LEFT_TO_RIGHT_MARK "0x80")), 0x80)); + IGNORE_RETVAL(ComboBox_SetItemData(hDiskID, ComboBox_AddStringU(hDiskID, lmprintf(MSG_030, LEFT_TO_RIGHT_EMBEDDING "0x80" POP_DIRECTIONAL_FORMATTING)), 0x80)); for (i=1; i<=7; i++) { IGNORE_RETVAL(ComboBox_SetItemData(hDiskID, ComboBox_AddStringU(hDiskID, lmprintf(MSG_109, 0x80+i, i+1)), 0x80+i)); } @@ -1794,7 +1796,7 @@ void InitDialog(HWND hDlg) tbLangToolbarButtons[0].fsState = TBSTATE_ENABLED; SendMessage(hLangToolbar, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&tbLangToolbarButtons); // Add just the 1 button SendMessage(hLangToolbar, TB_GETRECT, lang_button_id, (LPARAM)&rcToolbarButton); - + // Make the toolbar window just big enough to hold the button // Set the top margin to 4 DIPs and the right margin so that it's aligned with the Device List Combobox GetWindowRect(hDeviceList, &rcDeviceList); @@ -1919,7 +1921,7 @@ void ShowLanguageMenu(RECT rcExclude) str = safe_strdup(lcmd->txt[1]); l = strtok(str, search); r = strtok(NULL, search); - static_sprintf(lang, LEFT_TO_RIGHT_MARK "(%s) " LEFT_TO_RIGHT_MARK "%s", r, l); + static_sprintf(lang, LEFT_TO_RIGHT_EMBEDDING "(%s) " POP_DIRECTIONAL_FORMATTING "%s", r, l); safe_free(str); } else { safe_strcpy(lang, sizeof(lang), lcmd->txt[1]); @@ -2051,6 +2053,7 @@ void SaveVHD(void) } } + /* * Main dialog callback */ @@ -2186,6 +2189,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if (i++ == selected_language) { if (selected_locale != lcmd) { selected_locale = lcmd; + selected_langid = get_language_id(lcmd); relaunch = TRUE; PostMessage(hDlg, WM_COMMAND, IDCANCEL, 0); } @@ -2199,8 +2203,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA PF_INIT(SHChangeNotifyDeregister, Shell32); EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE); if (format_thid != NULL) { - if ((no_confirmation_on_cancel) || (MessageBoxU(hMainDialog, lmprintf(MSG_105), lmprintf(MSG_049), - MB_YESNO|MB_ICONWARNING|MB_IS_RTL) == IDYES)) { + if ((no_confirmation_on_cancel) || (MessageBoxExU(hMainDialog, lmprintf(MSG_105), lmprintf(MSG_049), + MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDYES)) { // Operation may have completed in the meantime if (format_thid != NULL) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED; @@ -2246,7 +2250,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA Point.x = max(DialogRect.left - offset - nWidth, 0); else Point.x = min(DialogRect.right + offset, DesktopRect.right - nWidth); - + Point.y = max(DialogRect.top, DesktopRect.top - nHeight); MoveWindow(hLogDlg, Point.x, Point.y, nWidth, nHeight, FALSE); // The log may have been recentered to fit the screen, in which case, try to shift our main dialog left (or right for RTL) @@ -2463,7 +2467,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if (dur_secs > UDF_FORMAT_WARN) { dur_mins = dur_secs/60; dur_secs -= dur_mins*60; - MessageBoxU(hMainDialog, lmprintf(MSG_112, dur_mins, dur_secs), lmprintf(MSG_113), MB_OK|MB_ICONASTERISK|MB_IS_RTL); + MessageBoxExU(hMainDialog, lmprintf(MSG_112, dur_mins, dur_secs), lmprintf(MSG_113), + MB_OK|MB_ICONASTERISK|MB_IS_RTL, selected_langid); } else { dur_secs = 0; dur_mins = 0; @@ -2487,19 +2492,19 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA } GetWindowTextU(hDeviceList, tmp, ARRAYSIZE(tmp)); - if (MessageBoxU(hMainDialog, lmprintf(MSG_003, tmp), - APPLICATION_NAME, MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL) == IDCANCEL) { + if (MessageBoxExU(hMainDialog, lmprintf(MSG_003, tmp), + APPLICATION_NAME, MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL) { format_op_in_progress = FALSE; break; } - if ((SelectedDrive.nPartitions > 1) && (MessageBoxU(hMainDialog, lmprintf(MSG_093), - lmprintf(MSG_094), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL) == IDCANCEL)) { + if ((SelectedDrive.nPartitions > 1) && (MessageBoxExU(hMainDialog, lmprintf(MSG_093), + lmprintf(MSG_094), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) { format_op_in_progress = FALSE; break; } - if ((IsChecked(IDC_BOOT)) && (SelectedDrive.Geometry.BytesPerSector != 512) && - (MessageBoxU(hMainDialog, lmprintf(MSG_196, SelectedDrive.Geometry.BytesPerSector), - lmprintf(MSG_197), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL) == IDCANCEL)) { + if ((IsChecked(IDC_BOOT)) && (SelectedDrive.Geometry.BytesPerSector != 512) && + (MessageBoxExU(hMainDialog, lmprintf(MSG_196, SelectedDrive.Geometry.BytesPerSector), + lmprintf(MSG_197), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) { format_op_in_progress = FALSE; break; } @@ -2561,7 +2566,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA switch (((LPNMHDR)lParam)->code) { case TBN_DROPDOWN: lpnmtb = (LPNMTOOLBAR)lParam; - + // We only care about the language button on the language toolbar if (lpnmtb->hdr.hwndFrom == hLangToolbar && lpnmtb->iItem == lang_button_id) { @@ -2597,7 +2602,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA } SetTaskbarProgressState(TASKBAR_NORMAL); SetTaskbarProgressValue(0, MAX_PROGRESS); - + break; case UM_PROGRESS_EXIT: @@ -2853,7 +2858,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // Sysnative and System32 are the same safe_strcpy(sysnative_dir, sizeof(sysnative_dir), system_dir); // But if the app is 32 bit and the OS is 64 bit, Sysnative must differ from System32 -#if (!defined(_WIN64) && !defined(BUILD64)) +#if (!defined(_WIN64) && !defined(BUILD64)) if (is_x64()) { if (GetSystemWindowsDirectoryU(sysnative_dir, sizeof(sysnative_dir)) == 0) { uprintf("Could not get Windows directory: %s", WindowsErrorString()); @@ -2897,6 +2902,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // Init localization init_localization(); + // Seek for a loc file in the current directory if (GetFileAttributesU(rufus_loc) == INVALID_FILE_ATTRIBUTES) { uprintf("loc file not found in current directory - embedded one will be used"); @@ -2928,9 +2934,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine || ((selected_locale = ((locale_name == NULL)?get_locale_from_lcid(lcid, TRUE):get_locale_from_name(locale_name, TRUE))) == NULL) ) { uprintf("FATAL: Could not access locale!\n"); MessageBoxU(NULL, "The locale data is missing or invalid. This application will now exit.", - "Fatal error", MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL); + "Fatal error", MB_ICONSTOP|MB_SYSTEMMODAL); goto out; } + selected_langid = get_language_id(selected_locale); // Prevent 2 applications from running at the same time, unless "/W" is passed as an option // in which case we wait for the mutex to be relinquished @@ -2945,8 +2952,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine if ((mutex == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS)) { // Load the translation before we print the error get_loc_data_file(loc_file, selected_locale); + right_to_left_mode = ((selected_locale->ctrl_id) & LOC_RIGHT_TO_LEFT); // Set MB_SYSTEMMODAL to prevent Far Manager from stealing focus... - MessageBoxU(NULL, lmprintf(MSG_002), lmprintf(MSG_001), MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL); + MessageBoxExU(NULL, lmprintf(MSG_002), lmprintf(MSG_001), MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL, selected_langid); goto out; } @@ -2993,7 +3001,8 @@ relaunch: */ hDlg = MyCreateDialog(hInstance, IDD_DIALOG, NULL, MainCallback); if (hDlg == NULL) { - MessageBoxU(NULL, "Could not create Window", "DialogBox failure", MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL); + MessageBoxExU(NULL, "Could not create Window", "DialogBox failure", + MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL, selected_langid); goto out; } if ((relaunch_rc.left > -65536) && (relaunch_rc.top > -65536)) @@ -3005,7 +3014,7 @@ relaunch: while(GetMessage(&msg, NULL, 0, 0)) { // Ctrl-A => Select the log data - if ( (IsWindowVisible(hLogDlg)) && (GetKeyState(VK_CONTROL) & 0x8000) && + if ( (IsWindowVisible(hLogDlg)) && (GetKeyState(VK_CONTROL) & 0x8000) && (msg.message == WM_KEYDOWN) && (msg.wParam == 'A') ) { // Might also need ES_NOHIDESEL property if you want to select when not active SendMessage(hLog, EM_SETSEL, 0, -1); diff --git a/src/rufus.h b/src/rufus.h index 03309df6..9f248c84 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -41,8 +41,12 @@ #define APPLICATION_NAME "Rufus" #define COMPANY_NAME "Akeo Consulting" #define STR_NO_LABEL "NO_LABEL" -#define LEFT_TO_RIGHT_MARK "‎" // Yes, there is a character between the quotes! -#define RIGHT_TO_LEFT_MARK "‏" // Yes, there is a character between the quotes! +// Yes, there is a character between these seemingly empty quotes! +#define LEFT_TO_RIGHT_MARK "‎" +#define RIGHT_TO_LEFT_MARK "‏" +#define LEFT_TO_RIGHT_EMBEDDING "‪" +#define RIGHT_TO_LEFT_EMBEDDING "‫" +#define POP_DIRECTIONAL_FORMATTING "‬" #define DRIVE_ACCESS_TIMEOUT 15000 // How long we should retry drive access (in ms) #define DRIVE_ACCESS_RETRIES 60 // How many times we should retry #define DRIVE_INDEX_MIN 0x00000080 @@ -81,7 +85,7 @@ #define STRINGIFY(x) #x #endif #define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED) -#define MB_IS_RTL (right_to_left_mode?MB_RTLREADING:0) +#define MB_IS_RTL (right_to_left_mode?MB_RTLREADING|MB_RIGHT:0) #define CHECK_FOR_USER_CANCEL if (IS_ERROR(FormatStatus)) goto out #define safe_free(p) do {free((void*)p); p = NULL;} while(0) @@ -317,7 +321,7 @@ typedef struct ext_t { } ext_t; #ifndef __VA_GROUP__ -#define __VA_GROUP__(...) __VA_ARGS__ +#define __VA_GROUP__(...) __VA_ARGS__ #endif #define EXT_X(prefix, ...) const char* _##prefix##_x[] = { __VA_ARGS__ } #define EXT_D(prefix, ...) const char* _##prefix##_d[] = { __VA_ARGS__ } @@ -377,6 +381,7 @@ extern char WindowsVersionStr[128]; extern char embedded_sl_version_str[2][12]; extern RUFUS_UPDATE update; extern int dialog_showing; +extern WORD selected_langid; /* * Shared prototypes diff --git a/src/rufus.rc b/src/rufus.rc index 6365745a..229481f6 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 2.5.779" +CAPTION "Rufus 2.5.780" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -319,8 +319,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,5,779,0 - PRODUCTVERSION 2,5,779,0 + FILEVERSION 2,5,780,0 + PRODUCTVERSION 2,5,780,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -337,13 +337,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.5.779" + VALUE "FileVersion", "2.5.780" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", " 2011-2015 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.5.779" + VALUE "ProductVersion", "2.5.780" END END BLOCK "VarFileInfo" diff --git a/src/stdlg.c b/src/stdlg.c index 21f7b4d8..f262bc79 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -469,8 +469,8 @@ void CreateStatusBar(void) SendMessage(hStatusToolbar, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hStatusToolbar, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_MIXEDBUTTONS); SendMessage(hStatusToolbar, TB_SETIMAGELIST, 0, (LPARAM)NULL); - SendMessage(hStatusToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)NULL); - SendMessage(hStatusToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(0,0)); + SendMessage(hStatusToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)NULL); + SendMessage(hStatusToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(0,0)); // Set our text memset(tbbStatusToolbarButtons, 0, sizeof(TBBUTTON)); @@ -1094,7 +1094,7 @@ BOOL IsShown(HWND hDlg) /* Compute the width of a dropdown list entry */ LONG GetEntryWidth(HWND hDropDown, const char *entry) -{ +{ HDC hDC; HFONT hFont, hDefFont = NULL; SIZE size; @@ -1103,7 +1103,7 @@ LONG GetEntryWidth(HWND hDropDown, const char *entry) hFont = (HFONT)SendMessage(hDropDown, WM_GETFONT, 0, 0); if (hFont != NULL) hDefFont = (HFONT)SelectObject(hDC, hFont); - + if (!GetTextExtentPointU(hDC, entry, &size)) size.cx = 0; @@ -1193,9 +1193,9 @@ DECLARE_INTERFACE_(my_ITaskbarList3, IUnknown) { STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE; STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE; }; -const IID my_IID_ITaskbarList3 = +const IID my_IID_ITaskbarList3 = { 0xea1afb91, 0x9e28, 0x4b86, { 0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf } }; -const IID my_CLSID_TaskbarList = +const IID my_CLSID_TaskbarList = { 0x56fdf344, 0xfd6d, 0x11d0, { 0x95, 0x8a ,0x0, 0x60, 0x97, 0xc9, 0xa0 ,0x90 } }; static my_ITaskbarList3* ptbl = NULL; @@ -1299,7 +1299,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l GetWindowRect(hPolicy, &rect); dy = rect.bottom - rect.top; rsz = (REQRESIZE *)lParam; - dy -= rsz->rc.bottom - rsz->rc.top + 6; // add the border + dy -= rsz->rc.bottom - rsz->rc.top + 6; // add the border ResizeMoveCtrl(hDlg, hDlg, 0, 0, 0, -dy, 1.0f); ResizeMoveCtrl(hDlg, hPolicy, 0, 0, 0, -dy, 1.0f); ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDS_UPDATE_SETTINGS_GRP), 0, -dy, 0, 0, 1.0f); @@ -1458,7 +1458,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR SendMessageA(hNotes, EM_SETTEXTEX, (WPARAM)&friggin_microsoft_unicode_amateurs, (LPARAM)update.release_notes); SendMessage(hNotes, EM_SETSEL, -1, -1); SendMessage(hNotes, EM_SETEVENTMASK, 0, ENM_LINK); - SetWindowTextU(GetDlgItem(hDlg, IDC_YOUR_VERSION), lmprintf(MSG_018, + SetWindowTextU(GetDlgItem(hDlg, IDC_YOUR_VERSION), lmprintf(MSG_018, rufus_version[0], rufus_version[1], rufus_version[2])); SetWindowTextU(GetDlgItem(hDlg, IDC_LATEST_VERSION), lmprintf(MSG_019, update.version[0], update.version[1], update.version[2]));