代码插件自动信任有签名的代码

This commit is contained in:
ZouJin 2023-06-16 12:40:16 +10:00
parent 265f512df3
commit 07950780d0
2 changed files with 21 additions and 11 deletions

View File

@ -35,10 +35,6 @@ namespace VPet_Simulator.Windows
public int Ver; public int Ver;
public string Content = ""; public string Content = "";
public bool SuccessLoad = true; public bool SuccessLoad = true;
/// <summary>
/// LBGame 信任的MOD,自动加载
/// </summary>
public bool IsTrust = false;
public static string INTtoVER(int ver) => $"{ver / 100}.{ver % 100:00}"; public static string INTtoVER(int ver) => $"{ver / 100}.{ver % 100:00}";
public static void LoadImage(MainWindow mw, DirectoryInfo di) public static void LoadImage(MainWindow mw, DirectoryInfo di)
{ {
@ -130,7 +126,7 @@ namespace VPet_Simulator.Windows
break; break;
case "plugin": case "plugin":
Content += "代码插件\n"; Content += "代码插件\n";
SuccessLoad = false; SuccessLoad = true;
foreach (FileInfo tmpfi in di.EnumerateFiles("*.dll")) foreach (FileInfo tmpfi in di.EnumerateFiles("*.dll"))
{ {
try try
@ -141,9 +137,24 @@ namespace VPet_Simulator.Windows
LoadedDLL.Add(path); LoadedDLL.Add(path);
Assembly dll = Assembly.LoadFrom(tmpfi.FullName); Assembly dll = Assembly.LoadFrom(tmpfi.FullName);
var certificate = dll.GetModules()?.First()?.GetSignerCertificate(); var certificate = dll.GetModules()?.First()?.GetSignerCertificate();
if (certificate != null && certificate.Subject == "") if (certificate != null)
{//LBGame 信任的证书 {
if (certificate.Subject == "CN=\"Shenzhen Lingban Computer Technology Co., Ltd.\", O=\"Shenzhen Lingban Computer Technology Co., Ltd.\", L=Shenzhen, S=Guangdong Province, C=CN, SERIALNUMBER=91440300MA5H8REU3K, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.1=Shenzhen, OID.1.3.6.1.4.1.311.60.2.1.2=Guangdong Province, OID.1.3.6.1.4.1.311.60.2.1.3=CN"
&& certificate.Issuer == "CN=DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1, O=\"DigiCert, Inc.\", C=US")
{//LBGame 信任的证书
if (!Author.Contains("["))
Author += "[认证]";
}
else if (!IsPassMOD(mw))
{//不是通过模组,不加载
SuccessLoad = false;
continue;
}
else if (!Author.Contains("["))
{
Author += "[签名]";
Intro += $"Subject:{certificate.Subject}\nIssuer:{certificate.Subject}";
}
} }
else else
{ {
@ -158,13 +169,12 @@ namespace VPet_Simulator.Windows
if (exportedType.BaseType == typeof(MainPlugin)) if (exportedType.BaseType == typeof(MainPlugin))
{ {
mw.Plugins.Add((MainPlugin)Activator.CreateInstance(exportedType, mw)); mw.Plugins.Add((MainPlugin)Activator.CreateInstance(exportedType, mw));
SuccessLoad = true;
} }
} }
} }
catch catch
{ {
SuccessLoad = false;
} }
} }
break; break;

View File

@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="https://opensource.panuon.com/wpf-ui" xmlns:local="clr-namespace:VPet_Simulator.Windows" xmlns:pu="https://opensource.panuon.com/wpf-ui" xmlns:local="clr-namespace:VPet_Simulator.Windows"
mc:Ignorable="d" Title="更好买" Height="450" Width="800" FontSize="14" WindowStartupLocation="CenterScreen" mc:Ignorable="d" Title="更好买" Height="500" Width="800" FontSize="14" WindowStartupLocation="CenterScreen"
Background="#E0F6FF" pu:WindowXCaption.Height="45" pu:WindowXCaption.Background="{DynamicResource DARKPrimary}" Background="#E0F6FF" pu:WindowXCaption.Height="45" pu:WindowXCaption.Background="{DynamicResource DARKPrimary}"
pu:WindowXCaption.Foreground="#FFFFFF" pu:WindowXCaption.Buttons="Close" Icon="/Res/BetterBuy.png" pu:WindowXCaption.Foreground="#FFFFFF" pu:WindowXCaption.Buttons="Close" Icon="/Res/BetterBuy.png"
pu:WindowXCaption.ShadowColor="{DynamicResource ShadowColor}" Closing="WindowX_Closing"> pu:WindowXCaption.ShadowColor="{DynamicResource ShadowColor}" Closing="WindowX_Closing">