Skip to content

Commit 408a81c

Browse files
author
Your Name
committed
Fix issues with disassembly
Tidy message Bump version
1 parent b870996 commit 408a81c

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frida-cshell",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "Frida's CShell",
55
"scripts": {
66
"prepare": "npm run build && npm run version && npm run package && npm run copy",

src/cmdlets/data/assembly.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Format } from '../../misc/format.js';
44
import { Token } from '../../io/token.js';
55
import { Var } from '../../vars/var.js';
66
import { Mem } from '../../memory/mem.js';
7+
import { Overlay } from '../../memory/overlay.js';
78

89
export class AssemblyCmdLet extends CmdLet {
910
name = 'l';
@@ -47,6 +48,7 @@ l address <bytes> - show disassembly listing
4748
try {
4849
const minLength = this.maxInstructionLen();
4950
const copy = Memory.alloc(Process.pageSize);
51+
let hasOverlaps = false;
5052

5153
for (let i = 1; i <= length; i++) {
5254
if (buffer.byteLength < minLength) {
@@ -58,7 +60,15 @@ l address <bytes> - show disassembly listing
5860
}
5961

6062
Mem.writeBytes(copy, buffer);
61-
const insn = Instruction.parse(copy.add(isThumb ? 1 : 0));
63+
64+
let insn = Instruction.parse(cursor.add(isThumb ? 1 : 0));
65+
const overlaps = Overlay.overlaps(cursor, insn.size);
66+
67+
if (overlaps) {
68+
hasOverlaps = true;
69+
insn = Instruction.parse(copy.add(isThumb ? 1 : 0));
70+
}
71+
6272
if (insn.size > buffer.length)
6373
throw new Error(
6474
`failed to parse instruction at ${cursor}, not enough bytes: ${buffer.length}`,
@@ -71,14 +81,26 @@ l address <bytes> - show disassembly listing
7181
.join(' ');
7282

7383
Output.writeln(
74-
`${Output.bold(idx)}: ${Output.green(Format.toHexString(cursor))}: ${Output.yellow(insn.toString().padEnd(40))} ${Output.blue(bytesStr)}`,
84+
[
85+
`${Output.bold(idx)}:`,
86+
`${Output.green(Format.toHexString(cursor))}:`,
87+
`${Output.yellow(insn.toString().padEnd(40))}`,
88+
`${Output.blue(bytesStr)}`,
89+
overlaps ? `${Output.red('*')}` : '',
90+
].join(' '),
7591
true,
7692
);
7793

7894
cursor = cursor.add(insn.size);
7995
buffer = buffer.slice(insn.size);
8096
}
8197

98+
if (hasOverlaps) {
99+
Output.writeln(
100+
`${Output.red('*')} offset in RIP relative instruction may be incorrect due to conflicting breakpoint`,
101+
);
102+
}
103+
82104
return new Var(uint64(cursor.toString()));
83105
} catch (error) {
84106
throw new Error(

0 commit comments

Comments
 (0)