1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[misc] report if running x86 emulation on ARM

* Also fix a static analysis warning.
This commit is contained in:
Pete Batard 2023-02-26 22:10:22 +00:00
parent 4e8375c73c
commit aed34ca635
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
3 changed files with 52 additions and 7 deletions

View file

@ -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);

View file

@ -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"

View file

@ -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];