remove unused code

This commit is contained in:
HolographicHat
2026-01-26 16:28:30 +08:00
parent b14f5b54d7
commit 3b7d0a1252
2 changed files with 5 additions and 87 deletions

View File

@@ -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<int, void*, int, int> _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<nint, void> _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
}

View File

@@ -13,18 +13,8 @@ internal static class CmdId {
internal static unsafe class GameMethod {
public static delegate*unmanaged<int, void*, int, int> DoCmd { get; set; }
public static delegate*unmanaged<nint, int, double, double, int, void> UpdateNormalProp { get; set; }
public static delegate*unmanaged<nint, nint> NewString { get; set; }
public static delegate*unmanaged<nint, nint> FindGameObject { get; set; }
public static delegate*unmanaged<nint, void> EventSystemUpdate { get; set; }
public static delegate*unmanaged<nint, nint, bool> SimulatePointerClick { get; set; }
public static delegate*unmanaged<byte*, int, int> 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<int, void*, int, int>) Native.RVAToVA(_pipeReader.ReadUInt32());
_ = _pipeReader.ReadUInt32();
GameMethod.UpdateNormalProp = (delegate*unmanaged<nint, int, double, double, int, void>) Native.RVAToVA(_pipeReader.ReadUInt32());
GameMethod.NewString = (delegate*unmanaged<nint, nint>) Native.RVAToVA(_pipeReader.ReadUInt32());
GameMethod.FindGameObject = (delegate*unmanaged<nint, nint>) Native.RVAToVA(_pipeReader.ReadUInt32());
GameMethod.EventSystemUpdate = (delegate*unmanaged<nint, void>) Native.RVAToVA(_pipeReader.ReadUInt32());
GameMethod.SimulatePointerClick = (delegate*unmanaged<nint, nint, bool>) Native.RVAToVA(_pipeReader.ReadUInt32());
_ = _pipeReader.ReadUInt32();
_ = _pipeReader.ReadUInt32();
_ = _pipeReader.ReadUInt32();
_ = _pipeReader.ReadUInt32();
GameMethod.ToInt32 = (delegate*unmanaged<byte*, int, int>) Native.RVAToVA(_pipeReader.ReadUInt32());
GameMethod.TcpStatePtr = (void**) Native.RVAToVA(_pipeReader.ReadUInt32());
GameMethod.SharedInfoPtr = (void**) Native.RVAToVA(_pipeReader.ReadUInt32());