diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs b/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs index 661ddc5e..f251057a 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs @@ -9,12 +9,11 @@ using System.Threading.Tasks.Dataflow; using ProjBobcat.Class.Helper; using ProjBobcat.Class.Model; -using ProjBobcat.DefaultComponent.ResourceInfoResolver; using ProjBobcat.Event; using ProjBobcat.Interface; namespace ProjBobcat.DefaultComponent; -#nullable enable + /// /// 默认的资源补全器 /// diff --git a/ProjBobcat/ProjBobcat/NativeMethods.txt b/ProjBobcat/ProjBobcat/NativeMethods.txt index ef99a070..25cb48f8 100644 --- a/ProjBobcat/ProjBobcat/NativeMethods.txt +++ b/ProjBobcat/ProjBobcat/NativeMethods.txt @@ -1 +1,2 @@ -SetWindowText \ No newline at end of file +SetWindowText +IsWow64Process2 \ No newline at end of file diff --git a/ProjBobcat/ProjBobcat/Platforms/Windows/SystemInfoHelper.Windows.cs b/ProjBobcat/ProjBobcat/Platforms/Windows/SystemInfoHelper.Windows.cs index ffdbe0db..4169ef15 100644 --- a/ProjBobcat/ProjBobcat/Platforms/Windows/SystemInfoHelper.Windows.cs +++ b/ProjBobcat/ProjBobcat/Platforms/Windows/SystemInfoHelper.Windows.cs @@ -2,6 +2,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using Windows.Win32; +using Windows.Win32.Foundation; +using Windows.Win32.System.SystemInformation; using Microsoft.Win32; using ProjBobcat.Class.Model; @@ -229,4 +232,38 @@ public static IEnumerable GetLogicalDrives() { return Environment.GetLogicalDrives(); } + + public static bool IsWindows7() + { + var os = Environment.OSVersion; + + return os is { Platform: PlatformID.Win32NT, Version: { Major: 6, Minor: 1 } }; + } + + /// + /// 检查某个进程是否运行在 X86 模拟下 + /// + /// + /// 待检查的进程,如果不传则检测当前进程 + public static unsafe bool IsRunningUnderTranslation(Process? proc = null) + { + if (IsWindows7()) return false; + + proc ??= Process.GetCurrentProcess(); + + var handle = proc.Handle; + + IMAGE_FILE_MACHINE processMachine; + IMAGE_FILE_MACHINE nativeMachine; + + var result = PInvoke.IsWow64Process2( + new HANDLE(handle), + &processMachine, + &nativeMachine); + + if (!result) return false; + if (processMachine == IMAGE_FILE_MACHINE.IMAGE_FILE_MACHINE_UNKNOWN) return false; + + return processMachine != nativeMachine; + } } diff --git a/ProjBobcat/ProjBobcat/ProjBobcat.csproj b/ProjBobcat/ProjBobcat/ProjBobcat.csproj index ddc2600c..bd381f77 100644 --- a/ProjBobcat/ProjBobcat/ProjBobcat.csproj +++ b/ProjBobcat/ProjBobcat/ProjBobcat.csproj @@ -95,9 +95,6 @@ resolved the issue that LaunchWrapper may not return the correct exit code - - all - 0.34.1 @@ -106,6 +103,9 @@ resolved the issue that LaunchWrapper may not return the correct exit code + + all +