forked from sdyxxjj123/AutoTimeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
92 lines (73 loc) · 2.84 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using CodeStage.AntiCheat.ObscuredTypes;
using Neo.IronLua;
namespace PCRAutoTimeline
{
class Program
{
public static long hwnd, addr;
public static long seed_addr;
private static readonly byte[] idcode =
{
0x3c, 0, 0, 0,
0x89, 0x88, 0x88, 0x3C
};
private static readonly byte[] seed_code = Encoding.UTF8.GetBytes(
"_GlobalWindTime\0_WindQuality\0\0\0\0_Wind\0\0\0\0\0\0\0\0\0\0\0_Shininess\0\0\0\0\0\0");
public static (int, float) TryGetInfo(long hwnd, long addr)
{
var data = new byte[16];
NativeFunctions.ReadProcessMemory(hwnd, addr - 0x44, data, 16, 0);
return (BitConverter.ToInt32(data, 0), BitConverter.ToSingle(data, 8));
}
static void Main(string[] args)
{
//Minitouch.connect("localhost", 1111);
//Minitouch.setPos(1, 100, 100);
//Minitouch.press(1);
using var lua = new Lua();
var env = lua.CreateEnvironment();
env.RegisterPackage("autopcr", typeof(Autopcr));
env.RegisterPackage("minitouch", typeof(Minitouch));
var chunk = lua.CompileChunk(File.ReadAllText("timeline.lua"), "timeline.lua", new LuaCompileOptions());
Console.Write("pid>");
var pid = int.Parse(Console.ReadLine());
//var pid = 11892;
hwnd = NativeFunctions.OpenProcess(NativeFunctions.PROCESS_ALL_ACCESS, false, pid);
var tuple = AobscanHelper.Aobscan(hwnd, idcode, addr =>
{
var frame = TryGetInfo(hwnd, addr);
if (frame.Item1 >= 0 && frame.Item1 < 1000 && frame.Item2 > 80 && frame.Item2 < 100)
{
Console.WriteLine($"data found, frameCount = {frame.Item1}, limitTime = {frame.Item2}");
return true;
}
return false;
});
addr = tuple.Item1;
Console.WriteLine($"addr = {addr:x}");
Console.WriteLine();
if (addr == -1)
{
Console.WriteLine("aobscan failed.");
return;
}
seed_addr = AobscanHelper.Aobscan(hwnd, seed_code, addr =>
{
Console.WriteLine($"seed found.");
return true;
}).Item1 - 0x90;
chunk.Run(env);
Console.WriteLine("script finished.");
Minitouch.exit();
Console.ReadLine();
}
}
}