Compare commits

...

40 Commits

Author SHA1 Message Date
qhy040404
b99b34945e fix #1711 2024-06-10 11:05:58 +08:00
qhy040404
94a96c76bc fix #1710 2024-06-10 10:57:29 +08:00
DismissedLight
5cf3046257 Merge pull request #1694 from Mikachu2333/develop 2024-06-06 15:16:22 +08:00
Lightczx
89f8dedb57 fix url protocol launch lock 2024-06-06 13:11:24 +08:00
LinkChou
3c1e9237aa replace Uid to UID 2024-06-06 11:54:11 +08:00
LinkChou
e7cb01b302 Merge branch 'develop' of https://github.com/Mikachu2333/Snap.Hutao into develop 2024-06-06 11:48:03 +08:00
LinkChou
4cd971e166 Add some 2024-06-06 11:47:37 +08:00
Mikachu2333
7a9657f0cb Merge branch 'DGP-Studio:develop' into develop 2024-06-06 11:44:31 +08:00
Lightczx
82e6b62231 correctly free library 2024-06-06 09:29:50 +08:00
LinkChou
374c4d796d reformat 2024-06-06 07:25:11 +08:00
Mikachu2333
6e149a5be3 Update SH.resx 2024-06-06 01:44:32 +08:00
Mikachu2333
00ad0ef346 correct format 2024-06-06 01:39:10 +08:00
Mikachu2333
f22f165592 Merge branch 'develop' into develop 2024-06-06 01:33:09 +08:00
DismissedLight
5d8a39fe43 bump version 2024-06-05 21:29:28 +08:00
DismissedLight
521534be05 Merge pull request #1667 from DGP-Studio/l10n_develop 2024-06-05 21:22:17 +08:00
DismissedLight
b1364db3ac Merge pull request #1697 from DGP-Studio/opt/launch_game_activation 2024-06-05 20:35:18 +08:00
qhy040404
031cf77c27 refine LaunchGameAction 2024-06-05 19:09:57 +08:00
LinkChou
49c75dde2a Chinese text improve 2024-06-05 18:43:45 +08:00
Lightczx
3200c5e60b fix NTHeader offset 2024-06-05 17:22:45 +08:00
Lightczx
b392a6f8e5 Align HMODULE ptr 2024-06-05 17:17:52 +08:00
Lightczx
3e8e109123 use image header to fetch image size 2024-06-05 16:51:59 +08:00
Lightczx
91c886befb code style 2024-06-05 16:15:46 +08:00
Lightczx
32bdfe12af Fix Unlock Fps Attempt 2 2024-06-05 16:05:51 +08:00
Lightczx
eac67b6f44 Fix Unlock Fps Attempt 1 2024-06-05 15:28:50 +08:00
Lightczx
0dcba220c5 fix Launch Game ViewModel scope 2024-06-05 13:42:31 +08:00
Masterain
a204eaa95c New translations sh.resx (Vietnamese) 2024-06-04 18:31:38 -07:00
Masterain
35491c4eb1 New translations sh.resx (French) 2024-06-04 18:31:36 -07:00
Masterain
706401350c New translations sh.resx (Indonesian) 2024-06-04 18:31:36 -07:00
Masterain
c8ba04ee11 New translations sh.resx (English) 2024-06-04 18:31:34 -07:00
Masterain
b080a553c3 New translations sh.resx (Chinese Traditional) 2024-06-04 18:31:33 -07:00
Masterain
baf5612333 New translations sh.resx (Russian) 2024-06-04 18:31:32 -07:00
Masterain
eacd697cfe New translations sh.resx (Portuguese) 2024-06-04 18:31:31 -07:00
Masterain
11dc8e60bb New translations sh.resx (Korean) 2024-06-04 18:31:29 -07:00
Masterain
bba62996a0 New translations sh.resx (Japanese) 2024-06-04 18:31:28 -07:00
DismissedLight
db15b6a30c Merge pull request #1673 from DGP-Studio/ref/disable_web_login 2024-06-05 09:26:14 +08:00
Lightczx
1b0356b5ef fix #1669 2024-06-05 09:24:29 +08:00
Masterain
c85a74dfc3 New translations sh.resx (Chinese Traditional) 2024-06-03 07:31:29 -07:00
Masterain
5859ca3c12 New translations sh.resx (Chinese Traditional) 2024-06-01 11:19:36 -07:00
Masterain
e34e87359f New translations sh.resx (Chinese Traditional) 2024-06-01 09:51:13 -07:00
Masterain
ff6c682e1b New translations sh.resx (Chinese Traditional) 2024-05-31 10:16:41 -07:00
47 changed files with 577 additions and 182 deletions

View File

@@ -5,6 +5,7 @@ using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Markup;
using Microsoft.UI.Xaml.Navigation;
using Snap.Hutao.Core.Abstraction;
using Snap.Hutao.Service.Navigation;
using Snap.Hutao.View.Helper;
using Snap.Hutao.ViewModel.Abstraction;
@@ -53,9 +54,14 @@ internal class ScopedPage : Page
{
try
{
IViewModel viewModel = pageScope.ServiceProvider.GetRequiredService<TViewModel>();
viewModel.CancellationToken = viewCancellationTokenSource.Token;
viewModel.DeferContentLoader = new DeferContentLoader(this);
TViewModel viewModel = pageScope.ServiceProvider.GetRequiredService<TViewModel>();
using (viewModel.DisposeLock.Enter())
{
viewModel.IsViewDisposed = false;
viewModel.CancellationToken = viewCancellationTokenSource.Token;
viewModel.DeferContentLoader = new DeferContentLoader(this);
}
DataContext = viewModel;
}
catch (Exception ex)
@@ -104,13 +110,15 @@ internal class ScopedPage : Page
viewCancellationTokenSource.Cancel();
IViewModel viewModel = (IViewModel)DataContext;
// Wait to ensure viewmodel operation is completed
viewModel.DisposeLock.Wait();
viewModel.IsViewDisposed = true;
using (viewModel.DisposeLock.Enter())
{
// Wait to ensure viewmodel operation is completed
viewModel.IsViewDisposed = true;
// Dispose the scope
pageScope.Dispose();
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true);
// Dispose the scope
pageScope.Dispose();
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true);
}
}
}
}

View File

@@ -5,5 +5,5 @@ namespace Snap.Hutao.Core.Abstraction;
internal interface IPinnable<TData>
{
ref readonly TData GetPinnableReference();
ref TData GetPinnableReference();
}

View File

@@ -0,0 +1,9 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Core.Abstraction;
internal interface IResurrectable
{
void Resurrect();
}

View File

