forked from 0xDC00/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPC_Steam_Unity_Soul.Hackers.2.js
More file actions
167 lines (151 loc) · 5.3 KB
/
Copy pathPC_Steam_Unity_Soul.Hackers.2.js
File metadata and controls
167 lines (151 loc) · 5.3 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// ==UserScript==
// @name Soul Hackers 2
// @version
// @author Koukdw
// @description Steam
// * Atlus
// * Unity (IL2CPP)
//
// https://store.steampowered.com/app/1777620/Soul_Hackers_2/
// ==/UserScript==
console.log(`
Known bug: If you quit the game without detaching game get stuck so
Please detach before quitting the game
`)
const Mono = require('./libMono.js');
const {
_module
} = Mono;
const handlerLine = trans.send((s) => s, '250+');
// Subtitle
Mono.setHook('', '.EventSubtitleManager', 'Show', -1, {
onEnter(args) {
console.log('onEnter EventSubtitleManager:Show');
let text = args[1].readMonoString()
let s = cleanText2(text);
handlerLine(s);
}
});
// Dialogue + Name
Mono.setHook('', '.EventTalkController', 'SetMessageText', 5, {
onEnter(args) {
console.log('onEnter EventTalkController:SetMessageText');
let text = args[1].readMonoString();
let name = args[2].readMonoString();
text = cleanText(text);
name = cleanText(name);
handlerLine(name + '\r\n' + text);
}
});
// Choices
Mono.setHook('', 'Game.UI.Common.UISelectWindow', 'SetText', -1, {
onEnter(args) {
console.log('onEnter Game.UI.Common.UISelectWindow:SetText');
let text = args[2].readMonoString();
let s = cleanText(text);
handlerLine(s);
}
});
// Tips
Mono.setHook('', 'Game.Common.TipsManager', 'GetNameMessage', -1, {
onLeave(retValue) {
console.log('onLeave Game.Common.TipsManager:GetNameMessage');
let text = retValue.readMonoString();
let s = cleanText(text);
handlerLine(s);
}
});
Mono.setHook('', 'Game.Common.TipsManager', 'GetTextMessage', -1, {
onLeave(retValue) {
console.log('onLeave Game.Common.TipsManager:GetTextMessage');
let text = retValue.readMonoString();
let s = cleanText2(text);
handlerLine(s);
}
});
// Tutorial
{
const target = Mono.use('AtLib', 'AtLib.AtText').SetText.address;
const targetStr = target.toString();
console.log('Target = ' + targetStr);
let setTextAddr = [];
// find call
const vmAddress = Mono.use('', 'Game.UI.Common.UISystemHelpView').UpdateView.address;
let ins = Instruction.parse(vmAddress);
while (ins.mnemonic !== 'ret') {
if (ins.mnemonic === 'call') {
if (ins.operands[0].type === 'imm') {
if (ins.opStr === targetStr) {
setTextAddr.push(ins);
}
}
}
ins = Instruction.parse(ins.next);
}
setTextAddr.forEach((ins, index) => {
if (index === 0 || index === 2) {
const idaAddress = ins.address.sub(_module.base).add(0x180000000).toString();
console.log('Hooking SetText at ' + idaAddress);
Breakpoint.add(ins.address, function () {
console.log('onEnter: SetText at ' + idaAddress);
let text = this.context.rdx.readMonoString();
let s = cleanText2(text);
handlerLine(s);
});
//// Interceptor makes the game crash
// Interceptor.attach(ins.address, {
// onEnter: function (args) {
// console.log('onEnter: SetText at ' + idaAddress);
// let text = args[1].readMonoString();
// let s = cleanText2(text);
// handlerLine(s);
// }
// });
}
});
}
//// Prompt text (Annoying)
// Mono.setHook('', 'Game.UI.Common.UICommonDialogBox', 'SetText', -1, {
// onEnter(args) {
// console.log('onEnter Game.UI.Common.UICommonDialogBox:SetText');
// let text = args[1].readMonoString();
// handlerLine(text);
// }
// });
//// Prompt choice (Annoying)
// Mono.setHook('', 'Game.UI.Common.UICommonDialogBoxSelector', 'SetText', -1, {
// onEnter(args) {
// console.warn('onEnter Game.UI.Common.UICommonDialogBoxSelector:SetText');
// let text = args[1].readMonoString();
// let s = text;
// handlerLine(s);
// }
// });
//// Notification + spell names (Annoying) uncomment if you really want this
// Mono.setHook('', 'Game.UI.Battle.BattleActionPanel', 'SetText', -1, {
// onEnter(args) {
// console.warn('onEnter Game.UI.Battle.BattleActionPanel:SetText', this.returnAddress.sub(_module.base).add(0x180000000));
// let text = args[1].readMonoString();
// let s = text;
// handlerLine(s);
// }
// });
//// Root hook (get everything)
// Mono.setHook('AtLib', 'AtLib.AtText', 'SetText', -1, {
// onEnter(args) {
// console.warn('onEnter AtLib.AtText:SetText', this.returnAddress.sub(_module.base).add(0x180000000));
// let text = args[1].readMonoString();
// let s = text;
// console.warn(s);
// }
// });
function cleanText(s) {
return s
.replace(/\n+/g, ' ') // single line
.replace(/<\/?[^>]*./g, ''); // remove all html tag
}
// keep the newline (better for big text because otherwise it's hard to read)
function cleanText2(s) {
return s
.replace(/<\/?[^>]*./g, ''); // remove all html tag
}