-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecord.ts
105 lines (91 loc) · 2.69 KB
/
record.ts
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
93
94
95
96
97
98
99
100
101
102
103
104
105
let getinputstatePtrSdl = Module.getBaseAddress("xenia_canary.exe").add(0xAFBA60); //xe::hid::InputSystem::GetState
var stateptr : NativePointer;
var keepState = false;
var callcount = 0;
var isRecord = false;
var inputdata = {};
var inp_index = 0;
function nonzero(el : any)
{
return el != 0
};
send("ready");
let recordPlayBack = recv(function(msg){
if(msg["type"] == "playback"){
isRecord = false;
inputdata = msg.data;
} else{
isRecord = true;
}
});
recordPlayBack.wait();
if(isRecord) {
var dumped = false;
Interceptor.attach(getinputstatePtrSdl, {
onEnter: function (args) {
//@ts-ignore
var user_index = args[1].toInt32();
if (user_index == 0) {
keepState = true;
//@ts-ignore
stateptr = args[2];
callcount += 1
} else if (callcount < 1200000) {
keepState = false;
} else {
send("stop");
console.log("recording done due to limit");
Interceptor.detachAll();
}
},
onLeave: function () {
if (keepState) {
var inpstate = stateptr.add(4).readByteArray(12);
//@ts-ignore
let test : number = stateptr.add(5).readU8();
if((test & 0x80) != 0){
send("stop");
console.log("recording done");
Interceptor.detachAll();
return;
}
send("state", inpstate);
}
}
});
} else {
console.log("Playing back");
var limit = Object.keys(inputdata).length;
console.log("Limit: " + limit);
Interceptor.attach(getinputstatePtrSdl,{
onEnter: function(args){
if(callcount >= limit) {
Interceptor.detachAll();
console.log("Playback Done");
send("stop");
return;
}
//@ts-ignore
var user_index = args[1].toInt32();
if (user_index == 0) {
keepState = true;
//@ts-ignore
stateptr = args[2];
}
else{
keepState = false;
}
}, onLeave: function(){
if(keepState) {
// @ts-ignore
stateptr.add(4).writeByteArray(inputdata[callcount]);
// @ts-ignore
if(inputdata[callcount][1] & 0x80 == 0x80){
// @ts-ignore
console.log(inputdata[callcount]);
}
callcount++;
}
}
})
}