mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-06 14:42:52 +08:00
auto enter gate (close #143)
This commit is contained in:
@@ -1,32 +1,30 @@
|
||||
CloseClipboard
|
||||
CreateProcess
|
||||
CreateRemoteThread
|
||||
EmptyClipboard
|
||||
GetConsoleMode
|
||||
GetDC
|
||||
GetDeviceCaps
|
||||
GetModuleHandle
|
||||
GetProcAddress
|
||||
GetStdHandle
|
||||
// kernel32
|
||||
GlobalLock
|
||||
OpenProcess
|
||||
GetStdHandle
|
||||
GlobalUnlock
|
||||
OpenClipboard
|
||||
ResumeThread
|
||||
SetClipboardData
|
||||
Module32Next
|
||||
Module32First
|
||||
CreateProcess
|
||||
LoadLibraryEx
|
||||
VirtualFreeEx
|
||||
VirtualAllocEx
|
||||
GetProcAddress
|
||||
GetConsoleMode
|
||||
SetConsoleMode
|
||||
TerminateProcess
|
||||
VirtualAllocEx
|
||||
VirtualFreeEx
|
||||
WaitForSingleObject
|
||||
CreateRemoteThread
|
||||
WriteProcessMemory
|
||||
|
||||
WaitForSingleObject
|
||||
GetCurrentConsoleFontEx
|
||||
CreateToolhelp32Snapshot
|
||||
|
||||
OpenProcess
|
||||
// psapi
|
||||
GetModuleFileNameEx
|
||||
|
||||
LoadLibraryEx
|
||||
|
||||
CreateToolhelp32Snapshot
|
||||
Module32First
|
||||
Module32Next
|
||||
// user32
|
||||
OpenClipboard
|
||||
CloseClipboard
|
||||
EmptyClipboard
|
||||
SetClipboardData
|
||||
|
||||
@@ -21,6 +21,10 @@ message MethodRvaConfig {
|
||||
uint32 do_cmd = 1;
|
||||
uint32 to_uint16 = 2;
|
||||
uint32 update_normal_prop = 3;
|
||||
uint32 new_string = 4;
|
||||
uint32 find_game_object = 5;
|
||||
uint32 event_system_update = 6;
|
||||
uint32 simulate_pointer_click = 7;
|
||||
}
|
||||
|
||||
message NativeLibConfig {
|
||||
|
||||
@@ -7,8 +7,6 @@ using static YaeAchievement.Utils;
|
||||
|
||||
namespace YaeAchievement;
|
||||
|
||||
// TODO: WndHook
|
||||
|
||||
internal static class Program {
|
||||
|
||||
public static async Task Main(string[] args) {
|
||||
|
||||
@@ -259,6 +259,10 @@ public static class Utils {
|
||||
writer.Write(methodRva.DoCmd);
|
||||
writer.Write(methodRva.ToUint16);
|
||||
writer.Write(methodRva.UpdateNormalProp);
|
||||
writer.Write(methodRva.NewString);
|
||||
writer.Write(methodRva.FindGameObject);
|
||||
writer.Write(methodRva.EventSystemUpdate);
|
||||
writer.Write(methodRva.SimulatePointerClick);
|
||||
break;
|
||||
case 0xFE:
|
||||
_proc!.ResumeMainThread();
|
||||
|
||||
@@ -29,6 +29,7 @@ internal static unsafe class Application {
|
||||
MinHook.Attach(GameMethod.DoCmd, &OnDoCmd, out _doCmd);
|
||||
MinHook.Attach(GameMethod.ToUInt16, &OnToUInt16, out _toUInt16);
|
||||
MinHook.Attach(GameMethod.UpdateNormalProp, &OnUpdateNormalProp, out _updateNormalProp);
|
||||
MinHook.Attach(GameMethod.EventSystemUpdate, &OnEventSystemUpdate, out _eventSystemUpdate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -142,4 +143,24 @@ internal static unsafe class Application {
|
||||
|
||||
#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 = GameMethod.FindGameObject(GameMethod.NewString("BtnStart"u8.AsPointer()));
|
||||
if (obj != 0 && GameMethod.SimulatePointerClick(@this, obj)) {
|
||||
MinHook.Detach((nint) GameMethod.EventSystemUpdate);
|
||||
}
|
||||
_lastTryEnterTime = Environment.TickCount64;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,14 @@ internal static unsafe class GameMethod {
|
||||
|
||||
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; }
|
||||
|
||||
}
|
||||
|
||||
internal static class Goshujin {
|
||||
@@ -77,6 +85,10 @@ internal static class Goshujin {
|
||||
GameMethod.DoCmd = (delegate*unmanaged<int, void*, int, int>) Native.RVAToVA(_pipeReader.ReadUInt32());
|
||||
GameMethod.ToUInt16 = (delegate*unmanaged<byte*, int, ushort>) Native.RVAToVA(_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());
|
||||
}
|
||||
|
||||
public static void ResumeMainThread() {
|
||||
|
||||
@@ -93,6 +93,9 @@ internal static unsafe class Native {
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static nint AsPointer(this ReadOnlySpan<byte> span) => *(nint*) Unsafe.AsPointer(ref span);
|
||||
|
||||
}
|
||||
|
||||
internal static partial class MinHook {
|
||||
@@ -146,6 +149,7 @@ internal static partial class MinHook {
|
||||
/// Uninitialize the MinHook library. You must call this function EXACTLY ONCE at the end of your program.
|
||||
/// </summary>
|
||||
[LibraryImport("libMinHook.x64", EntryPoint = "MH_Uninitialize")]
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
private static partial uint MinHookUninitialize();
|
||||
|
||||
static MinHook() {
|
||||
@@ -168,9 +172,9 @@ internal static partial class MinHook {
|
||||
}
|
||||
|
||||
// todo: auto gen
|
||||
public static unsafe void Attach(delegate*unmanaged<nint, nint, uint, void> origin, delegate*unmanaged<nint, nint, uint, void> handler, out delegate*unmanaged<nint, nint, uint, void> trampoline) {
|
||||
public static unsafe void Attach(delegate*unmanaged<nint, void> origin, delegate*unmanaged<nint, void> handler, out delegate*unmanaged<nint, void> trampoline) {
|
||||
Attach((nint) origin, (nint) handler, out var trampoline1);
|
||||
trampoline = (delegate*unmanaged<nint, nint, uint, void>) trampoline1;
|
||||
trampoline = (delegate*unmanaged<nint, void>) trampoline1;
|
||||
}
|
||||
|
||||
// todo: auto gen
|
||||
|
||||
Reference in New Issue
Block a user