Skip to content

Commit

Permalink
Update SystemInfoHelper.Windows.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Oct 11, 2023
1 parent dcb5949 commit 1b20335
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.System.SystemInformation;
Expand Down Expand Up @@ -262,8 +263,16 @@ public static unsafe bool IsRunningUnderTranslation(Process? proc = null)
&nativeMachine);

if (!result) return false;
if (processMachine == IMAGE_FILE_MACHINE.IMAGE_FILE_MACHINE_UNKNOWN) return false;

return processMachine != nativeMachine;
var nativeArch = nativeMachine switch
{
IMAGE_FILE_MACHINE.IMAGE_FILE_MACHINE_AMD64 => Architecture.X64,
IMAGE_FILE_MACHINE.IMAGE_FILE_MACHINE_ARM64 => Architecture.Arm64,
IMAGE_FILE_MACHINE.IMAGE_FILE_MACHINE_ARMNT => Architecture.Arm64,
IMAGE_FILE_MACHINE.IMAGE_FILE_MACHINE_I386 => Architecture.X86,
_ => throw new ArgumentException($"Unknown System Arch [{nativeMachine}]")
};

return nativeArch != RuntimeInformation.OSArchitecture;
}
}

0 comments on commit 1b20335

Please sign in to comment.