diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift index 118712a64..b2666ccbc 100644 --- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift @@ -448,8 +448,8 @@ extension _FileManagerImpl { func isExecutableFile(atPath path: String) -> Bool { #if os(Windows) return (try? path.withNTPathRepresentation { - var dwBinaryType: DWORD = 0 - return GetBinaryTypeW($0, &dwBinaryType) + // Use SHGetFileInfo instead of GetBinaryType because the latter returns the wrong answer for x86 binaries running under emulation on ARM systems. + return (SHGetFileInfoW($0, 0, nil, 0, SHGFI_EXETYPE) & 0xFFFF) != 0 }) ?? false #else _fileAccessibleForMode(path, X_OK) diff --git a/Sources/FoundationEssentials/WinSDK+Extensions.swift b/Sources/FoundationEssentials/WinSDK+Extensions.swift index 35e0d155c..f0eb3ed95 100644 --- a/Sources/FoundationEssentials/WinSDK+Extensions.swift +++ b/Sources/FoundationEssentials/WinSDK+Extensions.swift @@ -229,6 +229,10 @@ package var RRF_RT_REG_SZ: DWORD { DWORD(WinSDK.RRF_RT_REG_SZ) } +package var SHGFI_EXETYPE: UINT { + UINT(WinSDK.SHGFI_EXETYPE) +} + package var SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE: DWORD { DWORD(WinSDK.SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE) }