diff --git a/.gitignore b/.gitignore index 6950e2a00..e2cdd7f25 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ bld/ # Visual Studio 2015/2017 cache/options directory .vs/ +.vscode/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index f980ab98c..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - // 使用 IntelliSense 了解相关属性。 - // 悬停以查看现有属性的描述。 - // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [] -} \ No newline at end of file diff --git a/WattToolkit.slnx b/WattToolkit.slnx index c6054a907..29e55ca14 100644 --- a/WattToolkit.slnx +++ b/WattToolkit.slnx @@ -116,7 +116,6 @@ - diff --git a/ref/Common b/ref/Common index baf1832b2..818b673ab 160000 --- a/ref/Common +++ b/ref/Common @@ -1 +1 @@ -Subproject commit baf1832b2e26a8a328abfe2d99fc3909a28d90a4 +Subproject commit 818b673aba6a1c0b0e85616fea1fbbcffdea6469 diff --git a/src/AssemblyInfo.Constants.cs b/src/AssemblyInfo.Constants.cs index 14d60ea16..ca9e38cae 100644 --- a/src/AssemblyInfo.Constants.cs +++ b/src/AssemblyInfo.Constants.cs @@ -13,7 +13,9 @@ public static partial class AssemblyInfo /// public const string Version = $"{Version2}.{VersionBuild}"; - const string VersionBuild = "1"; + const string VersionBuild = "1"; // 1~99 + + const string VersionBuild2 = $"{VersionBuild}0"; // VersionBuild为1位时,补0,两位 /// /// 预览版本号,范围 1~9,只增不减 @@ -25,7 +27,7 @@ public static partial class AssemblyInfo /// const string ver_for_rc = "0"; - public const string FileVersion = $"{Version2}.2{ver_for_rc}2{ver_for_preview}.0"; // msix 需要保持第四位为0 + public const string FileVersion = $"{Version2}.{VersionBuild2}{ver_for_rc}0{ver_for_preview}.0"; // msix 需要保持第四位为0 public const string InformationalVersion = Version; //public const string InformationalVersion = $"{Version}-preview.{ver_for_preview}"; @@ -65,6 +67,8 @@ public static partial class AssemblyInfo /// public const string Product = Trademark; + public const string Product_APP_REVERSE_PROXY = $"{Product} - Accelerator and script module sub-process"; + /// /// 与该应用程序关联的公司名称。 /// @@ -148,4 +152,37 @@ false #endif + /// + /// 验证程序集是否为合法程序集 + /// + /// + /// + public static bool ValidateAssembly(string assemblyPath) + { + var fvi = FileVersionInfo.GetVersionInfo(assemblyPath); + if (fvi.Comments != Description) + { + return false; + } + else if (fvi.CompanyName != Company) + { + return false; + } + else if (fvi.LegalCopyright != Copyright) + { + return false; + } + else if (fvi.LegalTrademarks != Trademark) + { + return false; + } + else if (fvi.ProductName != Product && fvi.ProductName != Product_APP_REVERSE_PROXY) + { + return false; + } + + // TODO: Digital signature verification + return true; + } + } \ No newline at end of file diff --git a/src/AssemblyInfo.cs b/src/AssemblyInfo.cs index 4fde1ebd9..f798a5399 100644 --- a/src/AssemblyInfo.cs +++ b/src/AssemblyInfo.cs @@ -27,7 +27,7 @@ using AssemblyInfo = BD.WTTS.AssemblyInfo; [assembly: AssemblyTrademark(AssemblyInfo.Trademark)] [assembly: AssemblyDescription(AssemblyInfo.Description)] #if APP_REVERSE_PROXY -[assembly: AssemblyProduct($"{AssemblyInfo.Product} - Accelerator and script module sub-process")] +[assembly: AssemblyProduct(AssemblyInfo.Product_APP_REVERSE_PROXY)] #else [assembly: AssemblyProduct(AssemblyInfo.Product)] #endif diff --git a/src/BD.WTTS.Client.AppHost.Bridge/App.config b/src/BD.WTTS.Client.AppHost.Bridge/App.config index 048a6a7d2..6dd0cf5c8 100644 --- a/src/BD.WTTS.Client.AppHost.Bridge/App.config +++ b/src/BD.WTTS.Client.AppHost.Bridge/App.config @@ -9,6 +9,6 @@ - + \ No newline at end of file diff --git a/src/BD.WTTS.Client.AppHost/App.config b/src/BD.WTTS.Client.AppHost/App.config index 3ec9176de..2deca9b16 100644 --- a/src/BD.WTTS.Client.AppHost/App.config +++ b/src/BD.WTTS.Client.AppHost/App.config @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/src/BD.WTTS.Client.AppHost/Program.cs b/src/BD.WTTS.Client.AppHost/Program.cs index e238d2b55..ac2691ed7 100644 --- a/src/BD.WTTS.Client.AppHost/Program.cs +++ b/src/BD.WTTS.Client.AppHost/Program.cs @@ -5,6 +5,7 @@ #if NETFRAMEWORK using System.Configuration; +using System.Diagnostics; #endif using static BD.WTTS.AssemblyInfo; using static BD.WTTS.Client.Resources.Strings; @@ -19,11 +20,12 @@ static unsafe partial class Program dotnet_version_major = "11"; dotnet_version_minor = "0"; dotnet_version_build = "0"; - dotnet_version = $"{dotnet_version_major}.{dotnet_version_minor}.{dotnet_version_build}"; + dotnet_version_preOrRcString = "-preview.7.26381.103"; // -字符开头! + dotnet_version = $"{dotnet_version_major}.{dotnet_version_minor}.{dotnet_version_build}{dotnet_version_preOrRcString}"; } //#if NETFRAMEWORK - public static string dotnet_version_major, dotnet_version_minor, dotnet_version_build, dotnet_version; + public static string dotnet_version_major, dotnet_version_minor, dotnet_version_build, dotnet_version, dotnet_version_preOrRcString; //#else // public const string dotnet_version_major = "7"; // public const string dotnet_version_minor = "0"; @@ -239,7 +241,7 @@ static unsafe partial class Program #if NETFRAMEWORK try { - var dotnet_version_ = ConfigurationManager.AppSettings["d"]; + var dotnet_version_ = ConfigurationManager.AppSettings["d"]; // 由 App.config 中的配置键控制加载运行时版本 if (! #if !NET35 string. @@ -248,7 +250,7 @@ static unsafe partial class Program dotnet_version_.Length < sbyte.MaxValue) { var dotnet_version__ = dotnet_version_.Split('.'); - int major, minor, build; + int major, minor; switch (dotnet_version__.Length) { case 1: @@ -265,8 +267,17 @@ static unsafe partial class Program case 3: dotnet_version_major = (int.TryParse(dotnet_version__[0], out major) ? major : 0).ToString(); dotnet_version_minor = (int.TryParse(dotnet_version__[1], out minor) ? minor : 0).ToString(); - dotnet_version_build = (int.TryParse(dotnet_version__[2], out build) ? build : 0).ToString(); - dotnet_version = $"{dotnet_version_major}.{dotnet_version_minor}.{dotnet_version_build}"; + // 支持 PRE/RC 版本号 + string? preOrRcString = null; + var buildString = dotnet_version__[2]; + var index = buildString.IndexOf('-'); + if (index > 0) + { + preOrRcString = buildString.Substring(index); + buildString = buildString.Substring(0, index); + } + dotnet_version_build = (int.TryParse(buildString, out var build) ? build : 0).ToString(); + dotnet_version = $"{dotnet_version_major}.{dotnet_version_minor}.{dotnet_version_build}{preOrRcString}"; break; } } diff --git a/src/BD.WTTS.Client.IPC/Services.Implementation/IPCSubProcessServiceImpl.cs b/src/BD.WTTS.Client.IPC/Services.Implementation/IPCSubProcessServiceImpl.cs index b9da650d5..ad176af44 100644 --- a/src/BD.WTTS.Client.IPC/Services.Implementation/IPCSubProcessServiceImpl.cs +++ b/src/BD.WTTS.Client.IPC/Services.Implementation/IPCSubProcessServiceImpl.cs @@ -64,29 +64,43 @@ public sealed class IPCSubProcessServiceImpl : IPCSubProcessService internal static bool CheckBePid(Process proc) { - var procPath = Environment.ProcessPath; - ArgumentNullException.ThrowIfNullOrWhiteSpace(procPath); - procPath = Path.GetFullPath(procPath); - - var fn = proc.TryGetMainModule()?.FileName; - var fnPath = fn == null ? null : Path.GetFullPath(fn); - - if (procPath == fnPath) + if (proc.Id == Environment.ProcessId) { return true; } - var accProPath = Path.GetFullPath(Path.Combine(procPath, "..", "modules", "Accelerator", + var thisPath = Environment.ProcessPath; + ArgumentException.ThrowIfNullOrWhiteSpace(thisPath); + thisPath = Path.GetFullPath(thisPath); + + var procPath = proc.TryGetMainModule()?.FileName; + procPath = procPath == null ? null : Path.GetFullPath(procPath); + + if (procPath != null) + { + + if (thisPath == procPath) + { + return true; + } + + var accProPath = Path.GetFullPath(Path.Combine(thisPath, "..", "modules", "Accelerator", #if WINDOWS - "Steam++.Accelerator.exe" + "Steam++.Accelerator.exe" #else - "Steam++.Accelerator" + "Steam++.Accelerator" #endif - )); - if (procPath == accProPath) - { - return true; + )); + if (procPath == accProPath) + { + return true; + } + + if (AssemblyInfo.ValidateAssembly(procPath)) + { + return true; + } } return false; @@ -94,6 +108,10 @@ public sealed class IPCSubProcessServiceImpl : IPCSubProcessService internal static bool CheckBePid(int pid) { + if (pid == Environment.ProcessId) + { + return true; + } if (!TryGetProcessById(pid, out var proc)) { return false; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj index 9bebcd07a..316324e8a 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj @@ -96,6 +96,8 @@ --> + + diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/BD.WTTS.Client.Plugins.Accelerator.csproj b/src/BD.WTTS.Client.Plugins.Accelerator/BD.WTTS.Client.Plugins.Accelerator.csproj index 2dd506d2c..c1c0ae0af 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator/BD.WTTS.Client.Plugins.Accelerator.csproj +++ b/src/BD.WTTS.Client.Plugins.Accelerator/BD.WTTS.Client.Plugins.Accelerator.csproj @@ -82,6 +82,8 @@ + + diff --git a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus.csproj b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus.csproj index 7f1b5ef1f..bd1bb5c0c 100644 --- a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus.csproj +++ b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus.csproj @@ -117,6 +117,8 @@ + + diff --git a/src/BD.WTTS.Client.Plugins.Authenticator/BD.WTTS.Client.Plugins.Authenticator.csproj b/src/BD.WTTS.Client.Plugins.Authenticator/BD.WTTS.Client.Plugins.Authenticator.csproj index cf47bd7d4..0f69e7520 100644 --- a/src/BD.WTTS.Client.Plugins.Authenticator/BD.WTTS.Client.Plugins.Authenticator.csproj +++ b/src/BD.WTTS.Client.Plugins.Authenticator/BD.WTTS.Client.Plugins.Authenticator.csproj @@ -70,6 +70,8 @@ + + diff --git a/src/BD.WTTS.Client.Plugins.GameAccount/BD.WTTS.Client.Plugins.GameAccount.csproj b/src/BD.WTTS.Client.Plugins.GameAccount/BD.WTTS.Client.Plugins.GameAccount.csproj index 347123530..b61b548cc 100644 --- a/src/BD.WTTS.Client.Plugins.GameAccount/BD.WTTS.Client.Plugins.GameAccount.csproj +++ b/src/BD.WTTS.Client.Plugins.GameAccount/BD.WTTS.Client.Plugins.GameAccount.csproj @@ -81,6 +81,8 @@ + + diff --git a/src/BD.WTTS.Client.Plugins.GameList/BD.WTTS.Client.Plugins.GameList.csproj b/src/BD.WTTS.Client.Plugins.GameList/BD.WTTS.Client.Plugins.GameList.csproj index 27b131c3b..4b4d11ea7 100644 --- a/src/BD.WTTS.Client.Plugins.GameList/BD.WTTS.Client.Plugins.GameList.csproj +++ b/src/BD.WTTS.Client.Plugins.GameList/BD.WTTS.Client.Plugins.GameList.csproj @@ -80,6 +80,8 @@ + + diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/BD.WTTS.Client.Plugins.SteamIdleCard.csproj b/src/BD.WTTS.Client.Plugins.SteamIdleCard/BD.WTTS.Client.Plugins.SteamIdleCard.csproj index a1a6108ce..85a3b7ded 100644 --- a/src/BD.WTTS.Client.Plugins.SteamIdleCard/BD.WTTS.Client.Plugins.SteamIdleCard.csproj +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/BD.WTTS.Client.Plugins.SteamIdleCard.csproj @@ -76,6 +76,8 @@ + + diff --git a/src/BD.WTTS.Client.Tools.Publish/Commands/IDotNetPublishCommand.cs b/src/BD.WTTS.Client.Tools.Publish/Commands/IDotNetPublishCommand.cs index 507930bec..587d6d558 100644 --- a/src/BD.WTTS.Client.Tools.Publish/Commands/IDotNetPublishCommand.cs +++ b/src/BD.WTTS.Client.Tools.Publish/Commands/IDotNetPublishCommand.cs @@ -624,6 +624,27 @@ $""" /// static void CopyRuntime(string rootPublishDir, Platform platform, bool isCopyRuntime, Architecture architecture) { + string? preOrRcString = null; + var infoVer = typeof(object).Assembly.GetCustomAttribute()?.InformationalVersion; + if (!string.IsNullOrWhiteSpace(infoVer)) + { + var index = infoVer.IndexOf('-'); + if (index > 4) // x.y.z-abc + { + var index2 = infoVer.IndexOf('+'); + if (index2 > 0) + { + preOrRcString = infoVer.Substring(index + 1, index2 - index - 1); + } + else + { + preOrRcString = infoVer[(index + 1)..]; + } + } + } + + var specific_version = $"{Environment.Version.Major}.{Environment.Version.Minor}.{Environment.Version.Build}{(preOrRcString == null ? null : $"-{preOrRcString}")}"; + switch (platform) { case Platform.UWP: @@ -643,36 +664,36 @@ $""" Environment.SpecialFolder.ProgramFilesX86 : Environment.SpecialFolder.ProgramFiles); - static string get_hostfxr_path(string rootPath) => Path.Combine(rootPath, + string get_hostfxr_path(string rootPath) => Path.Combine(rootPath, "dotnet", "host", "fxr", - $"{Environment.Version.Major}.{Environment.Version.Minor}.{Environment.Version.Build}", + specific_version, "hostfxr.dll"); var hostfxr_path = get_hostfxr_path(programFiles); - static string get_aspnetcore_path(string rootPath) => Path.Combine(rootPath, + string get_aspnetcore_path(string rootPath) => Path.Combine(rootPath, "dotnet", "shared", "Microsoft.AspNetCore.App", - $"{Environment.Version.Major}.{Environment.Version.Minor}.{Environment.Version.Build}"); + specific_version); var aspnetcore_path = get_aspnetcore_path(programFiles); - static string get_win_desktop_path(string rootPath) => Path.Combine(rootPath, + string get_win_desktop_path(string rootPath) => Path.Combine(rootPath, "dotnet", "shared", "Microsoft.WindowsDesktop.App", - $"{Environment.Version.Major}.{Environment.Version.Minor}.{Environment.Version.Build}"); + specific_version); var win_desktop_path = get_win_desktop_path(programFiles); - static string get_netcore_path(string rootPath) => Path.Combine(rootPath, + string get_netcore_path(string rootPath) => Path.Combine(rootPath, "dotnet", "shared", "Microsoft.NETCore.App", - $"{Environment.Version.Major}.{Environment.Version.Minor}.{Environment.Version.Build}"); + specific_version); var netcore_path = get_netcore_path(programFiles); diff --git a/src/BD.WTTS.Client.Tools.Publish/Constants.cs b/src/BD.WTTS.Client.Tools.Publish/Constants.cs index 17dc1c869..8857e190e 100644 --- a/src/BD.WTTS.Client.Tools.Publish/Constants.cs +++ b/src/BD.WTTS.Client.Tools.Publish/Constants.cs @@ -6,7 +6,7 @@ interface Constants { const string ProjectDir_AvaloniaApp = "BD.WTTS.Client.Avalonia.App"; const string ProjectDir_AppHost = "BD.WTTS.Client.AppHost"; - const string windowssdkver = "10.0.19041"; + const string windowssdkver = "10.0.19041.0"; static string DebugRuntimeConfigPath => Path.Combine(ProjectUtils.ProjPath, "src", ProjectDir_AvaloniaApp, "bin", "Debug", $"net{Environment.Version.Major}.{Environment.Version.Minor}-windows{windowssdkver}", runtimeconfigjsonfilename); diff --git a/src/BD.WTTS.UnitTest/IcoTest.cs b/src/BD.WTTS.UnitTest/IcoTest.cs index 336686d56..e180be68b 100644 --- a/src/BD.WTTS.UnitTest/IcoTest.cs +++ b/src/BD.WTTS.UnitTest/IcoTest.cs @@ -31,7 +31,7 @@ public sealed class IcoTest using var logo512Bitmap = SKBitmap.Decode(logo512Path); logoBitmaps = new[] { logo512Bitmap }.Concat(new[] { 256, 128, 96, 64, 48, 32, 24, 16 } - .Select(x => logo512Bitmap.Resize(new SKSizeI { Height = x, Width = x }, SKFilterQuality.High))) + .Select(x => logo512Bitmap.Resize(new SKSizeI { Height = x, Width = x }, SKSamplingOptions.Default))) .ToArray(); // 根据 512 大小生成所有挡位的位图数组 var savePath = Path.Combine(assemblyDir, "EncodeTest.ico"); @@ -79,7 +79,7 @@ public sealed class IcoTest var maxSize = allSize.Max(); using var fBitmap = ResizeImage(imgBitmap, gameBitmap, maxSize); bitmaps = new[] { fBitmap }.Concat(allSize.Where(x => x != maxSize) - .Select(x => fBitmap.Resize(new SKSizeI { Height = x, Width = x }, SKFilterQuality.High))) + .Select(x => fBitmap.Resize(new SKSizeI { Height = x, Width = x }, SKSamplingOptions.Default))) .ToArray(); var savePath = Path.Combine(saveDirPath, $"{img.Name}.ico"); @@ -106,7 +106,7 @@ public sealed class IcoTest int watermarkTop = size - icoHeight; SKBitmap scaledImage = new(size, size); - image.ScalePixels(scaledImage, SKFilterQuality.High); + image.ScalePixels(scaledImage, SKSamplingOptions.Default); using SKCanvas canvas = new(scaledImage); canvas.DrawBitmap(icoIcon, new SKRect(watermarkLeft, watermarkTop, watermarkLeft + icoWidth, watermarkTop + icoHeight)); diff --git a/src/TFM_NETX_SINGLE.props b/src/TFM_NETX_SINGLE.props index f9118f622..e7ef68de7 100644 --- a/src/TFM_NETX_SINGLE.props +++ b/src/TFM_NETX_SINGLE.props @@ -1,12 +1,12 @@ - net$(DotNet_Version)-windows10.0.19041 + net$(DotNet_Version)-windows10.0.19041.0 net$(DotNet_Version)-macos net$(DotNet_Version) 15.0 15.0 12.0 - 21.0 + 24.0 10.0.17763.0 10.0.17763.0 6.5 diff --git a/src/TFM_NETX_WINDOWS.props b/src/TFM_NETX_WINDOWS.props index 35ed58db5..89649f27d 100644 --- a/src/TFM_NETX_WINDOWS.props +++ b/src/TFM_NETX_WINDOWS.props @@ -1,6 +1,6 @@ net$(DotNet_Version) - net$(DotNet_Version)-windows10.0.19041 + net$(DotNet_Version)-windows10.0.19041.0 \ No newline at end of file diff --git a/src/TFM_NETX_WITH_ALL.props b/src/TFM_NETX_WITH_ALL.props index d49d57e35..60461ccd5 100644 --- a/src/TFM_NETX_WITH_ALL.props +++ b/src/TFM_NETX_WITH_ALL.props @@ -2,14 +2,14 @@ net$(DotNet_Version) - $(TargetFrameworks);net$(DotNet_Version)-macos;net$(DotNet_Version)-windows10.0.19041 + $(TargetFrameworks);net$(DotNet_Version)-macos;net$(DotNet_Version)-windows10.0.19041.0 $(TargetFrameworks);net$(DotNet_Version)-ios;net$(DotNet_Version)-macos;net$(DotNet_Version)-maccatalyst $(TargetFrameworks) 15.0 15.0 12.0 - 21.0 + 24.0 10.0.17763.0 10.0.17763.0 6.5 diff --git a/src/TFM_NETX_WITH_DESKTOP.props b/src/TFM_NETX_WITH_DESKTOP.props index 85b59dd2f..e893a7262 100644 --- a/src/TFM_NETX_WITH_DESKTOP.props +++ b/src/TFM_NETX_WITH_DESKTOP.props @@ -6,7 +6,7 @@ 15.0 15.0 12.0 - 21.0 + 24.0 10.0.17763.0 10.0.17763.0 6.5 diff --git a/src/TFM_NETX_WITH_WINDOWS.props b/src/TFM_NETX_WITH_WINDOWS.props index 459335a79..89949a8a2 100644 --- a/src/TFM_NETX_WITH_WINDOWS.props +++ b/src/TFM_NETX_WITH_WINDOWS.props @@ -1,11 +1,11 @@ net$(DotNet_Version) - $(TargetFrameworks);net$(DotNet_Version)-windows10.0.19041 + $(TargetFrameworks);net$(DotNet_Version)-windows10.0.19041.0 15.0 15.0 12.0 - 21.0 + 24.0 10.0.17763.0 10.0.17763.0 6.5 diff --git a/src/Utils.cs b/src/Utils.cs index 6f1e01777..534d20085 100644 --- a/src/Utils.cs +++ b/src/Utils.cs @@ -78,7 +78,7 @@ public static partial class ProjectUtils /// public const string tfm_ = #if WINDOWS - "-windows10.0.19041"; + "-windows10.0.19041.0"; #elif LINUX ""; #elif MACCATALYST