@@ -56,30 +56,39 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
/// <inheritdoc/>
public void PostInitialization()
{
serviceProvider.GetRequiredService<PrivateNamedPipeServer>().RunAsync().SafeForget();
ToastNotificationManagerCompat.OnActivated += NotificationActivate;
RunPostInitializationAsync().SafeForget();
using (activateSemaphore.Enter())
async ValueTask RunPostInitializationAsync()
{
// TODO: Introduced in 1.10.2, remove in later version
serviceProvider.GetRequiredService<IJumpListInterop>().ClearAsync().SafeForget();
serviceProvider.GetRequiredService<IScheduleTaskInterop>().UnregisterAllTasks();
await taskContext.SwitchToBackgroundAsync();
if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor10Revision0GuideState, GuideState.Language) < GuideState.Completed)
serviceProvider.GetRequiredService<PrivateNamedPipeServer>().RunAsync().SafeForget();
ToastNotificationManagerCompat.OnActivated += NotificationActivate;
using (await activateSemaphore.EnterAsync().ConfigureAwait(false))
{
return;
// TODO: Introduced in 1.10.2, remove in later version
serviceProvider.GetRequiredService<IJumpListInterop>().ClearAsync().SafeForget();
serviceProvider.GetRequiredService<IScheduleTaskInterop>().UnregisterAllTasks();
if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor10Revision0GuideState, GuideState.Language) < GuideState.Completed)
{
return;
}
serviceProvider.GetRequiredService<HotKeyOptions>().RegisterAll();
if (serviceProvider.GetRequiredService<AppOptions>().IsNotifyIconEnabled)
{
XamlLifetime.ApplicationLaunchedWithNotifyIcon = true;
await taskContext.SwitchToMainThreadAsync();
serviceProvider.GetRequiredService<App>().DispatcherShutdownMode = DispatcherShutdownMode.OnExplicitShutdown;
_ = serviceProvider.GetRequiredService<NotifyIconController>();
}
serviceProvider.GetRequiredService<IQuartzService>().StartAsync(default).SafeForget();
}
serviceProvider.GetRequiredService<HotKeyOptions>().RegisterAll();
if (serviceProvider.GetRequiredService<AppOptions>().IsNotifyIconEnabled)
{
XamlLifetime.ApplicationLaunchedWithNotifyIcon = true;
serviceProvider.GetRequiredService<App>().DispatcherShutdownMode = DispatcherShutdownMode.OnExplicitShutdown;
_ = serviceProvider.GetRequiredService<NotifyIconController>();
}
serviceProvider.GetRequiredService<IQuartzService>().StartAsync(default).SafeForget();
}
}
@@ -96,25 +105,31 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
await taskContext.SwitchToMainThreadAsync();
if (currentWindowReference.Window is null)
switch (currentWindowReference.Window)
{
currentWindowReference.Window = serviceProvider.GetRequiredService<LaunchGameWindow>();
return;
}
case null:
LaunchGameWindow launchGameWindow = serviceProvider.GetRequiredService<LaunchGameWindow>();
currentWindowReference.Window = launchGameWindow;
if (currentWindowReference.Window is MainWindow)
{
await serviceProvider
.GetRequiredService<INavigationService>()
.NavigateAsync<View.Page.LaunchGamePage>(INavigationAwaiter.Default, true)
.ConfigureAwait(false);
launchGameWindow.SwitchTo();
launchGameWindow.BringToForeground();
return;
return;
}
else
{
// We have a non-Main Window, just exit current process anyway
Process.GetCurrentProcess().Kill();
case MainWindow:
await serviceProvider
.GetRequiredService<INavigationService>()
.NavigateAsync<View.Page.LaunchGamePage>(INavigationAwaiter.Default, true)
.ConfigureAwait(false);
return;
case LaunchGameWindow currentLaunchGameWindow:
currentLaunchGameWindow.SwitchTo();
currentLaunchGameWindow.BringToForeground();
return;
default:
Process.GetCurrentProcess().Kill();
return;
}
}
@@ -134,6 +149,8 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
private async ValueTask HandleActivationAsync(HutaoActivationArguments args)
{
await taskContext.SwitchToBackgroundAsync();
if (activateSemaphore.CurrentCount > 0)
{
using (await activateSemaphore.EnterAsync().ConfigureAwait(false))

View File

@@ -63,7 +63,8 @@ internal static class WindowExtension
{
ShowWindow(hwnd, SHOW_WINDOW_CMD.SW_SHOW);
}
else if (IsIconic(hwnd))
if (IsIconic(hwnd))
{
ShowWindow(hwnd, SHOW_WINDOW_CMD.SW_RESTORE);
}

View File

@@ -75,7 +75,7 @@ internal sealed class Material : DisplayItem
DayOfWeek.Monday or DayOfWeek.Thursday => Materials.MondayThursdayItems.Contains(Id),
DayOfWeek.Tuesday or DayOfWeek.Friday => Materials.TuesdayFridayItems.Contains(Id),
DayOfWeek.Wednesday or DayOfWeek.Saturday => Materials.WednesdaySaturdayItems.Contains(Id),
_ => treatSundayAsTrue,
_ => treatSundayAsTrue && (Materials.MondayThursdayItems.Contains(Id) || Materials.TuesdayFridayItems.Contains(Id) || Materials.WednesdaySaturdayItems.Contains(Id)),
};
}

View File

@@ -13,7 +13,7 @@
<Identity
Name="60568DGPStudio.SnapHutao"
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
Version="1.10.2.0" />
Version="1.10.3.0" />
<Properties>
<DisplayName>Snap Hutao</DisplayName>

View File

@@ -13,7 +13,7 @@
<Identity
Name="60568DGPStudio.SnapHutaoDev"
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
Version="1.10.2.0" />
Version="1.10.3.0" />
<Properties>
<DisplayName>Snap Hutao Dev</DisplayName>

View File

@@ -2996,6 +2996,9 @@
<data name="ViewUserDocumentationHeader" xml:space="preserve">
<value>Document</value>
</data>
<data name="ViewUserLoginMihoyoUserDisabledTooltip" xml:space="preserve">
<value>由于米游社安全策略的相关更改,网页登录暂不可用</value>
</data>
<data name="ViewUserNoUserHint" xml:space="preserve">
<value>Haven't logged in</value>
</data>

View File

@@ -2996,6 +2996,9 @@
<data name="ViewUserDocumentationHeader" xml:space="preserve">
<value>文档</value>
</data>
<data name="ViewUserLoginMihoyoUserDisabledTooltip" xml:space="preserve">
<value>由于米游社安全策略的相关更改,网页登录暂不可用</value>
</data>
<data name="ViewUserNoUserHint" xml:space="preserve">
<value>尚未登录</value>
</data>

View File

@@ -2996,6 +2996,9 @@
<data name="ViewUserDocumentationHeader" xml:space="preserve">
<value>Dokumen</value>
</data>
<data name="ViewUserLoginMihoyoUserDisabledTooltip" xml:space="preserve">
<value>由于米游社安全策略的相关更改,网页登录暂不可用</value>
</data>
<data name="ViewUserNoUserHint" xml:space="preserve">
<value>Tidak masuk</value>
</data>

View File

@@ -2996,6 +2996,9 @@
<data name="ViewUserDocumentationHeader" xml:space="preserve">
<value>ドキュメント</value>
</data>
<data name="ViewUserLoginMihoyoUserDisabledTooltip" xml:space="preserve">
<value>由于米游社安全策略的相关更改,网页登录暂不可用</value>
</data>
<data name="ViewUserNoUserHint" xml:space="preserve">
<value>ログインしていません</value>
</data>

View File

@@ -2996,6 +2996,9 @@
<data name="ViewUserDocumentationHeader" xml:space="preserve">
<value>문서</value>
</data>
<data name="ViewUserLoginMihoyoUserDisabledTooltip" xml:space="preserve">
<value>由于米游社安全策略的相关更改,网页登录暂不可用</value>
</data>
<data name="ViewUserNoUserHint" xml:space="preserve">
<value>尚未登录</value>
</data>

View File

@@ -2996,6 +2996,9 @@
<data name="ViewUserDocumentationHeader" xml:space="preserve">
<value>Documentação</value>
</data>
<data name="ViewUserLoginMihoyoUserDisabledTooltip" xml:space="preserve">
<value>由于米游社安全策略的相关更改,网页登录暂不可用</value>
</data>
<data name="ViewUserNoUserHint" xml:space="preserve">
<value>Sem login</value>
</data>

View File

