diff --git a/src/rufus.c b/src/rufus.c index a4990e3b..a00abf8c 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -1894,14 +1894,49 @@ static __inline const char* IsAlphaOrBeta(void) #endif } +static __inline DWORD GetApplicationArch(void) +{ +#if defined(_M_AMD64) + return IMAGE_FILE_MACHINE_AMD64; +#elif defined(_M_IX86) + return IMAGE_FILE_MACHINE_I386; +#elif defined(_M_ARM64) + return IMAGE_FILE_MACHINE_ARM64; +#elif defined(_M_ARM) + return IMAGE_FILE_MACHINE_ARM; +#else + return IMAGE_FILE_MACHINE_UNKNOWN; +#endif +} + +static const char* GetArchName(USHORT uArch) +{ + switch (uArch) { + case IMAGE_FILE_MACHINE_AMD64: + return "x64"; + case IMAGE_FILE_MACHINE_I386: + return "x86"; + case IMAGE_FILE_MACHINE_ARM64: + return "Arm64"; + case IMAGE_FILE_MACHINE_ARM: + return "Arm"; + default: + return "(Unknown Arch)"; + } +} + static void InitDialog(HWND hDlg) { DWORD len; HDC hDC; + USHORT ProcessMachine = IMAGE_FILE_MACHINE_UNKNOWN, NativeMachine = IMAGE_FILE_MACHINE_UNKNOWN; int i, lfHeight; char tmp[128], *token, *buf, *ext, *msg; static char* resource[2] = { MAKEINTRESOURCEA(IDR_SL_LDLINUX_V4_SYS), MAKEINTRESOURCEA(IDR_SL_LDLINUX_V6_SYS) }; + PF_TYPE_DECL(WINAPI, BOOL, IsWow64Process2, (HANDLE, USHORT*, USHORT*)); + PF_INIT(IsWow64Process2, Kernel32); + #ifdef RUFUS_TEST ShowWindow(GetDlgItem(hDlg, IDC_TEST), SW_SHOW); #endif @@ -1987,6 +2022,16 @@ static void InitDialog(HWND hDlg) } uprintf(APPLICATION_NAME " " APPLICATION_ARCH " v%d.%d.%d%s%s", rufus_version[0], rufus_version[1], rufus_version[2], IsAlphaOrBeta(), (ini_file != NULL)?"(Portable)": (appstore_version ? "(AppStore version)" : "")); + // Display a notice if running x86 emulation on ARM + // Oh, and https://devblogs.microsoft.com/oldnewthing/20220209-00/?p=106239 is *WRONG*: + // Get­Native­System­Info() will not tell you what the native system architecture is when + // running x86 code on ARM64. Instead you have to use IsWow64Process2(), which is only + // available on Windows 10 1511 or later... + if ((pfIsWow64Process2 != NULL) && pfIsWow64Process2(GetCurrentProcess(), &ProcessMachine, &NativeMachine)) { + if ((NativeMachine == IMAGE_FILE_MACHINE_ARM || NativeMachine == IMAGE_FILE_MACHINE_ARM64) && + (ProcessMachine == IMAGE_FILE_MACHINE_I386 || ProcessMachine == IMAGE_FILE_MACHINE_I386)) + uprintf("Notice: Running emulated on %s platform", GetArchName(NativeMachine)); + } for (i = 0; i < ARRAYSIZE(resource); i++) { len = 0; buf = (char*)GetResource(hMainInstance, resource[i], _RT_RCDATA, "ldlinux_sys", &len, TRUE); diff --git a/src/rufus.rc b/src/rufus.rc index a69f6a2f..5023392b 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.22.1980" +CAPTION "Rufus 3.22.1981" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,22,1980,0 - PRODUCTVERSION 3,22,1980,0 + FILEVERSION 3,22,1981,0 + PRODUCTVERSION 3,22,1981,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.22.1980" + VALUE "FileVersion", "3.22.1981" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.22.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.22.1980" + VALUE "ProductVersion", "3.22.1981" END END BLOCK "VarFileInfo" diff --git a/src/smart.c b/src/smart.c index 1aa2e19a..03525d7c 100644 --- a/src/smart.c +++ b/src/smart.c @@ -440,8 +440,8 @@ BOOL SmartGetVersion(HANDLE hdevice) */ int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid) { - int score = 0, score_list_size = 0; - size_t i, mlen, ilen; + int score = 0; + size_t i, mlen, ilen, score_list_size = 0; BOOL wc; uint64_t drive_size; int8_t score_list[16];