1.6.5 rc1

This commit is contained in:
Lightczx
2023-06-10 19:01:15 +08:00
parent 356c157ab2
commit e59a1c5444
8 changed files with 102 additions and 97 deletions

View File

@@ -61,4 +61,46 @@ internal static partial class EnumerableExtension
{ {
return new ObservableCollection<T>(source); return new ObservableCollection<T>(source);
} }
/// <summary>
/// Concatenates each element from the collection into single string.
/// </summary>
/// <typeparam name="T">Type of array elements.</typeparam>
/// <param name="collection">Collection to convert. Cannot be <see langword="null"/>.</param>
/// <param name="separator">Delimiter between elements in the final string.</param>
/// <param name="defaultValue">A string to be returned if collection has no elements.</param>
/// <returns>Converted collection into string.</returns>
public static string ToString<T>(this IEnumerable<T> collection, string separator, string defaultValue = "")
{
string result = string.Join(separator, collection);
if (result.Length > 0)
{
return result;
}
else
{
return defaultValue;
}
}
/// <summary>
/// Concatenates each element from the collection into single string.
/// </summary>
/// <typeparam name="T">Type of array elements.</typeparam>
/// <param name="collection">Collection to convert. Cannot be <see langword="null"/>.</param>
/// <param name="separator">Delimiter between elements in the final string.</param>
/// <param name="defaultValue">A string to be returned if collection has no elements.</param>
/// <returns>Converted collection into string.</returns>
public static string ToString<T>(this IEnumerable<T> collection, char separator = ',', string defaultValue = "")
{
string result = string.Join(separator, collection);
if (result.Length > 0)
{
return result;
}
else
{
return defaultValue;
}
}
} }

View File

@@ -15,7 +15,7 @@ internal enum AchievementStatus
STATUS_UNRECOGNIZED = -1, STATUS_UNRECOGNIZED = -1,
/// <summary> /// <summary>
/// 非法值 /// 不使用的成就
/// </summary> /// </summary>
STATUS_INVALID = 0, STATUS_INVALID = 0,

View File

@@ -7,80 +7,22 @@ namespace Snap.Hutao.Model.Intrinsic;
/// 元素类型 /// 元素类型
/// </summary> /// </summary>
[HighQuality] [HighQuality]
[SuppressMessage("", "SA1602")]
internal enum ElementType internal enum ElementType
{ {
/// <summary> None = 0, // 无元素
/// 元素 Fire = 1, // 元素
/// </summary> Water = 2, // 水元素
None = 0, Grass = 3, // 草元素
Electric = 4, // 雷元素
/// <summary> Ice = 5, // 冰元素
/// 元素 Frozen = 6, // 元素
/// </summary> Wind = 7, // 风元素
Fire = 1, Rock = 8, // 岩元素
AntiFire = 9, // 燃元素
/// <summary> VehicleMuteIce = 10, // 枫丹玩法
/// 水元素 Mushroom = 11, // 弹弹菇
/// </summary> Overdose = 12, // 激元素
Water = 2, Wood = 13, // 木元素
Count = 14, // 个数
/// <summary>
/// 草元素
/// </summary>
Grass = 3,
/// <summary>
/// 雷元素
/// </summary>
Electric = 4,
/// <summary>
/// 冰元素
/// </summary>
Ice = 5,
/// <summary>
/// 冻元素
/// </summary>
Frozen = 6,
/// <summary>
/// 风元素
/// </summary>
Wind = 7,
/// <summary>
/// 岩元素
/// </summary>
Rock = 8,
/// <summary>
/// 燃元素
/// </summary>
AntiFire = 9,
/// <summary>
/// 枫丹玩法
/// </summary>
VehicleMuteIce = 10,
/// <summary>
/// 弹弹菇
/// </summary>
Mushroom = 11,
/// <summary>
/// 激元素
/// </summary>
Overdose = 12,
/// <summary>
/// 木元素
/// </summary>
Wood = 13,
/// <summary>
/// 个数
/// </summary>
Count = 14,
} }

View File

