store migration

This commit is contained in:
DismissedLight
2023-01-30 16:22:54 +08:00
parent bb01f3a3cb
commit 9fb2da41cd
8 changed files with 70 additions and 33 deletions

View File

@@ -50,8 +50,8 @@ Global
{AAAB7CF0-F299-49B8-BDB4-4C320B3EC2C7}.Release|x86.ActiveCfg = Release|x86
{AAAB7CF0-F299-49B8-BDB4-4C320B3EC2C7}.Release|x86.Build.0 = Release|x86
{AAAB7CF0-F299-49B8-BDB4-4C320B3EC2C7}.Release|x86.Deploy.0 = Release|x86
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Debug|Any CPU.ActiveCfg = Debug|x64
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Debug|Any CPU.Build.0 = Debug|x64
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Debug|arm64.ActiveCfg = Debug|Any CPU
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Debug|arm64.Build.0 = Debug|Any CPU
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Debug|x64.ActiveCfg = Debug|x64
@@ -66,8 +66,8 @@ Global
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Release|x64.Build.0 = Release|x64
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Release|x86.ActiveCfg = Release|Any CPU
{8B96721E-5604-47D2-9B72-06FEBAD0CE00}.Release|x86.Build.0 = Release|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|Any CPU.ActiveCfg = Debug|x64
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|Any CPU.Build.0 = Debug|x64
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|arm64.ActiveCfg = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|arm64.Build.0 = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|x64.ActiveCfg = Debug|x64
@@ -78,8 +78,8 @@ Global
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|Any CPU.Build.0 = Release|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|arm64.ActiveCfg = Release|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|arm64.Build.0 = Release|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|x64.ActiveCfg = Release|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|x64.Build.0 = Release|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|x64.ActiveCfg = Release|x64
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|x64.Build.0 = Release|x64
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|x86.ActiveCfg = Release|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection

View File

@@ -19,11 +19,12 @@
},
"fileToFile": {
"add": {
".filenesting.json": [ "App.xaml.cs" ],
"app.manifest": [ "App.xaml.cs" ],
"Package.appxmanifest": [ "App.xaml.cs" ],
"GlobalUsing.cs": [ "Program.cs" ],
".filenesting.json": [ "Program.cs" ],
".editorconfig": [ "Program.cs" ]
"Package.StoreAssociation.xml": [ "App.xaml.cs" ],
".editorconfig": [ "Program.cs" ],
"GlobalUsing.cs": [ "Program.cs" ]
}
}
}

View File

@@ -40,7 +40,6 @@ public class GameAccount : INotifyPropertyChanged
/// <summary>
/// [MIHOYOSDK_ADL_PROD_CN_h3123967166]
/// see <see cref="Service.Game.GameAccountRegistryInterop.SdkKey"/>
/// </summary>
public string MihoyoSDK { get; set; } = default!;

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<StoreAssociation xmlns="http://schemas.microsoft.com/appx/2010/storeassociation">
<Publisher>CN=35C8E923-85DF-49A7-9172-B39DC6312C52</Publisher>
<PublisherDisplayName>DGP Studio</PublisherDisplayName>
<DeveloperAccountType>MSA</DeveloperAccountType>
<GeneratePackageHash>http://www.w3.org/2001/04/xmlenc#sha256</GeneratePackageHash>
<SupportedLocales>
<Language Code="zh-cn" InMinimumRequirementSet="true" />
</SupportedLocales>
<ProductReservedInfo>
<MainPackageIdentityName>60568DGPStudio.SnapHutao</MainPackageIdentityName>
<ReservedNames>
<ReservedName>Snap Hutao</ReservedName>
<ReservedName>胡桃工具箱</ReservedName>
</ReservedNames>
</ProductReservedInfo>
<AccountPackageIdentityNames>
<MainPackageIdentityName>60568DGPStudio.SnapGenshinResin</MainPackageIdentityName>
</AccountPackageIdentityNames>
<PackageInfoList LandingUrl="https://developer.microsoft.com/dashboard/Application?appId=9PH4NXJ2JN52" />
</StoreAssociation>

View File