@@ -552,10 +552,10 @@
<value>精炼 {0} 阶</value>
</data>
<data name="MustSelectUserAndUid" xml:space="preserve">
<value>必须登录 米游社/HoYoLAB 并选择一个用户与角色</value>
<value>必须登录 米游社 / HoYoLAB 并选择一个用户与角色</value>
</data>
<data name="ServerGachaLogServiceDeleteEntrySucceed" xml:space="preserve">
<value>删除了 Uid{0} 的 {1} 条祈愿记录</value>
<value>删除了 UID{0} 的 {1} 条祈愿记录</value>
</data>
<data name="ServerGachaLogServiceInsufficientRecordSlot" xml:space="preserve">
<value>胡桃云保存的祈愿记录存档数已达当前账号上限</value>
@@ -570,7 +570,7 @@
<value>数据异常,无法保存至云端,请勿跨账号上传或尝试删除云端数据后重试</value>
</data>
<data name="ServerGachaLogServiceUploadEntrySucceed" xml:space="preserve">
<value>上传了 Uid{0} 的 {1} 条祈愿记录,存储了 {2} 条</value>
<value>上传了 UID{0} 的 {1} 条祈愿记录,存储了 {2} 条</value>
</data>
<data name="ServerPassportLoginRequired" xml:space="preserve">
<value>请先登录或注册胡桃账号</value>
@@ -621,7 +621,7 @@
<value>验证请求过快,请 1 分钟后再试</value>
</data>
<data name="ServerRecordBannedUid" xml:space="preserve">
<value>上传深渊记录失败,当前 Uid 已被胡桃数据库封禁</value>
<value>上传深渊记录失败,当前 UID 已被胡桃数据库封禁</value>
</data>
<data name="ServerRecordComputingStatistics" xml:space="preserve">
<value>上传深渊记录失败,正在计算统计数据</value>
@@ -636,13 +636,13 @@
<value>上传深渊记录失败,存在无效的数据</value>
</data>
<data name="ServerRecordInvalidUid" xml:space="preserve">
<value>无效的 Uid</value>
<value>无效的 UID</value>
</data>
<data name="ServerRecordNotCurrentSchedule" xml:space="preserve">
<value>上传深渊记录失败,不是本期数据</value>
</data>
<data name="ServerRecordPreviousRequestNotCompleted" xml:space="preserve">
<value>上传深渊记录失败,当前 Uid 的记录仍在处理中,请勿重复操作</value>
<value>上传深渊记录失败,当前 UID 的记录仍在处理中,请勿重复操作</value>
</data>
<data name="ServerRecordUploadSuccessAndGachaLogServiceTimeExtended" xml:space="preserve">
<value>上传深渊记录成功,获赠祈愿记录上传服务时长</value>
@@ -1545,10 +1545,10 @@
<value>养成计划添加失败</value>
</data>
<data name="ViewModelCultivationBatchAddCompletedFormat" xml:space="preserve">
<value>操作完成:添加/更新:{0} 个,跳过 {1} 个</value>
<value>操作完成:添加 / 更新:{0} 个,跳过 {1} 个</value>
</data>
<data name="ViewModelCultivationBatchAddIncompletedFormat" xml:space="preserve">
<value>操作未全部完成:添加/更新:{0} 个,跳过 {1} 个</value>
<value>操作未全部完成:添加 / 更新:{0} 个,跳过 {1} 个</value>
</data>
<data name="ViewModelCultivationEntryAddSuccess" xml:space="preserve">
<value>已成功添加至当前养成计划</value>
@@ -2067,10 +2067,10 @@
<value>前往爱发电购买相关服务</value>
</data>
<data name="ViewPageGachaLogHutaoCloudAfdianPurchaseHeader" xml:space="preserve">
<value>购买/续费云服务</value>
<value>购买 / 续费云服务</value>
</data>
<data name="ViewPageGachaLogHutaoCloudDelete" xml:space="preserve">
<value>删除此 Uid 的云端存档</value>
<value>删除此 UID 的云端存档</value>
</data>
<data name="ViewPageGachaLogHutaoCloudDeveloperHint" xml:space="preserve">
<value>开发者账号无视服务到期时间</value>
@@ -2079,7 +2079,7 @@
<value>胡桃云服务时长不足</value>
</data>
<data name="ViewPageGachaLogHutaoCloudRetrieve" xml:space="preserve">
<value>下载此 Uid 的云端存档</value>
<value>下载此 UID 的云端存档</value>
</data>
<data name="ViewPageGachaLogHutaoCloudSpiralAbyssActivityDescription" xml:space="preserve">
<value>每期深渊首次上传可免费获得 3 天时长</value>
@@ -2406,7 +2406,7 @@
<value>重命名</value>
</data>
<data name="ViewPageLaunchGameSwitchSchemeDescription" xml:space="preserve">
<value>切换游戏服务器(国服/渠道服/国际服)</value>
<value>切换游戏服务器(国服 / 渠道服 / 国际服)</value>
</data>
<data name="ViewPageLaunchGameSwitchSchemeHeader" xml:space="preserve">
<value>服务器</value>
@@ -2415,7 +2415,7 @@
<value>版本更新前需要提前转换至与启动器匹配的服务器</value>
</data>
<data name="ViewPageLaunchGameUnlockFpsDescription" xml:space="preserve">
<value>请在游戏内关闭垂直同步选项,需要高性能的显卡以支持更高的帧率</value>
<value>请在游戏内关闭垂直同步选项,需要高性能的显卡以支持更高的帧率</value>
</data>
<data name="ViewPageLaunchGameUnlockFpsHeader" xml:space="preserve">
<value>解锁帧率限制</value>
@@ -2433,7 +2433,7 @@
<value>Windows HDR</value>
</data>
<data name="ViewPageLoginHoyoverseUserHint" xml:space="preserve">
<value>请输入你的 HoYoLab Uid</value>
<value>请输入你的 HoYoLab UID</value>
</data>
<data name="ViewPageLoginMihoyoUserDescription" xml:space="preserve">
<value>你正在通过由我们提供的内嵌网页视图登录 米哈游通行证,我们会在你点击 我已登录 按钮后,读取你的 Cookie 信息,由此视图发起的网络通信只发生于你的计算机与米哈游服务器之间</value>
@@ -2511,7 +2511,7 @@
<value>除非开发人员明确要求你这么做,否则不应尝试执行下方的操作!</value>
</data>
<data name="ViewPageSettingDataFolderDescription" xml:space="preserve">
<value>用户数据/元数据 在此处存放</value>
<value>用户数据 / 元数据 在此处存放</value>
</data>
<data name="ViewPageSettingDataFolderHeader" xml:space="preserve">
<value>数据 文件夹</value>
@@ -2646,7 +2646,7 @@
<value>您可以无限制的使用任何测试功能</value>
</data>
<data name="ViewPageSettingHutaoPassportMaintainerHeader" xml:space="preserve">
<value>胡桃开发/运维</value>
<value>胡桃开发 / 运维</value>
</data>
<data name="ViewPageSettingHutaoPassportRedeemCodeDescription" xml:space="preserve">
<value>我们有时会向某些用户赠送胡桃云兑换码</value>
@@ -2703,7 +2703,7 @@
<value>重置图片资源</value>
</data>
<data name="ViewPageSettingsAdvancedOptionsLaunchUnlockFpsDescription" xml:space="preserve">
<value>在启动游戏页面的进程部分加入解锁帧率限制选项</value>
<value>在启动游戏-进程」选项卡加入解锁帧率限制选项</value>
</data>
<data name="ViewPageSettingsAdvancedOptionsLaunchUnlockFpsHeader" xml:space="preserve">
<value>启动游戏-解锁帧率限制</value>
@@ -2751,7 +2751,7 @@
<value>贡献翻译</value>
</data>
<data name="ViewPageSettingUnobtainedWishItemVisibleDescription" xml:space="preserve">
<value>在祈愿记录页面角色与武器页签显示未抽取到的祈愿物品</value>
<value>在祈愿记录-角色」与「祈愿记录-武器」中显示未抽取到的祈愿物品</value>
</data>
<data name="ViewPageSettingUnobtainedWishItemVisibleHeader" xml:space="preserve">
<value>未抽取到的祈愿物品</value>

View File