@@ -25,7 +25,7 @@ public static partial class Program
[STAThread] [STAThread]
private static void Main(string[] args) private static void Main(string[] args)
{ {
System.Diagnostics.Debug.WriteLine($"[Arguments]:{args}"); System.Diagnostics.Debug.WriteLine($"[Arguments]:[{EnumerableExtension.ToString(args)}]");
XamlCheckProcessRequirements(); XamlCheckProcessRequirements();
ComWrappersSupport.InitializeComWrappers(); ComWrappersSupport.InitializeComWrappers();

View File

@@ -3,6 +3,7 @@
using Snap.Hutao.Core.Diagnostics; using Snap.Hutao.Core.Diagnostics;
using Snap.Hutao.Core.ExceptionService; using Snap.Hutao.Core.ExceptionService;
using Snap.Hutao.Win32.Memory;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Windows.Win32.Foundation; using Windows.Win32.Foundation;
@@ -235,7 +236,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
using (localMemory) using (localMemory)
{ {
int offset = IndexOfPattern(localMemory.GetBuffer()[(int)moduleEntryInfo.UnityPlayer.Size..]); int offset = IndexOfPattern(localMemory.Span[(int)moduleEntryInfo.UnityPlayer.Size..]);
Must.Range(offset >= 0, SH.ServiceGameUnlockerInterestedPatternNotFound); Must.Range(offset >= 0, SH.ServiceGameUnlockerInterestedPatternNotFound);
byte* pLocalMemory = (byte*)localMemory.Pointer; byte* pLocalMemory = (byte*)localMemory.Pointer;

View File

@@ -84,7 +84,7 @@ internal sealed partial class MetadataOptions : IOptions<MetadataOptions>
/// <returns>服务器上的本地化元数据文件</returns> /// <returns>服务器上的本地化元数据文件</returns>
public string GetLocalizedRemoteFile(string fileNameWithExtension) public string GetLocalizedRemoteFile(string fileNameWithExtension)
{ {
return Web.HutaoEndpoints.RawGithubUserContentMetadataFile(LocaleName, fileNameWithExtension); return Web.HutaoEndpoints.HutaoMetadata2File(LocaleName, fileNameWithExtension);
} }
private string GetLocaleName() private string GetLocaleName()

View File

@@ -0,0 +1,25 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
namespace Snap.Hutao.Win32.Memory;
/// <summary>
/// 非托管内存
/// </summary>
internal unsafe interface IUnmanagedMemory : IDisposable
{
/// <summary>
/// Gets a pointer to the allocated unmanaged memory.
/// </summary>
void* Pointer { get; }
/// <summary>
/// Gets size of referenced unmanaged memory, in bytes.
/// </summary>
uint Size { get; }
/// <summary>
/// Gets a span of bytes from the current instance.
/// </summary>
Span<byte> Span { get; }
}

View File

@@ -4,22 +4,22 @@
using Windows.Win32.System.Memory; using Windows.Win32.System.Memory;
using static Windows.Win32.PInvoke; using static Windows.Win32.PInvoke;
namespace Snap.Hutao.Service.Game.Unlocker; namespace Snap.Hutao.Win32.Memory;
/// <summary> /// <summary>
/// NativeMemory.AllocZeroed wrapper /// NativeMemory.AllocZeroed wrapper
/// </summary> /// </summary>
internal readonly unsafe struct VirtualMemory : IDisposable internal readonly unsafe struct VirtualMemory : IUnmanagedMemory
{ {
/// <summary> /// <summary>
/// 缓冲区地址 /// 缓冲区地址
/// </summary> /// </summary>
public readonly void* Pointer; private readonly void* pointer;
/// <summary> /// <summary>
/// 长度 /// 长度
/// </summary> /// </summary>
public readonly uint Length; private readonly uint size;
/// <summary> /// <summary>
/// 构造一个新的本地内存 /// 构造一个新的本地内存
@@ -27,28 +27,23 @@ internal readonly unsafe struct VirtualMemory : IDisposable
/// <param name="dwSize">长度</param> /// <param name="dwSize">长度</param>
public unsafe VirtualMemory(uint dwSize) public unsafe VirtualMemory(uint dwSize)
{ {
Length = dwSize; size = dwSize;
VIRTUAL_ALLOCATION_TYPE commitAndReserve = VIRTUAL_ALLOCATION_TYPE.MEM_COMMIT | VIRTUAL_ALLOCATION_TYPE.MEM_RESERVE; VIRTUAL_ALLOCATION_TYPE commitAndReserve = VIRTUAL_ALLOCATION_TYPE.MEM_COMMIT | VIRTUAL_ALLOCATION_TYPE.MEM_RESERVE;
Pointer = VirtualAlloc(default, dwSize, commitAndReserve, PAGE_PROTECTION_FLAGS.PAGE_READWRITE); pointer = VirtualAlloc(default, dwSize, commitAndReserve, PAGE_PROTECTION_FLAGS.PAGE_READWRITE);
} }
public static unsafe implicit operator Span<byte>(VirtualMemory memory) /// <inheritdoc/>
{ public void* Pointer { get => pointer; }
return memory.GetBuffer();
}
/// <summary> /// <inheritdoc/>
/// 获取缓冲区 public uint Size { get => size; }
/// </summary>
/// <returns>内存</returns> /// <inheritdoc/>
public unsafe Span<byte> GetBuffer() public Span<byte> Span { get => new(pointer, (int)size); }
{
return new Span<byte>(Pointer, (int)Length);
}
/// <inheritdoc/> /// <inheritdoc/>
public void Dispose() public void Dispose()
{ {
VirtualFree(Pointer, 0, VIRTUAL_FREE_TYPE.MEM_RELEASE); VirtualFree(pointer, 0, VIRTUAL_FREE_TYPE.MEM_RELEASE);
} }
} }