-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpatch.js
More file actions
85 lines (84 loc) · 2.17 KB
/
patch.js
File metadata and controls
85 lines (84 loc) · 2.17 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
Object.defineProperties(Module, {
ensureInitialized: {
value: (name) => Process.getModuleByName(name).ensureInitialized(),
},
getSymbolByName: {
value: (module, name) =>
!module
? Module.getGlobalExportByName(name)
: Process.getModuleByName(name).getSymbolByName(name),
},
findSymbolByName: {
value: (module, name) =>
!module
? Module.findGlobalExportByName(name)
: Process.findModuleByName(name)?.findExportByName(name) ?? null,
},
getExportByName: {
value: (module, name) =>
!module
? Module.getGlobalExportByName(name)
: Process.getModuleByName(module).getExportByName(name),
},
findExportByName: {
value: (module, name) =>
!module
? Module.findGlobalExportByName(name)
: Process.findModuleByName(module)?.findExportByName(name) ?? null,
},
getBaseAddress: {
value: (name) => Process.getModuleByName(name).base,
},
findBaseAddress: {
value: (name) => Process.findModuleByName(name)?.base ?? null,
},
});
const memdef = {};
for (const sign of ["U", "S"]) {
for (const type of ["8", "16", "32", "64", "Short", "Int", "Long"]) {
const key = `read${sign}${type}`;
memdef[key] = { value: (ptr) => NULL[key]?.call(ptr) };
}
}
for (const odd of [
"Short",
"Int",
"Long",
"Float",
"Double",
"Pointer",
"ByteArray",
"Byte",
"Volatile",
]) {
const key = `read${odd}`;
memdef[key] = { value: (ptr) => NULL[key]?.call(ptr) };
}
for (const str of ["CString", "Utf8String", "Utf16String", "AnsiSting"]) {
const key = `read${str}`;
memdef[key] = { value: (ptr, len) => NULL[key]?.call(ptr, len) };
}
for (const sign of ["U", "S"]) {
for (const type of ["8", "16", "32", "64", "Short", "Int", "Long"]) {
const key = `write${sign}${type}`;
memdef[key] = { value: (ptr, value) => NULL[key]?.call(ptr, value) };
}
}
for (const odd of [
"Short",
"Int",
"Long",
"Float",
"Double",
"Pointer",
"ByteArray",
"Byte",
"Volatile",
"AnsiSting",
"Utf8String",
"Utf16String",
]) {
const key = `write${odd}`;
memdef[key] = { value: (ptr, value) => NULL[key]?.call(ptr, value) };
}
Object.defineProperties(Memory, memdef);