Skip to content

Commit 9a0d4fb

Browse files
committed
Tidy up project
- move constants to separate file - add documentation for `memoryjs.closeProcess` - create install script to build the lib on correct target architecture - remove unnecessary dependencies - clean-up eslint rules - add downloads badge to readme - update .npmignore
1 parent 2dbc300 commit 9a0d4fb

File tree

9 files changed

+870
-912
lines changed

9 files changed

+870
-912
lines changed

.eslintrc.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,8 @@ module.exports = {
44
sourceType: 'module'
55
},
66
extends: 'airbnb-base',
7-
'rules': {
8-
'no-console': 0,
9-
'global-require': 0,
10-
'import/no-unresolved': 0,
11-
'no-param-reassign': 0,
12-
'no-shadow': 0,
13-
'import/extensions': 0,
14-
'import/newline-after-import': 0,
15-
'no-multi-assign': 0,
7+
rules: {
168
'linebreak-style': 0,
17-
// allow debugger during development
18-
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
19-
'consistent-return': 0,
20-
}
21-
}
9+
'import/no-unresolved': 0,
10+
},
11+
};

.npmignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
build
22
test.js
33
npm-debug.log
4-
/.npmignore
4+
.vscode
5+
node_modules
6+
test/vcxproj/Debug
7+
test/vcxproj/Release
8+
test/*.exe
9+
test/.vs

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# memoryjs · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Rob--/memoryjs/blob/master/LICENSE.md) [![npm version](https://img.shields.io/npm/v/memoryjs.svg?style=flat)](https://www.npmjs.com/package/memoryjs)
1+
# memoryjs · [![GitHub license](https://img.shields.io/github/license/Rob--/memoryjs)](https://github.com/Rob--/memoryjs/blob/master/LICENSE.md) [![npm version](https://img.shields.io/npm/v/memoryjs.svg?style=flat)](https://www.npmjs.com/package/memoryjs) ![npm](https://img.shields.io/npm/dm/memoryjs)
22

33
memoryjs is an NPM package for reading and writing process memory! (finally!)
44

@@ -76,6 +76,11 @@ memoryjs.openProcess(processIdentifier, (error, processObject) => {
7676
});
7777
```
7878

79+
Close/release process handle:
80+
``` javascript
81+
memoryjs.closeProcess(handle);
82+
```
83+
7984
Get all processes (sync):
8085
``` javascript
8186
const processes = memoryjs.getProcesses();

consts.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
const dataTypes = {
2+
standard: {
3+
BYTE: 'byte',
4+
INT: 'int',
5+
INT32: 'int32',
6+
UINT32: 'uint32',
7+
INT64: 'int64',
8+
UINT64: 'uint64',
9+
DWORD: 'dword',
10+
SHORT: 'short',
11+
LONG: 'long',
12+
FLOAT: 'float',
13+
DOUBLE: 'double',
14+
BOOL: 'bool',
15+
BOOLEAN: 'boolean',
16+
PTR: 'ptr',
17+
POINTER: 'pointer',
18+
STR: 'str',
19+
STRING: 'string',
20+
VEC3: 'vec3',
21+
VECTOR3: 'vector3',
22+
VEC4: 'vec4',
23+
VECTOR4: 'vector4',
24+
},
25+
function: {
26+
T_VOID: 0x0,
27+
T_STRING: 0x1,
28+
T_CHAR: 0x2,
29+
T_BOOL: 0x3,
30+
T_INT: 0x4,
31+
T_DOUBLE: 0x5,
32+
T_FLOAT: 0x6,
33+
},
34+
};
35+
36+
const signatureTypes = {
37+
NORMAL: 0x0,
38+
READ: 0x1,
39+
SUBTRACT: 0x2,
40+
};
41+
42+
const memoryFlags = {
43+
// see: https://docs.microsoft.com/en-gb/windows/desktop/Memory/memory-protection-constants
44+
access: {
45+
PAGE_NOACCESS: 0x01,
46+
PAGE_READONLY: 0x02,
47+
PAGE_READWRITE: 0x04,
48+
PAGE_WRITECOPY: 0x08,
49+
PAGE_EXECUTE: 0x10,
50+
PAGE_EXECUTE_READ: 0x20,
51+
PAGE_EXECUTE_READWRITE: 0x40,
52+
PAGE_EXECUTE_WRITECOPY: 0x80,
53+
PAGE_GUARD: 0x100,
54+
PAGE_NOCACHE: 0x200,
55+
PAGE_WRITECOMBINE: 0x400,
56+
PAGE_ENCLAVE_UNVALIDATED: 0x20000000,
57+
PAGE_TARGETS_NO_UPDATE: 0x40000000,
58+
PAGE_TARGETS_INVALID: 0x40000000,
59+
PAGE_ENCLAVE_THREAD_CONTROL: 0x80000000,
60+
},
61+
62+
// see: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualallocex#parameters
63+
allocation: {
64+
MEM_COMMIT: 0x00001000,
65+
MEM_RESERVE: 0x00002000,
66+
MEM_RESET: 0x00080000,
67+
MEM_TOP_DOWN: 0x00100000,
68+
MEM_RESET_UNDO: 0x1000000,
69+
MEM_LARGE_PAGES: 0x20000000,
70+
MEM_PHYSICAL: 0x00400000,
71+
},
72+
73+
// see: https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_memory_basic_information
74+
page: {
75+
MEM_PRIVATE: 0x20000,
76+
MEM_MAPPED: 0x40000,
77+
MEM_IMAGE: 0x1000000,
78+
},
79+
};
80+
81+
const hardwareDebug = {
82+
registers: {
83+
DR0: 0x0,
84+
DR1: 0x1,
85+
DR2: 0x2,
86+
DR3: 0x3,
87+
},
88+
breakpointTriggerTypes: {
89+
TRIGGER_EXECUTE: 0x0,
90+
TRIGGER_ACCESS: 0x3,
91+
TRIGGER_WRITE: 0x1,
92+
},
93+
};
94+
95+
module.exports = {
96+
// data type constants
97+
...dataTypes.standard,
98+
...dataTypes.function,
99+
100+
// pattern scanning flags
101+
...signatureTypes,
102+
103+
// memory flags
104+
...memoryFlags.access,
105+
...memoryFlags.allocation,
106+
...memoryFlags.page,
107+
108+
// debugger consts
109+
...hardwareDebug.registers,
110+
...hardwareDebug.breakpointTriggerTypes,
111+
};

0 commit comments

Comments
 (0)