From 3b7d0a125283a4d37fdffd3ec470b0f908f538b1 Mon Sep 17 00:00:00 2001 From: HolographicHat Date: Mon, 26 Jan 2026 16:28:30 +0800 Subject: [PATCH] remove unused code --- YaeAchievementLib/src/Application.cs | 72 ---------------------------- YaeAchievementLib/src/Goshujin.cs | 20 ++------ 2 files changed, 5 insertions(+), 87 deletions(-) diff --git a/YaeAchievementLib/src/Application.cs b/YaeAchievementLib/src/Application.cs index c24ccaa..6bdd0f1 100644 --- a/YaeAchievementLib/src/Application.cs +++ b/YaeAchievementLib/src/Application.cs @@ -1,5 +1,4 @@ using System.Buffers.Binary; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Yae.Utilities; using static Yae.GameMethod; @@ -26,11 +25,8 @@ internal static unsafe class Application { Native.WaitMainWindow(); Log.ResetConsole(); // - RecordChecksum(); - MinHook.Attach(DoCmd, &OnDoCmd, out _doCmd); MinHook.Attach(ToInt32, &OnToInt32, out _toInt32); MinHook.Attach(UpdateNormalProp, &OnUpdateNormalProp, out _updateNormalProp); - MinHook.Attach(EventSystemUpdate, &OnEventSystemUpdate, out _eventSystemUpdate); return 0; } @@ -146,72 +142,4 @@ internal static unsafe class Application { #endregion - #region Checksum - - [StructLayout(LayoutKind.Sequential)] - private struct RecordChecksumCmdData { - - public int Type; - - public void* Buffer; - - public int Length; - - } - - private static readonly RecordChecksumCmdData[] RecordedChecksum = new RecordChecksumCmdData[3]; - - private static void RecordChecksum() { - for (var i = 0; i < 3; i++) { - var buffer = NativeMemory.AllocZeroed(256); - var data = new RecordChecksumCmdData { - Type = i, - Buffer = buffer, - Length = 256 - }; - _ = DoCmd(23, Unsafe.AsPointer(ref data), sizeof(RecordChecksumCmdData)); - RecordedChecksum[i] = data; - //REPL//Log.Trace($"nType={i}, value={new string((sbyte*) buffer, 0, data.Length)}"); - } - } - - private static delegate*unmanaged _doCmd; - - [UnmanagedCallersOnly] - public static int OnDoCmd(int cmdType, void* data, int size) { - var result = _doCmd(cmdType, data, size); - if (cmdType == 23) { - var cmdData = (RecordChecksumCmdData*) data; - if (cmdData->Type < 3) { - var recordedData = RecordedChecksum[cmdData->Type]; - cmdData->Length = recordedData.Length; - Buffer.MemoryCopy(recordedData.Buffer, cmdData->Buffer, recordedData.Length, recordedData.Length); - //REPL//Log.Trace($"Override type {cmdData->Type} result"); - } - } - return result; - } - - #endregion - - #region EnterGate - - private static long _lastTryEnterTime; - - private static delegate*unmanaged _eventSystemUpdate; - - [UnmanagedCallersOnly] - public static void OnEventSystemUpdate(nint @this) { - _eventSystemUpdate(@this); - if (Environment.TickCount64 - _lastTryEnterTime > 200) { - var obj = FindGameObject(NewString("BtnStart"u8.AsPointer())); - if (obj != 0 && SimulatePointerClick(@this, obj)) { - MinHook.Detach((nint) EventSystemUpdate); - } - _lastTryEnterTime = Environment.TickCount64; - } - } - - #endregion - } diff --git a/YaeAchievementLib/src/Goshujin.cs b/YaeAchievementLib/src/Goshujin.cs index 3e88a5c..01c7e6f 100644 --- a/YaeAchievementLib/src/Goshujin.cs +++ b/YaeAchievementLib/src/Goshujin.cs @@ -13,18 +13,8 @@ internal static class CmdId { internal static unsafe class GameMethod { - public static delegate*unmanaged DoCmd { get; set; } - public static delegate*unmanaged UpdateNormalProp { get; set; } - public static delegate*unmanaged NewString { get; set; } - - public static delegate*unmanaged FindGameObject { get; set; } - - public static delegate*unmanaged EventSystemUpdate { get; set; } - - public static delegate*unmanaged SimulatePointerClick { get; set; } - public static delegate*unmanaged ToInt32 { get; set; } public static void** TcpStatePtr { get; set; } @@ -88,12 +78,12 @@ internal static class Goshujin { public static unsafe void LoadMethodTable() { _pipeWriter.Write((byte) 0xFD); - GameMethod.DoCmd = (delegate*unmanaged) Native.RVAToVA(_pipeReader.ReadUInt32()); + _ = _pipeReader.ReadUInt32(); GameMethod.UpdateNormalProp = (delegate*unmanaged) Native.RVAToVA(_pipeReader.ReadUInt32()); - GameMethod.NewString = (delegate*unmanaged) Native.RVAToVA(_pipeReader.ReadUInt32()); - GameMethod.FindGameObject = (delegate*unmanaged) Native.RVAToVA(_pipeReader.ReadUInt32()); - GameMethod.EventSystemUpdate = (delegate*unmanaged) Native.RVAToVA(_pipeReader.ReadUInt32()); - GameMethod.SimulatePointerClick = (delegate*unmanaged) Native.RVAToVA(_pipeReader.ReadUInt32()); + _ = _pipeReader.ReadUInt32(); + _ = _pipeReader.ReadUInt32(); + _ = _pipeReader.ReadUInt32(); + _ = _pipeReader.ReadUInt32(); GameMethod.ToInt32 = (delegate*unmanaged) Native.RVAToVA(_pipeReader.ReadUInt32()); GameMethod.TcpStatePtr = (void**) Native.RVAToVA(_pipeReader.ReadUInt32()); GameMethod.SharedInfoPtr = (void**) Native.RVAToVA(_pipeReader.ReadUInt32());