bun-memory 1.1.26 → 1.1.28

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.
Files changed (2) hide show
  1. package/README.md +31 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -9,9 +9,9 @@ Blazing fast, high-performance Windows process memory manipulation for Bun.
9
9
  ## Features
10
10
 
11
11
  - Attach to processes by name or PID
12
- - Read and write all primitive types, arrays, buffers, and common structures
13
12
  - Efficient, allocation-free operations using user-provided buffers (scratches)
14
13
  - Module enumeration and pointer chain resolution
14
+ - Read and write all primitive types, arrays, buffers, and common structures
15
15
  - Typed helpers for vectors, matrices, colors, and more
16
16
 
17
17
  ## Requirements
@@ -27,6 +27,8 @@ bun add bun-memory
27
27
 
28
28
  ## Quick Start
29
29
 
30
+ ❗ **Important**: [Example: Using Scratches (Recommended)](#example-using-scratches-recommended).
31
+
30
32
  ```ts
31
33
  import Memory from 'bun-memory';
32
34
 
@@ -56,7 +58,7 @@ cs2.close();
56
58
 
57
59
  See the code and type definitions for full details. All methods are documented with concise examples.
58
60
 
59
- ## Example: Efficient Buffer Reuse
61
+ ## Example: Efficient Scratch Reuse
60
62
 
61
63
  ```ts
62
64
  const buffer = Buffer.allocUnsafe(256);
@@ -64,6 +66,12 @@ cs2.read(0x12345678n, buffer); // Fills buffer in-place
64
66
  // …use buffer…
65
67
  ```
66
68
 
69
+ ```ts
70
+ const array = new Float32Array(32);
71
+ cs2.read(0x12345678n, array); // Fills array in-place
72
+ // …use buffer…
73
+ ```
74
+
67
75
  ## Example: Pointer Chains
68
76
 
69
77
  ```ts
@@ -73,15 +81,10 @@ const address = cs2.follow(0x10000000n, [0x10n, 0x20n]);
73
81
  ## Example: Searching Memory
74
82
 
75
83
  ```ts
76
- const needle = Buffer.from([0x48, 0x8b, 0x05]);
77
- const address = cs2.indexOf(needle, 0x10000000n, 0x1000);
78
- if (address !== -1n) {
79
- console.log(`Found at 0x${address.toString(16)}`);
80
- }
81
- ```
82
-
83
- ```ts
84
- const needle = new Uint32Array([0x01, 0x02, 0x03]);
84
+ const needle = Buffer.from([0x01, 0x02, 0x03]);
85
+ // const needle = new Uint8Array([0x01, 0x02, 0x03]);
86
+ // const needle = new Uint32Array([0x012345, 0x123456, 0x234567]);
87
+ // …etc…
85
88
  const address = cs2.indexOf(needle, 0x10000000n, 0x1000);
86
89
  if (address !== -1n) {
87
90
  console.log(`Found at 0x${address.toString(16)}`);
@@ -92,19 +95,35 @@ if (address !== -1n) {
92
95
 
93
96
  ```ts
94
97
  const array = cs2.f32Array(0x12345678n, 4); // Float32Array of length 4
98
+ // const array = cs2.u64Array(0x12345678n, 4);
99
+ // const array = cs2.vector3Array(0x12345678n, 4);
100
+ // …etc…
95
101
  cs2.i32Array(0x12345678n, new Int32Array([1, 2, 3, 4]));
102
+ cs2.u64Array(0x12345678n, new BigUint64Array([1, 2, 3, 4]));
103
+ cs2.vector3Array(0x12345678n, [{ x: 1, y: 2, z: 3 }]);
96
104
  ```
97
105
 
98
106
  ## Example: Using Scratches (Recommended)
99
107
 
100
108
  Scratches let you reuse buffers and typed arrays for repeated memory operations, avoiding unnecessary allocations and maximizing performance. This is the most efficient way to read or write large or frequent data.
101
109
 
110
+ ```ts
111
+ const array = new BigUint64Array(0xf000 / 0x08);
112
+
113
+ while (true) {
114
+ cs2.read(0x10000000n, array); // Updates array without allocations
115
+ for (const element of array) {
116
+ // …use element…
117
+ }
118
+ }
119
+ ```
120
+
102
121
  ```ts
103
122
  const buffer = Buffer.allocUnsafe(256);
104
123
  const array = new Uint64Array(buffer.buffer, buffer.byteOffset, buffer.byteLength / 8);
105
124
 
106
125
  while (true) {
107
- cs2.read(0x10000000n, buffer); // Updates array & buffer without allocations
126
+ cs2.read(0x10000000n, buffer); // Updates both array & buffer without allocations
108
127
  for (const element of array) {
109
128
  // …use element…
110
129
  }
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.1.26",
25
+ "version": "1.1.28",
26
26
  "main": "./index.ts",
27
27
  "keywords": [
28
28
  "bun",