@@ -2996,6 +2996,9 @@
<data name="ViewUserDocumentationHeader" xml:space="preserve">
<value>Документация</value>
</data>
<data name="ViewUserLoginMihoyoUserDisabledTooltip" xml:space="preserve">
<value>由于米游社安全策略的相关更改,网页登录暂不可用</value>
</data>
<data name="ViewUserNoUserHint" xml:space="preserve">
<value>Вы не вошли в приложение</value>
</data>

View File

@@ -2996,6 +2996,9 @@
<data name="ViewUserDocumentationHeader" xml:space="preserve">
<value>文档</value>
</data>
<data name="ViewUserLoginMihoyoUserDisabledTooltip" xml:space="preserve">
<value>由于米游社安全策略的相关更改,网页登录暂不可用</value>
</data>
<data name="ViewUserNoUserHint" xml:space="preserve">
<value>尚未登录</value>
</data>

View File

@@ -121,7 +121,7 @@
<value>胡桃 Dev {0}</value>
</data>
<data name="AppElevatedDevNameAndVersion" xml:space="preserve">
<value>胡桃Dev {0} [系統管理]</value>
<value>胡桃 Dev {0} [系統管理]</value>
</data>
<data name="AppElevatedNameAndVersion" xml:space="preserve">
<value>胡桃 {0} [系統管理員]</value>
@@ -166,7 +166,7 @@
<value>數據庫已損壞:{0}</value>
</data>
<data name="CoreExceptionServiceUserdataCorruptedMessage" xml:space="preserve">
<value>用數據已損壞:{0}</value>
<value>用數據已損壞:{0}</value>
</data>
<data name="CoreIOPickerExtensionPickerExceptionInfoBarMessage" xml:space="preserve">
<value>請勿在系統管理員模式下使用此功能 {0}</value>
@@ -274,13 +274,13 @@
<value>上場 {0} 次</value>
</data>
<data name="ModelBindingLaunchGameLaunchSchemeBilibili" xml:space="preserve">
<value>渠道伺服器</value>
<value>渠道</value>
</data>
<data name="ModelBindingLaunchGameLaunchSchemeChinese" xml:space="preserve">
<value>官方伺服器</value>
<value>官方</value>
</data>
<data name="ModelBindingLaunchGameLaunchSchemeOversea" xml:space="preserve">
<value>國際伺服器</value>
<value>國際</value>
</data>
<data name="ModelBindingUserInitializationFailed" xml:space="preserve">
<value>網絡異常</value>
@@ -573,7 +573,7 @@
<value>上傳了 UID{0} 的 {1} 筆祈願記錄,儲存了 {2} 筆</value>
</data>
<data name="ServerPassportLoginRequired" xml:space="preserve">
<value>請先登入或冊胡桃帳號</value>
<value>請先登入或冊胡桃帳號</value>
</data>
<data name="ServerPassportLoginSucceed" xml:space="preserve">
<value>登入成功</value>
@@ -1011,7 +1011,7 @@
<value>無法找到遊戲本體路徑,請前往設定修改</value>
</data>
<data name="ServiceGameRegisteryInteropLongPathsDisabled" xml:space="preserve">
<value>未開啟長路徑功能,無法設定註冊表鍵值</value>
<value>未開啟長路徑功能,無法設定登錄檔鍵值</value>
</data>
<data name="ServiceGameSetMultiChannelConfigFileNotFound" xml:space="preserve">
<value>無法讀取遊戲設定檔 {0},可能是檔案不存在</value>
@@ -1878,7 +1878,7 @@
<value>同步角色天賦信息</value>
</data>
<data name="ViewPageAvatarPropertyRefreshFromHoyolabGameRecord" xml:space="preserve">
<value>從 HoYoLAB 戰績同步</value>
<value>從 HoYoLAB - 戰績同步</value>
</data>
<data name="ViewPageAvatarPropertyRefreshFromHoyolabGameRecordDescription" xml:space="preserve">
<value>同步角色天賦外的大部分信息</value>
@@ -2064,7 +2064,7 @@
<value>胡桃雲</value>
</data>
<data name="ViewPageGachaLogHutaoCloudAfdianPurchaseDescription" xml:space="preserve">
<value>前往愛發電購買相關服務</value>
<value>前往爱发电購買相關服務</value>
</data>
<data name="ViewPageGachaLogHutaoCloudAfdianPurchaseHeader" xml:space="preserve">
<value>購買/續費雲服務</value>
@@ -2436,13 +2436,13 @@
<value>請輸入您的 HoYoLAB UID</value>
</data>
<data name="ViewPageLoginMihoyoUserDescription" xml:space="preserve">
<value>你正在通過由我們提供的內嵌網頁視圖登入 miHoYo 通行證賬號,我們會在你點擊 我已登 按鈕後,讀取你的 Cookie 信息,由此視圖發起的網絡通信只發生於你的計算機與 miHoYo 服務器之間</value>
<value>你正在通過由我們提供的內嵌網頁視圖登錄 米哈游通行证,我們會在你點擊 我已登 按鈕後,讀取你的 Cookie 信息,由此視圖發起的網絡通信只發生於你的計算機與米哈遊服務器之間</value>
</data>
<data name="ViewPageLoginMihoyoUserLoggedInAction" xml:space="preserve">
<value>我已登入</value>
</data>
<data name="ViewPageLoginMihoyoUserTitle" xml:space="preserve">
<value>在下方登入 miHoYo 通行證賬號</value>
<value>在下方登入米哈游通行证</value>
</data>
<data name="ViewPageOpenScreenshotFolderAction" xml:space="preserve">
<value>開啟截圖檔案夾</value>
@@ -2961,7 +2961,7 @@
<value>工具</value>
</data>
<data name="ViewUserCookieOperation" xml:space="preserve">
<value>米社</value>
<value>米社</value>
</data>
<data name="ViewUserCookieOperation2" xml:space="preserve">
<value>HoYoLAB</value>
@@ -2996,6 +2996,9 @@
<data name="ViewUserDocumentationHeader" xml:space="preserve">
<value>文檔</value>
</data>
<data name="ViewUserLoginMihoyoUserDisabledTooltip" xml:space="preserve">
<value>由于米游社安全策略的相关更改,网页登录暂不可用</value>
</data>
<data name="ViewUserNoUserHint" xml:space="preserve">
<value>尚未登入</value>
</data>
@@ -3225,10 +3228,10 @@
<value>無效的 UID</value>
</data>
<data name="WebHoyolabRegionCNGF01" xml:space="preserve">
<value>大陸伺服器 官方伺服器</value>
<value>陸服 官方服</value>
</data>
<data name="WebHoyolabRegionCNQD01" xml:space="preserve">
<value>大陸伺服器 渠道伺服器</value>
<value>陸服 渠道服</value>
</data>
<data name="WebHoyolabRegionOSASIA" xml:space="preserve">
<value>國際服 亞服</value>

View File

@@ -48,7 +48,7 @@ internal sealed partial class DailyNoteOptions : DbStoreOptions
{
quartzService.UpdateJobAsync(JobIdentity.DailyNoteGroupName, JobIdentity.DailyNoteRefreshTriggerName, builder =>
{
return builder.WithSimpleSchedule(sb => sb.WithIntervalInMinutes(SelectedRefreshTime.Value).RepeatForever());
return builder.WithSimpleSchedule(sb => sb.WithIntervalInSeconds(SelectedRefreshTime.Value).RepeatForever());
}).SafeForget();
}
}

View File

