bun-memory 1.1.26 → 1.1.27

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 +28 -11
  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
@@ -56,7 +56,7 @@ cs2.close();
56
56
 
57
57
  See the code and type definitions for full details. All methods are documented with concise examples.
58
58
 
59
- ## Example: Efficient Buffer Reuse
59
+ ## Example: Efficient Scratch Reuse
60
60
 
61
61
  ```ts
62
62
  const buffer = Buffer.allocUnsafe(256);
@@ -64,6 +64,12 @@ cs2.read(0x12345678n, buffer); // Fills buffer in-place
64
64
  // …use buffer…
65
65
  ```
66
66
 
67
+ ```ts
68
+ const array = new Float32Array(32);
69
+ cs2.read(0x12345678n, array); // Fills array in-place
70
+ // …use buffer…
71
+ ```
72
+
67
73
  ## Example: Pointer Chains
68
74
 
69
75
  ```ts
@@ -73,15 +79,10 @@ const address = cs2.follow(0x10000000n, [0x10n, 0x20n]);
73
79
  ## Example: Searching Memory
74
80
 
75
81
  ```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]);
82
+ const needle = Buffer.from([0x01, 0x02, 0x03]);
83
+ // const needle = new Uint8Array([0x01, 0x02, 0x03]);
84
+ // const needle = new Uint32Array([0x012345, 0x123456, 0x234567]);
85
+ // …etc…
85
86
  const address = cs2.indexOf(needle, 0x10000000n, 0x1000);
86
87
  if (address !== -1n) {
87
88
  console.log(`Found at 0x${address.toString(16)}`);
@@ -92,13 +93,29 @@ if (address !== -1n) {
92
93
 
93
94
  ```ts
94
95
  const array = cs2.f32Array(0x12345678n, 4); // Float32Array of length 4
96
+ // const array = cs2.u64Array(0x12345678n, 4);
97
+ // const array = cs2.vector3Array(0x12345678n, 4);
98
+ // …etc…
95
99
  cs2.i32Array(0x12345678n, new Int32Array([1, 2, 3, 4]));
100
+ cs2.u64Array(0x12345678n, new BigUint64Array([1, 2, 3, 4]));
101
+ cs2.vector3Array(0x12345678n, [{ x: 1, y: 2, z: 3 }]);
96
102
  ```
97
103
 
98
104
  ## Example: Using Scratches (Recommended)
99
105
 
100
106
  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
107
 
108
+ ```ts
109
+ const array = new BigUint64Array(0xf000 / 0x08);
110
+
111
+ while (true) {
112
+ cs2.read(0x10000000n, array); // Updates array without allocations
113
+ for (const element of array) {
114
+ // …use element…
115
+ }
116
+ }
117
+ ```
118
+
102
119
  ```ts
103
120
  const buffer = Buffer.allocUnsafe(256);
104
121
  const array = new Uint64Array(buffer.buffer, buffer.byteOffset, buffer.byteLength / 8);
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.27",
26
26
  "main": "./index.ts",
27
27
  "keywords": [
28
28
  "bun",