mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Merge branch 'main' of https://github.com/Xhichn/Snap.Hutao
This commit is contained in:
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "nuget" # See documentation for possible values
|
||||||
|
directory: "/" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
@@ -306,7 +306,7 @@ internal sealed class GameService : IGameService
|
|||||||
game.Start();
|
game.Start();
|
||||||
if (isElevated && launchOptions.MultipleInstances)
|
if (isElevated && launchOptions.MultipleInstances)
|
||||||
{
|
{
|
||||||
await ProcessInterop.DisableProtectionAsync(gamePath).ConfigureAwait(false);
|
await ProcessInterop.DisableProtectionAsync(game, gamePath).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isElevated && launchOptions.UnlockFps)
|
if (isElevated && launchOptions.UnlockFps)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Snap.Hutao.Core.IO;
|
|||||||
using Snap.Hutao.Service.Game.Unlocker;
|
using Snap.Hutao.Service.Game.Unlocker;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Snap.Hutao.Service.Game;
|
namespace Snap.Hutao.Service.Game;
|
||||||
|
|
||||||
@@ -65,22 +66,26 @@ internal static class ProcessInterop
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 尝试禁用mhypbase
|
/// 尝试禁用mhypbase
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="game">游戏进程</param>
|
||||||
/// <param name="gamePath">游戏路径</param>
|
/// <param name="gamePath">游戏路径</param>
|
||||||
/// <returns>是否禁用成功</returns>
|
/// <returns>是否禁用成功</returns>
|
||||||
public static async Task<bool> DisableProtectionAsync(string gamePath)
|
public static async Task<bool> DisableProtectionAsync(Process game, string gamePath)
|
||||||
{
|
{
|
||||||
string? gameFolder = Path.GetDirectoryName(gamePath);
|
string? gameFolder = Path.GetDirectoryName(gamePath);
|
||||||
if (!string.IsNullOrEmpty(gameFolder))
|
if (!string.IsNullOrEmpty(gameFolder))
|
||||||
{
|
{
|
||||||
string mhypbaseDll = Path.Combine(gameFolder, "mhypbase.dll");
|
string pbasePath = Path.Combine(gameFolder, "mhypbase.dll");
|
||||||
string mhypbaseDllBackup = Path.Combine(gameFolder, "mhypbase.dll.backup");
|
SafeHandle handle = File.OpenHandle(pbasePath, share: FileShare.None);
|
||||||
|
while (true) {
|
||||||
File.Move(mhypbaseDll, mhypbaseDllBackup, true);
|
if (game.MainWindowHandle != nint.Zero) {
|
||||||
await Task.Delay(TimeSpan.FromSeconds(12)).ConfigureAwait(false);
|
handle.Close();
|
||||||
File.Move(mhypbaseDllBackup, mhypbaseDll, true);
|
break;
|
||||||
|
}
|
||||||
|
await Task.Delay(100).ConfigureAwait(false);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user