@@ -1,6 +1,7 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Service.Game.Scheme;
using System.IO;
namespace Snap.Hutao.Service.Game;
@@ -38,4 +39,6 @@ internal sealed class GameFileSystem
public string PCGameSDKFilePath { get => pcGameSDKFilePath ??= Path.Combine(GameDirectory, GameConstants.PCGameSDKFilePath); }
public string ScreenShotDirectory { get => Path.Combine(GameDirectory, "ScreenShot"); }
public string DataDirectory { get => Path.Combine(GameDirectory, LaunchScheme.ExecutableIsOversea(GameFileName) ? GameConstants.GenshinImpactData : GameConstants.YuanShenData); }
}

View File

@@ -19,7 +19,12 @@ internal sealed class LaunchExecutionUnlockFpsHandler : ILaunchExecutionDelegate
IProgressFactory progressFactory = context.ServiceProvider.GetRequiredService<IProgressFactory>();
IProgress<GameFpsUnlockerContext> progress = progressFactory.CreateForMainThread<GameFpsUnlockerContext>(c => context.Progress.Report(LaunchStatus.FromUnlockerContext(c)));
GameFpsUnlocker unlocker = new(context.ServiceProvider, context.Process, new(100, 20000, 3000), progress);
if (!context.TryGetGameFileSystem(out GameFileSystem? gameFileSystem))
{
return;
}
GameFpsUnlocker unlocker = new(context.ServiceProvider, context.Process, new(gameFileSystem, 100, 20000, 3000), progress);
try
{

View File

@@ -16,43 +16,30 @@ internal static class GameFpsAddress
private const byte ASM_JMP = 0xE9;
#pragma warning restore SA1310
public static unsafe void UnsafeFindFpsAddress(GameFpsUnlockerContext state, in RequiredGameModule requiredGameModule)
public static unsafe void UnsafeFindFpsAddress(GameFpsUnlockerContext context, in RequiredRemoteModule remoteModule, in RequiredLocalModule localModule)
{
bool readOk = UnsafeReadModulesMemory(state.GameProcess, requiredGameModule, out VirtualMemory localMemory);
HutaoException.ThrowIfNot(readOk, SH.ServiceGameUnlockerReadModuleMemoryCopyVirtualMemoryFailed);
int offsetToUserAssembly = IndexOfPattern(localModule.UserAssembly.AsSpan());
HutaoException.ThrowIfNot(offsetToUserAssembly >= 0, SH.ServiceGameUnlockerInterestedPatternNotFound);
using (localMemory)
nuint rip = localModule.UserAssembly.Address + (uint)offsetToUserAssembly;
rip += 5U;
rip += (nuint)(*(int*)(rip + 2U) + 6);
nuint remoteVirtualAddress = remoteModule.UserAssembly.Address + (rip - localModule.UserAssembly.Address);
nuint ptr = 0;
SpinWait.SpinUntil(() => UnsafeReadProcessMemory(context.GameProcess, remoteVirtualAddress, out ptr) && ptr != 0);
nuint localVirtualAddress = ptr - remoteModule.UnityPlayer.Address + localModule.UnityPlayer.Address;
while (*(byte*)localVirtualAddress is ASM_CALL or ASM_JMP)
{
int offset = IndexOfPattern(localMemory.AsSpan()[(int)requiredGameModule.UnityPlayer.Size..]);
HutaoException.ThrowIfNot(offset >= 0, SH.ServiceGameUnlockerInterestedPatternNotFound);
byte* pLocalMemory = (byte*)localMemory.Pointer;
ref readonly Module unityPlayer = ref requiredGameModule.UnityPlayer;
ref readonly Module userAssembly = ref requiredGameModule.UserAssembly;
nuint localMemoryUnityPlayerAddress = (nuint)pLocalMemory;
nuint localMemoryUserAssemblyAddress = localMemoryUnityPlayerAddress + unityPlayer.Size;
nuint rip = localMemoryUserAssemblyAddress + (uint)offset;
rip += 5U;
rip += (nuint)(*(int*)(rip + 2U) + 6);
nuint address = userAssembly.Address + (rip - localMemoryUserAssemblyAddress);
nuint ptr = 0;
SpinWait.SpinUntil(() => UnsafeReadProcessMemory(state.GameProcess, address, out ptr) && ptr != 0);
rip = ptr - unityPlayer.Address + localMemoryUnityPlayerAddress;
while (*(byte*)rip is ASM_CALL or ASM_JMP)
{
rip += (nuint)(*(int*)(rip + 1) + 5);
}
nuint localMemoryActualAddress = rip + *(uint*)(rip + 2) + 6;
nuint actualOffset = localMemoryActualAddress - localMemoryUnityPlayerAddress;
state.FpsAddress = unityPlayer.Address + actualOffset;
localVirtualAddress += (nuint)(*(int*)(localVirtualAddress + 1) + 5);
}
localVirtualAddress += *(uint*)(localVirtualAddress + 2) + 6;
nuint relativeVirtualAddress = localVirtualAddress - localModule.UnityPlayer.Address;
context.FpsAddress = remoteModule.UnityPlayer.Address + relativeVirtualAddress;
}
private static int IndexOfPattern(in ReadOnlySpan<byte> memory)
@@ -62,16 +49,6 @@ internal static class GameFpsAddress
return memory.IndexOf(part);
}
private static unsafe bool UnsafeReadModulesMemory(Process process, in RequiredGameModule moduleEntryInfo, out VirtualMemory memory)
{
ref readonly Module unityPlayer = ref moduleEntryInfo.UnityPlayer;
ref readonly Module userAssembly = ref moduleEntryInfo.UserAssembly;
memory = new VirtualMemory(unityPlayer.Size + userAssembly.Size);
return ReadProcessMemory(process.Handle, (void*)unityPlayer.Address, memory.AsSpan()[..(int)unityPlayer.Size], out _)
&& ReadProcessMemory(process.Handle, (void*)userAssembly.Address, memory.AsSpan()[(int)unityPlayer.Size..], out _);
}
private static unsafe bool UnsafeReadProcessMemory(Process process, nuint baseAddress, out nuint value)
{
value = 0;

View File

@@ -3,6 +3,7 @@
using Snap.Hutao.Core.ExceptionService;
using Snap.Hutao.Win32.Foundation;
using Snap.Hutao.Win32.System.LibraryLoader;
using System.Diagnostics;
using static Snap.Hutao.Win32.Kernel32;
@@ -18,12 +19,12 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
private readonly LaunchOptions launchOptions;
private readonly GameFpsUnlockerContext context = new();
public GameFpsUnlocker(IServiceProvider serviceProvider, Process gameProcess, in UnlockTimingOptions options, IProgress<GameFpsUnlockerContext> progress)
public GameFpsUnlocker(IServiceProvider serviceProvider, Process gameProcess, in UnlockOptions options, IProgress<GameFpsUnlockerContext> progress)
{
launchOptions = serviceProvider.GetRequiredService<LaunchOptions>();
context.GameProcess = gameProcess;
context.TimingOptions = options;
context.Options = options;
context.Progress = progress;
}
@@ -31,18 +32,22 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
public async ValueTask<bool> UnlockAsync(CancellationToken token = default)
{
HutaoException.ThrowIfNot(context.IsUnlockerValid, "This Unlocker is invalid");
(FindModuleResult result, RequiredGameModule gameModule) = await GameProcessModule.FindModuleAsync(context).ConfigureAwait(false);
(FindModuleResult result, RequiredRemoteModule remoteModule) = await GameProcessModule.FindModuleAsync(context).ConfigureAwait(false);
HutaoException.ThrowIfNot(result != FindModuleResult.TimeLimitExeeded, SH.ServiceGameUnlockerFindModuleTimeLimitExeeded);
HutaoException.ThrowIfNot(result != FindModuleResult.NoModuleFound, SH.ServiceGameUnlockerFindModuleNoModuleFound);
GameFpsAddress.UnsafeFindFpsAddress(context, gameModule);
using (RequiredLocalModule localModule = LoadRequiredLocalModule(context.Options.GameFileSystem))
{
GameFpsAddress.UnsafeFindFpsAddress(context, remoteModule, localModule);
}
context.Report();
return context.FpsAddress != 0U;
}
public async ValueTask PostUnlockAsync(CancellationToken token = default)
{
using (PeriodicTimer timer = new(context.TimingOptions.AdjustFpsDelay))
using (PeriodicTimer timer = new(context.Options.AdjustFpsDelay))
{
while (await timer.WaitForNextTickAsync(token).ConfigureAwait(false))
{
@@ -66,4 +71,15 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
{
return WriteProcessMemory((HANDLE)process.Handle, (void*)baseAddress, ref value, out _);
}
private static RequiredLocalModule LoadRequiredLocalModule(GameFileSystem gameFileSystem)
{
string gameFoler = gameFileSystem.GameDirectory;
string dataFoler = gameFileSystem.DataDirectory;
LOAD_LIBRARY_FLAGS flags = LOAD_LIBRARY_FLAGS.LOAD_LIBRARY_AS_IMAGE_RESOURCE;
HMODULE unityPlayerAddress = LoadLibraryExW(System.IO.Path.Combine(gameFoler, "UnityPlayer.dll"), default, flags);
HMODULE userAssemblyAddress = LoadLibraryExW(System.IO.Path.Combine(dataFoler, "Native", "UserAssembly.dll"), default, flags);
return new(unityPlayerAddress, userAssemblyAddress);
}
}

View File

@@ -18,7 +18,7 @@ internal sealed class GameFpsUnlockerContext
public nuint FpsAddress { get; set; }
public UnlockTimingOptions TimingOptions { get; set; }
public UnlockOptions Options { get; set; }
public Process GameProcess { get; set; } = default!;

View File

@@ -12,14 +12,14 @@ namespace Snap.Hutao.Service.Game.Unlocker;
internal static class GameProcessModule
{
public static async ValueTask<ValueResult<FindModuleResult, RequiredGameModule>> FindModuleAsync(GameFpsUnlockerContext state)
public static async ValueTask<ValueResult<FindModuleResult, RequiredRemoteModule>> FindModuleAsync(GameFpsUnlockerContext state)
{
ValueStopwatch watch = ValueStopwatch.StartNew();
using (PeriodicTimer timer = new(state.TimingOptions.FindModuleDelay))
using (PeriodicTimer timer = new(state.Options.FindModuleDelay))
{
while (await timer.WaitForNextTickAsync().ConfigureAwait(false))
{
FindModuleResult result = UnsafeGetGameModuleInfo((HANDLE)state.GameProcess.Handle, out RequiredGameModule gameModule);
FindModuleResult result = UnsafeGetGameModuleInfo((HANDLE)state.GameProcess.Handle, out RequiredRemoteModule gameModule);
if (result == FindModuleResult.Ok)
{
return new(FindModuleResult.Ok, gameModule);
@@ -30,7 +30,7 @@ internal static class GameProcessModule
return new(FindModuleResult.NoModuleFound, default);
}
if (watch.GetElapsedTime() > state.TimingOptions.FindModuleLimit)
if (watch.GetElapsedTime() > state.Options.FindModuleLimit)
{
break;
}
@@ -40,7 +40,7 @@ internal static class GameProcessModule
return new(FindModuleResult.TimeLimitExeeded, default);
}
private static FindModuleResult UnsafeGetGameModuleInfo(in HANDLE hProcess, out RequiredGameModule info)
private static FindModuleResult UnsafeGetGameModuleInfo(in HANDLE hProcess, out RequiredRemoteModule info)
{
FindModuleResult unityPlayerResult = UnsafeFindModule(hProcess, "UnityPlayer.dll", out Module unityPlayer);
FindModuleResult userAssemblyResult = UnsafeFindModule(hProcess, "UserAssembly.dll", out Module userAssembly);

View File

@@ -15,4 +15,9 @@ internal readonly struct Module
Address = address;
Size = size;
}
public unsafe Span<byte> AsSpan()
{
return new((void*)Address, (int)Size);
}
}

View File

@@ -0,0 +1,49 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Win32.Foundation;
using Snap.Hutao.Win32.System.Diagnostics.Debug;
using Snap.Hutao.Win32.System.SystemService;
using System.Runtime.CompilerServices;
using static Snap.Hutao.Win32.Kernel32;
namespace Snap.Hutao.Service.Game.Unlocker;
internal readonly struct RequiredLocalModule : IDisposable
{
public readonly bool HasValue = false;
public readonly Module UnityPlayer;
public readonly Module UserAssembly;
private readonly HMODULE hModuleUnityPlayer;
private readonly HMODULE hModuleUserAssembly;
[SuppressMessage("", "SH002")]
public RequiredLocalModule(HMODULE unityPlayer, HMODULE userAssembly)
{
hModuleUnityPlayer = unityPlayer;
hModuleUserAssembly = userAssembly;
// Align the pointer
nint unityPlayerMappedView = (nint)(unityPlayer & ~0x3L);
nint userAssemblyMappedView = (nint)(userAssembly & ~0x3L);
HasValue = true;
UnityPlayer = new((nuint)unityPlayerMappedView, GetImageSize(unityPlayerMappedView));
UserAssembly = new((nuint)userAssemblyMappedView, GetImageSize(userAssemblyMappedView));
}
public void Dispose()
{
FreeLibrary(hModuleUnityPlayer);
FreeLibrary(hModuleUserAssembly);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe uint GetImageSize(nint baseAddress)
{
IMAGE_DOS_HEADER* pImageDosHeader = (IMAGE_DOS_HEADER*)baseAddress;
IMAGE_NT_HEADERS64* pImageNtHeader = (IMAGE_NT_HEADERS64*)(pImageDosHeader->e_lfanew + baseAddress);
return pImageNtHeader->OptionalHeader.SizeOfImage;
}
}

View File

@@ -3,13 +3,13 @@
namespace Snap.Hutao.Service.Game.Unlocker;
internal readonly struct RequiredGameModule
internal readonly struct RequiredRemoteModule
{
public readonly bool HasValue = false;
public readonly Module UnityPlayer;
public readonly Module UserAssembly;
public RequiredGameModule(in Module unityPlayer, in Module userAssembly)
public RequiredRemoteModule(in Module unityPlayer, in Module userAssembly)
{
HasValue = true;
UnityPlayer = unityPlayer;

View File

@@ -0,0 +1,20 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Service.Game.Unlocker;
internal readonly struct UnlockOptions
{
public readonly GameFileSystem GameFileSystem;
public readonly TimeSpan FindModuleDelay;
public readonly TimeSpan FindModuleLimit;
public readonly TimeSpan AdjustFpsDelay;
public UnlockOptions(GameFileSystem gameFileSystem, int findModuleDelayMilliseconds, int findModuleLimitMilliseconds, int adjustFpsDelayMilliseconds)
{
GameFileSystem = gameFileSystem;
FindModuleDelay = TimeSpan.FromMilliseconds(findModuleDelayMilliseconds);
FindModuleLimit = TimeSpan.FromMilliseconds(findModuleLimitMilliseconds);
AdjustFpsDelay = TimeSpan.FromMilliseconds(adjustFpsDelayMilliseconds);
}
}

View File

@@ -1,38 +0,0 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Service.Game.Unlocker;
/// <summary>
/// 解锁时机选项
/// </summary>
internal readonly struct UnlockTimingOptions
{
/// <summary>
/// 每次查找 Module 的延时
/// </summary>
public readonly TimeSpan FindModuleDelay;
/// <summary>
/// 查找 Module 的最大时间阈值
/// </summary>
public readonly TimeSpan FindModuleLimit;
/// <summary>
/// 每次循环调整的间隔时间
/// </summary>
public readonly TimeSpan AdjustFpsDelay;
/// <summary>
/// 构造一个新的解锁器选项
/// </summary>
/// <param name="findModuleDelayMilliseconds">每次查找UnityPlayer的延时,推荐100毫秒</param>
/// <param name="findModuleLimitMilliseconds">查找UnityPlayer的最大阈值,推荐10000毫秒</param>
/// <param name="adjustFpsDelayMilliseconds">每次循环调整的间隔时间推荐2000毫秒</param>
public UnlockTimingOptions(int findModuleDelayMilliseconds, int findModuleLimitMilliseconds, int adjustFpsDelayMilliseconds)
{
FindModuleDelay = TimeSpan.FromMilliseconds(findModuleDelayMilliseconds);
FindModuleLimit = TimeSpan.FromMilliseconds(findModuleLimitMilliseconds);
AdjustFpsDelay = TimeSpan.FromMilliseconds(adjustFpsDelayMilliseconds);
}
}

View File

@@ -26,7 +26,7 @@ internal sealed partial class DailyNoteRefreshJobScheduler : IJobScheduler
ITrigger dailyNoteTrigger = TriggerBuilder.Create()
.WithIdentity(JobIdentity.DailyNoteRefreshTriggerName, JobIdentity.DailyNoteGroupName)
.StartNow()
.WithSimpleSchedule(builder => builder.WithIntervalInMinutes(interval).RepeatForever())
.WithSimpleSchedule(builder => builder.WithIntervalInSeconds(interval).RepeatForever())
.Build();
await scheduler.ScheduleJob(dailyNoteJob, dailyNoteTrigger).ConfigureAwait(false);

View File

@@ -31,14 +31,14 @@
<Slider
MinWidth="160"
Margin="32,0,0,0"
Maximum="160"
Maximum="{Binding DailyNote.MaxResin}"
Minimum="0"
Value="{Binding ResinNotifyThreshold, Mode=TwoWay}"/>
</clw:SettingsCard>
<clw:SettingsCard Padding="16,8" Header="{shcm:ResourceString Name=ViewDialogDailyNoteNotificationHomeCoinNotifyThreshold}">
<Slider
MinWidth="160"
Maximum="2400"
Maximum="{Binding DailyNote.MaxHomeCoin}"
Minimum="0"
Value="{Binding HomeCoinNotifyThreshold, Mode=TwoWay}"/>
</clw:SettingsCard>

View File

@@ -100,6 +100,6 @@ internal sealed partial class LaunchGameShared
[Command("HandleGamePathNullOrEmptyCommand")]
private void HandleGamePathNullOrEmpty()
{
navigationService.Navigate<LaunchGamePage>(INavigationAwaiter.Default);
navigationService.Navigate<LaunchGamePage>(INavigationAwaiter.Default, true);
}
}

View File

@@ -8,4 +8,8 @@ namespace Snap.Hutao.Win32.Foundation;
internal readonly struct HMODULE
{
public readonly nint Value;
public static unsafe implicit operator HMODULE(nint value) => *(HMODULE*)&value;
public static unsafe implicit operator nint(HMODULE module) => *(nint*)&module;
}

View File

@@ -4,6 +4,7 @@
using Snap.Hutao.Win32.Foundation;
using Snap.Hutao.Win32.Security;
using Snap.Hutao.Win32.System.Console;
using Snap.Hutao.Win32.System.LibraryLoader;
using Snap.Hutao.Win32.System.ProcessStatus;
using System.Diagnostics;
using System.Runtime.InteropServices;
@@ -41,6 +42,10 @@ internal static class Kernel32
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static extern BOOL FreeConsole();
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static extern BOOL FreeLibrary(HMODULE hLibModule);
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static unsafe extern BOOL GetConsoleMode(HANDLE hConsoleHandle, CONSOLE_MODE* lpMode);
@@ -96,6 +101,19 @@ internal static class Kernel32
}
}
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static extern HMODULE LoadLibraryExW(PCWSTR lpLibFileName, [AllowNull] HANDLE hFile, LOAD_LIBRARY_FLAGS dwFlags);
[DebuggerStepThrough]
public static unsafe HMODULE LoadLibraryExW(ReadOnlySpan<char> libFileName, [AllowNull] HANDLE hFile, LOAD_LIBRARY_FLAGS dwFlags)
{
fixed (char* lpLibFileName = libFileName)
{
return LoadLibraryExW(lpLibFileName, hFile, dwFlags);
}
}
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static unsafe extern BOOL ReadProcessMemory(HANDLE hProcess, void* lpBaseAddress, void* lpBuffer, nuint nSize, [MaybeNull] nuint* lpNumberOfBytesRead);

View File

@@ -159,4 +159,4 @@ internal enum FACILITY_CODE : uint
FACILITY_GAME = 2340u,
FACILITY_PIX = 2748u,
FACILITY_NT_BIT = 268435456u,
}
}

View File

@@ -0,0 +1,10 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Win32.System.Diagnostics.Debug;
internal struct IMAGE_DATA_DIRECTORY
{
public uint VirtualAddress;
public uint Size;
}

View File

@@ -0,0 +1,26 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Win32.System.Diagnostics.Debug;
[Flags]
internal enum IMAGE_DLL_CHARACTERISTICS : ushort
{
IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA = 0x20,
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE = 0x40,
IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY = 0x80,
IMAGE_DLLCHARACTERISTICS_NX_COMPAT = 0x100,
IMAGE_DLLCHARACTERISTICS_NO_ISOLATION = 0x200,
IMAGE_DLLCHARACTERISTICS_NO_SEH = 0x400,
IMAGE_DLLCHARACTERISTICS_NO_BIND = 0x800,
IMAGE_DLLCHARACTERISTICS_APPCONTAINER = 0x1000,
IMAGE_DLLCHARACTERISTICS_WDM_DRIVER = 0x2000,
IMAGE_DLLCHARACTERISTICS_GUARD_CF = 0x4000,
IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000,
IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT = 1,
IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT_STRICT_MODE = 2,
IMAGE_DLLCHARACTERISTICS_EX_CET_SET_CONTEXT_IP_VALIDATION_RELAXED_MODE = 4,
IMAGE_DLLCHARACTERISTICS_EX_CET_DYNAMIC_APIS_ALLOW_IN_PROC = 8,
IMAGE_DLLCHARACTERISTICS_EX_CET_RESERVED_1 = 0x10,
IMAGE_DLLCHARACTERISTICS_EX_CET_RESERVED_2 = 0x20,
}

View File

@@ -0,0 +1,24 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Win32.System.Diagnostics.Debug;
[Flags]
internal enum IMAGE_FILE_CHARACTERISTICS : ushort
{
IMAGE_FILE_RELOCS_STRIPPED = 0x1,
IMAGE_FILE_EXECUTABLE_IMAGE = 0x2,
IMAGE_FILE_LINE_NUMS_STRIPPED = 0x4,
IMAGE_FILE_LOCAL_SYMS_STRIPPED = 0x8,
IMAGE_FILE_AGGRESIVE_WS_TRIM = 0x10,
IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x20,
IMAGE_FILE_BYTES_REVERSED_LO = 0x80,
IMAGE_FILE_32BIT_MACHINE = 0x100,
IMAGE_FILE_DEBUG_STRIPPED = 0x200,
IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x400,
IMAGE_FILE_NET_RUN_FROM_SWAP = 0x800,
IMAGE_FILE_SYSTEM = 0x1000,
IMAGE_FILE_DLL = 0x2000,
IMAGE_FILE_UP_SYSTEM_ONLY = 0x4000,
IMAGE_FILE_BYTES_REVERSED_HI = 0x8000,
}

View File

@@ -0,0 +1,17 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Win32.System.SystemInformation;
namespace Snap.Hutao.Win32.System.Diagnostics.Debug;
internal struct IMAGE_FILE_HEADER
{
public IMAGE_FILE_MACHINE Machine;
public ushort NumberOfSections;
public uint TimeDateStamp;
public uint PointerToSymbolTable;
public uint NumberOfSymbols;
public ushort SizeOfOptionalHeader;
public IMAGE_FILE_CHARACTERISTICS Characteristics;
}

View File

@@ -0,0 +1,11 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Win32.System.Diagnostics.Debug;
internal struct IMAGE_NT_HEADERS64
{
public uint Signature;
public IMAGE_FILE_HEADER FileHeader;
public IMAGE_OPTIONAL_HEADER64 OptionalHeader;
}

View File

@@ -0,0 +1,50 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Snap.Hutao.Win32.System.Diagnostics.Debug;
[StructLayout(LayoutKind.Sequential, Pack = 4)]
internal struct IMAGE_OPTIONAL_HEADER64
{
public IMAGE_OPTIONAL_HEADER_MAGIC Magic;
public byte MajorLinkerVersion;
public byte MinorLinkerVersion;
public uint SizeOfCode;
public uint SizeOfInitializedData;
public uint SizeOfUninitializedData;
public uint AddressOfEntryPoint;
public uint BaseOfCode;
public ulong ImageBase;
public uint SectionAlignment;
public uint FileAlignment;
public ushort MajorOperatingSystemVersion;
public ushort MinorOperatingSystemVersion;
public ushort MajorImageVersion;
public ushort MinorImageVersion;
public ushort MajorSubsystemVersion;
public ushort MinorSubsystemVersion;
public uint Win32VersionValue;
public uint SizeOfImage;
public uint SizeOfHeaders;
public uint CheckSum;
public IMAGE_SUBSYSTEM Subsystem;
public IMAGE_DLL_CHARACTERISTICS DllCharacteristics;
public ulong SizeOfStackReserve;
public ulong SizeOfStackCommit;
public ulong SizeOfHeapReserve;
public ulong SizeOfHeapCommit;
[Obsolete]
public uint LoaderFlags;
public uint NumberOfRvaAndSizes;
public IMAGE_DATA_DIRECTORY_16 DataDirectory;
[InlineArray(16)]
internal struct IMAGE_DATA_DIRECTORY_16
{
public IMAGE_DATA_DIRECTORY Value;
}
}

View File

@@ -0,0 +1,12 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Win32.System.Diagnostics.Debug;
internal enum IMAGE_OPTIONAL_HEADER_MAGIC : ushort
{
IMAGE_NT_OPTIONAL_HDR_MAGIC = 523,
IMAGE_NT_OPTIONAL_HDR32_MAGIC = 267,
IMAGE_NT_OPTIONAL_HDR64_MAGIC = 523,
IMAGE_ROM_OPTIONAL_HDR_MAGIC = 263,
}

View File

@@ -0,0 +1,23 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Win32.System.Diagnostics.Debug;
internal enum IMAGE_SUBSYSTEM : ushort
{
IMAGE_SUBSYSTEM_UNKNOWN = 0,
IMAGE_SUBSYSTEM_NATIVE = 1,
IMAGE_SUBSYSTEM_WINDOWS_GUI = 2,
IMAGE_SUBSYSTEM_WINDOWS_CUI = 3,
IMAGE_SUBSYSTEM_OS2_CUI = 5,
IMAGE_SUBSYSTEM_POSIX_CUI = 7,
IMAGE_SUBSYSTEM_NATIVE_WINDOWS = 8,
IMAGE_SUBSYSTEM_WINDOWS_CE_GUI = 9,
IMAGE_SUBSYSTEM_EFI_APPLICATION = 10,
IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11,
IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12,
IMAGE_SUBSYSTEM_EFI_ROM = 13,
IMAGE_SUBSYSTEM_XBOX = 14,
IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16,
IMAGE_SUBSYSTEM_XBOX_CODE_CATALOG = 17,
}

View File

@@ -0,0 +1,23 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Win32.System.LibraryLoader;
[Flags]
internal enum LOAD_LIBRARY_FLAGS : uint
{
DONT_RESOLVE_DLL_REFERENCES = 1U,
LOAD_LIBRARY_AS_DATAFILE = 2U,
LOAD_WITH_ALTERED_SEARCH_PATH = 8U,
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x10U,
LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x20U,
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x40U,
LOAD_LIBRARY_REQUIRE_SIGNED_TARGET = 0x80U,
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x100U,
LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x200U,
LOAD_LIBRARY_SEARCH_USER_DIRS = 0x400U,
LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x800U,
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x1000U,
LOAD_LIBRARY_SAFE_CURRENT_DIRS = 0x2000U,
LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER = 0x4000U,
}

View File

@@ -0,0 +1,46 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Snap.Hutao.Win32.System.SystemInformation;
internal enum IMAGE_FILE_MACHINE : ushort
{
IMAGE_FILE_MACHINE_AXP64 = 644,
IMAGE_FILE_MACHINE_I386 = 332,
IMAGE_FILE_MACHINE_IA64 = 512,
IMAGE_FILE_MACHINE_AMD64 = 34404,
IMAGE_FILE_MACHINE_UNKNOWN = 0,
IMAGE_FILE_MACHINE_TARGET_HOST = 1,
IMAGE_FILE_MACHINE_R3000 = 354,
IMAGE_FILE_MACHINE_R4000 = 358,
IMAGE_FILE_MACHINE_R10000 = 360,
IMAGE_FILE_MACHINE_WCEMIPSV2 = 361,
IMAGE_FILE_MACHINE_ALPHA = 388,
IMAGE_FILE_MACHINE_SH3 = 418,
IMAGE_FILE_MACHINE_SH3DSP = 419,
IMAGE_FILE_MACHINE_SH3E = 420,
IMAGE_FILE_MACHINE_SH4 = 422,
IMAGE_FILE_MACHINE_SH5 = 424,
IMAGE_FILE_MACHINE_ARM = 448,
IMAGE_FILE_MACHINE_THUMB = 450,
IMAGE_FILE_MACHINE_ARMNT = 452,
IMAGE_FILE_MACHINE_AM33 = 467,
IMAGE_FILE_MACHINE_POWERPC = 496,
IMAGE_FILE_MACHINE_POWERPCFP = 497,
IMAGE_FILE_MACHINE_MIPS16 = 614,
IMAGE_FILE_MACHINE_ALPHA64 = 644,
IMAGE_FILE_MACHINE_MIPSFPU = 870,
IMAGE_FILE_MACHINE_MIPSFPU16 = 1126,
IMAGE_FILE_MACHINE_TRICORE = 1312,
IMAGE_FILE_MACHINE_CEF = 3311,
IMAGE_FILE_MACHINE_EBC = 3772,
IMAGE_FILE_MACHINE_M32R = 36929,
IMAGE_FILE_MACHINE_ARM64 = 43620,
IMAGE_FILE_MACHINE_CEE = 49390,
}

View File

@@ -0,0 +1,32 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using System.Runtime.InteropServices;
namespace Snap.Hutao.Win32.System.SystemService;
[SuppressMessage("", "SA1307")]
[SuppressMessage("", "SA1310")]
[StructLayout(LayoutKind.Sequential, Pack = 2)]
internal struct IMAGE_DOS_HEADER
{
public ushort e_magic;
public ushort e_cblp;
public ushort e_cp;
public ushort e_crlc;
public ushort e_cparhdr;
public ushort e_minalloc;
public ushort e_maxalloc;
public ushort e_ss;
public ushort e_sp;
public ushort e_csum;
public ushort e_ip;
public ushort e_cs;
public ushort e_lfarlc;
public ushort e_ovno;
public unsafe fixed ushort e_res[4];
public ushort e_oemid;
public ushort e_oeminfo;
public unsafe fixed ushort e_res2[10];
public int e_lfanew;
}