mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix ci build
This commit is contained in:
@@ -21,7 +21,7 @@ internal sealed class AppDbContextDesignTimeFactory : IDesignTimeDbContextFactor
|
||||
string userdataDbName = @"D:\Hutao\Userdata.db";
|
||||
return AppDbContext.Create($"Data Source={userdataDbName}");
|
||||
#else
|
||||
throw;
|
||||
throw Must.NeverHappen();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
|
||||
return WriteProcessMemory(process.SafeHandle, (void*)baseAddress, lpBuffer, sizeof(int), null);
|
||||
}
|
||||
|
||||
private static unsafe MODULEENTRY32 UnsafeFindModule(int processId, string moduleName)
|
||||
private static unsafe MODULEENTRY32 UnsafeFindModule(int processId, ReadOnlySpan<byte> moduleName)
|
||||
{
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(CREATE_TOOLHELP_SNAPSHOT_FLAGS.TH32CS_SNAPMODULE, (uint)processId);
|
||||
try
|
||||
@@ -87,7 +87,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
|
||||
bool loop = Module32First(snapshot, &entry);
|
||||
while (loop)
|
||||
{
|
||||
if (entry.th32ProcessID == processId && entry.szModule.AsString() == moduleName)
|
||||
if (entry.th32ProcessID == processId && entry.szModule.AsNullTerminatedReadOnlySpan() == moduleName)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
@@ -110,7 +110,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
|
||||
|
||||
while (true)
|
||||
{
|
||||
MODULEENTRY32 module = UnsafeFindModule(gameProcess.Id, "UnityPlayer.dll");
|
||||
MODULEENTRY32 module = UnsafeFindModule(gameProcess.Id, "UnityPlayer.dll"u8);
|
||||
if (!StructMarshal.IsDefault(module))
|
||||
{
|
||||
return module;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Windows.Win32.Foundation;
|
||||
|
||||
namespace Snap.Hutao.Win32;
|
||||
@@ -18,23 +17,11 @@ internal static class MemoryExtension
|
||||
/// </summary>
|
||||
/// <param name="char256">目标字符数组</param>
|
||||
/// <returns>结果字符串</returns>
|
||||
public static unsafe string AsString(this in __CHAR_256 char256)
|
||||
public static unsafe ReadOnlySpan<byte> AsNullTerminatedReadOnlySpan(this in __CHAR_256 char256)
|
||||
{
|
||||
MemoryMarshal.AsBytes(char256.AsReadOnlySpan());
|
||||
fixed (CHAR* pszModule = &char256._0)
|
||||
fixed (CHAR* pszChar = &char256._0)
|
||||
{
|
||||
return Encoding.UTF8.GetString((byte*)pszModule, StringLength(pszModule));
|
||||
return MemoryMarshal.CreateReadOnlySpanFromNullTerminated((byte*)pszChar);
|
||||
}
|
||||
}
|
||||
|
||||
private static unsafe int StringLength(CHAR* pszStr)
|
||||
{
|
||||
int len = 0;
|
||||
while (*pszStr++ != 0)
|
||||
{
|
||||
++len;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user