-
Notifications
You must be signed in to change notification settings - Fork 13
/
platform.ts
51 lines (48 loc) · 1.42 KB
/
platform.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
/** @internal */
export const il2CppLibraryName =
Process.platform == "linux"
? "libil2cpp.so"
: Process.platform == "windows"
? "GameAssembly.dll"
: Process.platform == "darwin"
? undefined
: undefined;
/** @internal */
export const unityLibraryName =
Process.platform == "linux"
? "libunity.so"
: Process.platform == "windows"
? "UnityPlayer.dll"
: Process.platform == "darwin"
? undefined
: undefined;
/** @internal */
const loader =
Process.platform == "linux"
? Module.getExportByName("libc.so", "dlopen")
: Process.platform == "windows"
? undefined
: Process.platform == "darwin"
? undefined
: undefined;
/** @internal */
export function forLibrary(libraryName: string): Promise<void> {
return new Promise(resolve => {
const library = Process.findModuleByName(libraryName);
if (library != null) {
resolve();
} else {
const interceptor = Interceptor.attach(loader!, {
onEnter(args) {
this.isMatch = args[0].readCString()?.endsWith(libraryName);
},
onLeave() {
if (this.isMatch) {
setTimeout(() => interceptor.detach());
resolve();
}
}
});
}
});
}