bun-memory 1.1.15 → 1.1.16
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 +24 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -125,24 +125,35 @@ while (true) {
|
|
|
125
125
|
}
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
const scratch = Buffer.allocUnsafe(0x100);
|
|
130
|
-
memory.read(myAddress, scratch);
|
|
131
|
-
```
|
|
128
|
+
### Searching Memory
|
|
132
129
|
|
|
133
|
-
|
|
134
|
-
const scratch = new Uint32Array(0x10);
|
|
135
|
-
memory.read(myAddress, scratch);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Pattern Scanning
|
|
130
|
+
#### `findPattern`
|
|
139
131
|
|
|
140
132
|
Pattern scanning is temporarily disabled but will return shortly.
|
|
141
133
|
|
|
134
|
+
#### `indexOf`
|
|
135
|
+
|
|
136
|
+
Find the first occurrence of a byte sequence within a memory range and return the absolute address (`bigint`) of the first match, or `-1n` when not found. Accepts any Scratch-compatible input (`Buffer`, `TypedArray`, `DataView`, `ArrayBuffer`, or `SharedArrayBuffer`). No region or protection checking is performed; ensure the range is readable before calling.
|
|
137
|
+
|
|
142
138
|
```ts
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
139
|
+
// Attach…
|
|
140
|
+
const memory = new Memory('cs2.exe');
|
|
141
|
+
|
|
142
|
+
// Get the loaded client.dll…
|
|
143
|
+
const client = cs2.modules['client.dll'];
|
|
144
|
+
|
|
145
|
+
// Choose any Scratch type for the needle (bytes are matched exactly as laid out in memory).
|
|
146
|
+
const needle = Buffer.from([0x48, 0x8b, 0x05, 0x00, 0x00, 0x00, 0x00]);
|
|
147
|
+
// const needle = new Uint8Array([0x48, 0x8B, 0x05, 0x00, 0x00, 0x00, 0x00]);
|
|
148
|
+
// const needle = new Uint32Array([0xDEADBEEF, 0x11223344]);
|
|
149
|
+
// const needle = new DataView(Uint8Array.from([0xde, 0xad, 0xbe, 0xef]).buffer);
|
|
150
|
+
|
|
151
|
+
// Search client.dll for the byte sequence…
|
|
152
|
+
const addeess = memory.indexOf(needle, client.base, client.size);
|
|
153
|
+
|
|
154
|
+
if (address !== -1n) {
|
|
155
|
+
console.log(`Found at 0x${address.toString(16)}`);
|
|
156
|
+
}
|
|
146
157
|
```
|
|
147
158
|
|
|
148
159
|
## Notes
|