bun-memory 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +72 -0
- package/index.ts +3 -0
- package/package.json +47 -0
- package/structs/Memory.ts +1301 -0
- package/structs/Win32Error.ts +113 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ObscuritySRL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Memory (Bun + Win32)
|
|
2
|
+
|
|
3
|
+
High-performance Windows process memory utilities for [Bun](https://bun.sh) using `bun:ffi` and Kernel32 APIs.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Bun runtime (uses `bun:ffi`).
|
|
8
|
+
- Windows 10/11 (uses `kernel32.dll`).
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
bun add bun-memory
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Basic example
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import Memory from './Memory';
|
|
22
|
+
|
|
23
|
+
const memory = new Memory('strounter-cike.exe');
|
|
24
|
+
|
|
25
|
+
const clientDLL = memory.modules['client.dll'];
|
|
26
|
+
|
|
27
|
+
if (clientDLL === undefined) {
|
|
28
|
+
// …
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { modBaseAddr: clientBaseAddr, modBaseSize: modBaseSize } = clientDLL;
|
|
32
|
+
|
|
33
|
+
// Write to your ammo…
|
|
34
|
+
const ammoOffset = 0xabcdefn;
|
|
35
|
+
memory.writeUInt32LE(clientBaseAddr + ammoOffset, 0x270f);
|
|
36
|
+
|
|
37
|
+
// Read your health…
|
|
38
|
+
const healthOffset = 0x123456n;
|
|
39
|
+
const healthValue = memory.readUInt32LE(clientBaseAddr + healthOffset);
|
|
40
|
+
console.log('You have %d health…', healthValue); // Your have 100 health…
|
|
41
|
+
|
|
42
|
+
// Find an offset by pattern…
|
|
43
|
+
const otherOffset = memory.findPattern('aa??bbccdd??ff', clientBaseAddr, clientBaseSize);
|
|
44
|
+
const otherValue = memory.readBoolean(otherOffset + 0x1234n);
|
|
45
|
+
|
|
46
|
+
memory.close();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Reading with scratch buffers
|
|
50
|
+
|
|
51
|
+
Many read methods accept an optional `scratch` `Buffer` to avoid allocations:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const myScratch = Buffer.allocUnsafe(0xf000);
|
|
55
|
+
const myView = new BigUint64Array(myScratch.buffer, myScratch.byteOffset, 0xf000 / 0x08);
|
|
56
|
+
|
|
57
|
+
// …
|
|
58
|
+
|
|
59
|
+
while (true) {
|
|
60
|
+
memory.readInto(myAddress, myScratch); // Updates myView with no new allocations…
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
const myScratch = Buffer.allocUnsafe(0x256);
|
|
66
|
+
const myValue = memory.readString(myAddress, myScratch);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Notes
|
|
70
|
+
|
|
71
|
+
- Bun is required; this package relies on `bun:ffi`.
|
|
72
|
+
- Windows is the only supported platform.
|
package/index.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Stev Peifer <stev@bell.net>",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/obscuritysrl/bun-memory/issues"
|
|
5
|
+
},
|
|
6
|
+
"description": "Fast Windows process memory utilities for Bun using bun:ffi.",
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@types/bun": "latest"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./index.ts"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"module": "index.ts",
|
|
15
|
+
"name": "bun-memory",
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"typescript": "^5"
|
|
18
|
+
},
|
|
19
|
+
"private": false,
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git://github.com/obscuritysrl/bun-memory.git"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"version": "1.0.0",
|
|
26
|
+
"main": "./index.ts",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"bun",
|
|
29
|
+
"ffi",
|
|
30
|
+
"windows",
|
|
31
|
+
"win32",
|
|
32
|
+
"memory",
|
|
33
|
+
"process",
|
|
34
|
+
"ReadProcessMemory",
|
|
35
|
+
"WriteProcessMemory",
|
|
36
|
+
"typescript"
|
|
37
|
+
],
|
|
38
|
+
"files": [
|
|
39
|
+
"index.ts",
|
|
40
|
+
"structs/*.ts",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"bun": ">=1.1.0"
|
|
46
|
+
}
|
|
47
|
+
}
|