Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Sources/FoundationEssentials/WinSDK+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down