@@ -4,26 +4,23 @@
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
IgnorableNamespaces="com uap desktop desktop6 rescap">
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
IgnorableNamespaces="com uap desktop rescap mp">
<Identity
Name="7f0db578-026f-4e0b-a75b-d5d06bb0a74d"
Publisher="CN=DGP Studio"
Version="1.4.0.0" />
Name="60568DGPStudio.SnapHutao"
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
Version="1.4.11.0" />
<Properties>
<DisplayName>胡桃</DisplayName>
<DisplayName>Snap Hutao</DisplayName>
<PublisherDisplayName>DGP Studio</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
<desktop6:RegistryWriteVirtualization>disabled</desktop6:RegistryWriteVirtualization>
</Properties>
<Dependencies>
<!--<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />-->
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19041.0" MaxVersionTested="10.0.22621.0" />
</Dependencies>
@@ -36,7 +33,7 @@
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="胡桃"
DisplayName="Snap Hutao"
Description="A Snap Hutao Software"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
@@ -66,6 +63,5 @@
<Capabilities>
<rescap:Capability Name="runFullTrust"/>
<rescap:Capability Name="unvirtualizedResources"/>
</Capabilities>
</Package>

View File

@@ -377,7 +377,7 @@ internal class GameService : IGameService
{
Must.NotNull(gameAccounts!);
string? registrySdk = GameAccountRegistryInterop.Get();
string? registrySdk = RegistryInterop.Get();
if (!string.IsNullOrEmpty(registrySdk))
{
GameAccount? account;
@@ -422,7 +422,7 @@ internal class GameService : IGameService
/// <inheritdoc/>
public bool SetGameAccount(GameAccount account)
{
return GameAccountRegistryInterop.Set(account);
return RegistryInterop.Set(account);
}
/// <inheritdoc/>

View File

@@ -3,14 +3,15 @@
using Microsoft.Win32;
using Snap.Hutao.Model.Entity;
using System.Diagnostics;
using System.Text;
namespace Snap.Hutao.Service.Game;
/// <summary>
/// 定义了对注册表操作
/// 注册表操作
/// </summary>
internal static class GameAccountRegistryInterop
internal static class RegistryInterop
{
private const string GenshinKey = @"HKEY_CURRENT_USER\Software\miHoYo\原神";
private const string SdkKey = "MIHOYOSDK_ADL_PROD_CN_h3123967166";
@@ -24,8 +25,25 @@ internal static class GameAccountRegistryInterop
{
if (account != null)
{
Registry.SetValue(GenshinKey, SdkKey, Encoding.UTF8.GetBytes(account.MihoyoSDK));
return true;
string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(account.MihoyoSDK));
string path = $"HKCU:{GenshinKey[@"HKEY_CURRENT_USER\".Length..]}";
string command = $"""
$value = [Convert]::FromBase64String('{base64}');
Set-ItemProperty -Path '{path}' -Name '{SdkKey}' -Value $value -Force;
""";
ProcessStartInfo startInfo = new()
{
Arguments = command,
CreateNoWindow = true,
FileName = "PowerShell",
};
Process.Start(startInfo)?.WaitForExit();
if (Get() == account.MihoyoSDK)
{
return true;
}
}
return false;

View File

@@ -20,12 +20,12 @@
<DefaultLanguage>zh-CN</DefaultLanguage>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<PackageCertificateThumbprint>F8C2255969BEA4A681CED102771BF807856AEC02</PackageCertificateThumbprint>
<PackageCertificateThumbprint>D15C4474363D2AF157C5CC6F230C7BFF2CF19B25</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>True</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundle>Never</AppxBundle>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>False</GenerateTestArtifacts>
<AppxBundle>Always</AppxBundle>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<StartupObject>Snap.Hutao.Program</StartupObject>
<DefineConstants>$(DefineConstants);DISABLE_XAML_GENERATED_MAIN;DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION;DISABLE_XAML_GENERATED_BINDING_DEBUG_OUTPUT</DefineConstants>
@@ -33,6 +33,8 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<ApplicationIcon>Assets\Logo.ico</ApplicationIcon>
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
<AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
</PropertyGroup>
<ItemGroup>
@@ -177,7 +179,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25281-preview" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.221209.1" />
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.435">
<PrivateAssets>all</PrivateAssets>