diff --git a/package-lock.json b/package-lock.json index af00f3a..07ae3d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "frida-cshell", - "version": "1.6.0", + "version": "1.6.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "frida-cshell", - "version": "1.6.0", + "version": "1.6.1", "devDependencies": { "@eslint/js": "^9.10.0", "@types/frida-gum": "^18.7", diff --git a/package.json b/package.json index 9dd0ff3..7d9b4f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "frida-cshell", - "version": "1.6.0", + "version": "1.6.1", "description": "Frida's CShell", "scripts": { "prepare": "npm run build && npm run version && npm run package && npm run copy", diff --git a/src/cmdlets/data/assembly.ts b/src/cmdlets/data/assembly.ts index 938cfce..1f569a9 100644 --- a/src/cmdlets/data/assembly.ts +++ b/src/cmdlets/data/assembly.ts @@ -4,6 +4,7 @@ import { Format } from '../../misc/format.js'; import { Token } from '../../io/token.js'; import { Var } from '../../vars/var.js'; import { Mem } from '../../memory/mem.js'; +import { Overlay } from '../../memory/overlay.js'; export class AssemblyCmdLet extends CmdLet { name = 'l'; @@ -47,6 +48,7 @@ l address - show disassembly listing try { const minLength = this.maxInstructionLen(); const copy = Memory.alloc(Process.pageSize); + let hasOverlaps = false; for (let i = 1; i <= length; i++) { if (buffer.byteLength < minLength) { @@ -58,7 +60,15 @@ l address - show disassembly listing } Mem.writeBytes(copy, buffer); - const insn = Instruction.parse(copy.add(isThumb ? 1 : 0)); + + let insn = Instruction.parse(cursor.add(isThumb ? 1 : 0)); + const overlaps = Overlay.overlaps(cursor, insn.size); + + if (overlaps) { + hasOverlaps = true; + insn = Instruction.parse(copy.add(isThumb ? 1 : 0)); + } + if (insn.size > buffer.length) throw new Error( `failed to parse instruction at ${cursor}, not enough bytes: ${buffer.length}`, @@ -71,7 +81,13 @@ l address - show disassembly listing .join(' '); Output.writeln( - `${Output.bold(idx)}: ${Output.green(Format.toHexString(cursor))}: ${Output.yellow(insn.toString().padEnd(40))} ${Output.blue(bytesStr)}`, + [ + `${Output.bold(idx)}:`, + `${Output.green(Format.toHexString(cursor))}:`, + `${Output.yellow(insn.toString().padEnd(40))}`, + `${Output.blue(bytesStr)}`, + overlaps ? `${Output.red('*')}` : '', + ].join(' '), true, ); @@ -79,6 +95,12 @@ l address - show disassembly listing buffer = buffer.slice(insn.size); } + if (hasOverlaps) { + Output.writeln( + `${Output.red('*')} offset in RIP relative instruction may be incorrect due to conflicting breakpoint`, + ); + } + return new Var(uint64(cursor.toString())); } catch (error) { throw new Error(