forked from Rob--/memoryjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
117 lines (94 loc) · 2.95 KB
/
index.js
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
const memoryjs = require('./build/Release/memoryjs');
module.exports = {
// data type constants
INT: 'int',
DWORD: 'dword',
SHORT: 'short',
LONG: 'long',
FLOAT: 'float',
DOUBLE: 'double',
BOOL: 'bool',
BOOLEAN: 'boolean',
PTR: 'ptr',
POINTER: 'pointer',
STR: 'str',
STRING: 'string',
VEC3: 'vec3',
VECTOR3: 'vector3',
VEC4: 'vec4',
VECTOR4: 'vector4',
// signature type constants
NORMAL: 0x0,
READ: 0x1,
SUBTRACT: 0x2,
// Memory access types.
// See: https://docs.microsoft.com/en-gb/windows/desktop/Memory/memory-protection-constants
PAGE_NOACCESS: 0x01,
PAGE_READONLY: 0x02,
PAGE_READWRITE: 0x04,
PAGE_WRITECOPY: 0x08,
PAGE_EXECUTE: 0x10,
PAGE_EXECUTE_READ: 0x20,
PAGE_EXECUTE_READWRITE: 0x40,
PAGE_EXECUTE_WRITECOPY: 0x80,
PAGE_GUARD: 0x100,
PAGE_NOCACHE: 0x200,
PAGE_WRITECOMBINE: 0x400,
PAGE_ENCLAVE_THREAD_CONTROL: 0x80000000,
PAGE_TARGETS_NO_UPDATE: 0x40000000,
PAGE_TARGETS_INVALID: 0x40000000,
PAGE_ENCLAVE_UNVALIDATED: 0x20000000,
openProcess(processIdentifier, callback) {
if (arguments.length === 1) {
return memoryjs.openProcess(processIdentifier);
}
memoryjs.openProcess(processIdentifier, callback);
},
getProcesses(callback) {
if (arguments.length === 0) {
return memoryjs.getProcesses();
}
memoryjs.getProcesses(callback);
},
findModule(moduleName, processId, callback) {
if (arguments.length === 2) {
return memoryjs.findModule(moduleName, processId);
}
memoryjs.findModule(moduleName, processId, callback);
},
getModules(processId, callback) {
if (arguments.length === 1) {
return memoryjs.getModules(processId);
}
memoryjs.getModules(processId, callback);
},
readMemory(handle, address, dataType, callback) {
if (arguments.length === 3) {
return memoryjs.readMemory(handle, address, dataType.toLowerCase());
}
memoryjs.readMemory(handle, address, dataType.toLowerCase(), callback);
},
readBuffer(handle, address, size, callback) {
if (arguments.length === 3) {
return memoryjs.readBuffer(handle, address, size);
}
memoryjs.readBuffer(handle, address, size, callback);
},
writeMemory(handle, address, value, dataType) {
if (dataType === 'str' || dataType === 'string') {
value = value + '\0'; // add terminator
}
return memoryjs.writeMemory(handle, address, value, dataType.toLowerCase());
},
writeBuffer(handle, address, buffer) {
return memoryjs.writeBuffer(handle, address, buffer);
},
findPattern(handle, moduleName, signature, signatureType, patternOffset, addressOffset, callback) {
if (arguments.length === 6) {
return memoryjs.findPattern(handle, moduleName, signature, signatureType, patternOffset, addressOffset);
}
memoryjs.findPattern(handle, moduleName, signature, signatureType, patternOffset, addressOffset, callback);
},
setProtection: memoryjs.setProtection,
closeProcess: memoryjs.closeProcess,
};