-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcmdlet.js
42 lines (38 loc) · 894 Bytes
/
cmdlet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function dumpStuff(tokens, name, length) {
if (tokens.length !== 1) throw new Error("expected 1 argument");
const address = tokens[0].toVar().toPointer();
Output.writeln(`${name}: ${address}`);
const bytes = Mem.readBytes(address, length);
const dump = hexdump(bytes.buffer, {
length: length,
header: true,
ansi: true,
address: address,
});
const prefixed = dump.split('\n').join(`\n${Output.green("0x")}`);
Output.writeln(` ${prefixed}`);
}
return [
{
name: "test1",
runSync: function(tokens) {
try {
dumpStuff(tokens, "test1", 16);
return Var.ZERO;
} catch {
return this.usage();
}
},
},
{
name: "test2",
runSync: function(tokens) {
try {
dumpStuff(tokens, "test2", 32);
return Var.ZERO;
} catch {
return this.usage();
}
},
},
]