bun-memory 1.0.3 → 1.1.1

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/README.md CHANGED
@@ -1,11 +1,20 @@
1
- # Memory (Bun + Win32)
1
+ # bun-memory
2
2
 
3
- High-performance Windows process memory utilities for [Bun](https://bun.sh) using `bun:ffi` and Kernel32 APIs.
3
+ High-performance Windows process memory utilities for [Bun](https://bun.sh) using `bun:ffi` and Win32 APIs.
4
+
5
+ ## Features
6
+
7
+ - Built for Bun runtime and Windows 10/11
8
+ - Efficient buffer management for high-speed operations
9
+ - Pattern scanning for offsets \*
10
+ - Read and write memory of Windows processes
11
+
12
+ \* — Feature temporarily disabled
4
13
 
5
14
  ## Requirements
6
15
 
7
- - Bun runtime (uses `bun:ffi`).
8
- - Windows 10/11 (uses `kernel32.dll`).
16
+ - **Bun** (uses `bun:ffi`)
17
+ - **Windows 10/11** (uses `kernel32.dll`)
9
18
 
10
19
  ## Installation
11
20
 
@@ -15,62 +24,56 @@ bun add bun-memory
15
24
 
16
25
  ## Usage
17
26
 
18
- ### Basic example
27
+ ### Basic Example
19
28
 
20
29
  ```ts
21
30
  import Memory from 'bun-memory';
22
31
 
23
- const memory = new Memory('strounter-cike.exe');
32
+ // Attach to process by name…
33
+ const memory = new Memory('notepad.exe');
34
+ // …or PID
35
+ const memory = new Memory(1234);
24
36
 
25
- const clientDLL = memory.modules['client.dll'];
37
+ // Access loaded modules
38
+ const modules = memory.modules;
39
+ const mainModule = modules['notepad.exe'];
40
+ console.log(`Base address: 0x${mainModule.modBaseAddr.toString(16)}`);
41
+ console.log(`Size: ${mainModule.modBaseSize} bytes`);
26
42
 
27
- if (clientDLL === undefined) {
28
- //
29
- }
30
-
31
- const { modBaseAddr: clientBaseAddr, modBaseSize: modBaseSize } = clientDLL;
43
+ // Read a 32-bit integer
44
+ const value = memory.i32(0x12345678n);
32
45
 
33
- // Write to your ammo…
34
- const ammoOffset = 0xabcdefn;
35
- memory.writeUInt32LE(clientBaseAddr + ammoOffset, 0x270f);
46
+ // Write a float
47
+ memory.f32(0x12345678n, 3.14159);
36
48
 
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…
49
+ // Clean up
50
+ memory.close();
51
+ ```
41
52
 
42
- // Find an offset by pattern…
43
- const otherOffset = memory.findPattern('aa??bbccdd??ff', clientBaseAddr, clientBaseSize);
44
- const otherValue = memory.readBoolean(otherOffset + 0x1234n);
53
+ ### Pattern Scanning
45
54
 
55
+ ```ts
56
+ const offset = memory.findPattern('aa??bbccdd??ff', mainModule.modBaseAddr, mainModule.modBaseSize);
57
+ const value = memory.bool(offset + 0x1234n);
46
58
  memory.close();
47
59
  ```
48
60
 
49
- ### Reading with scratch buffers
50
-
51
- Many read methods accept an optional `scratch` `Buffer` to avoid allocations:
61
+ ### Efficient Buffer Reads
52
62
 
53
63
  ```ts
54
- const myScratch = Buffer.allocUnsafe(0xf000);
55
- const myView = new BigUint64Array(myScratch.buffer, myScratch.byteOffset, 0xf000 / 0x08);
56
-
57
- // …
64
+ const scratch = Buffer.allocUnsafe(0xf000);
65
+ const view = new BigUint64Array(scratch.buffer, scratch.byteOffset, 0xf000 / 8);
58
66
 
59
67
  while (true) {
60
- memory.readInto(myAddress, myScratch); // Updates myView with no new allocations
61
-
62
- // …or…
63
-
64
- memory.readBuffer(myAddress, 0xf000, myScratch); // Also updates myView with no new allocations…
68
+ memory.read(myAddress, scratch); // Updates scratch and view, no allocations
65
69
  }
66
70
  ```
67
71
 
68
72
  ```ts
69
- const myScratch = Buffer.allocUnsafe(0x100);
70
- const myValue = memory.readString(myAddress, 0x100, myScratch);
73
+ const scratch = Buffer.allocUnsafe(0x100);
74
+ memory.read(myAddress, scratch);
71
75
  ```
72
76
 
73
- ### Notes
77
+ ## Notes
74
78
 
75
- - Bun is required; this package relies on `bun:ffi`.
76
- - Windows is the only supported platform.
79
+ - Only works with Bun and Windows.
package/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import './runtime/extensions';
1
2
  import Memory from './structs/Memory';
2
3
 
3
4
  export default Memory;
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "url": "git://github.com/obscuritysrl/bun-memory.git"
23
23
  },
24
24
  "type": "module",
25
- "version": "1.0.3",
25
+ "version": "1.1.1",
26
26
  "main": "./index.ts",
27
27
  "keywords": [
28
28
  "bun",