Skip to content

Commit cce365a

Browse files
author
Your Name
committed
Fix handling of filenames
1 parent a03619f commit cce365a

File tree

21 files changed

+141
-79
lines changed

21 files changed

+141
-79
lines changed

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.8.0",
3+
"version": "1.8.1",
44
"description": "Frida's CShell",
55
"scripts": {
66
"prepare": "npm run version && npm run build && npm run package && npm run copy",

src/breakpoints/bp.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ export abstract class Bp {
3737
public conditions: string[] = [];
3838
public commands: string[] = [];
3939

40-
public static idToVar(id: number): Var {
41-
return new Var(uint64(id.toString()), `#${id}`);
42-
}
43-
4440
protected constructor(
4541
index: number,
4642
address: Var | null,

src/breakpoints/regs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Var } from '../vars/var.js';
2-
import { Bp } from './bp.js';
32

43
enum PseudoRegNames {
54
TID = 'tid',
@@ -58,7 +57,7 @@ export class Regs {
5857
}
5958

6059
public static setBreakpointId(breakpointId: number) {
61-
this.pseudoRegs[PseudoRegNames.BP] = Bp.idToVar(breakpointId);
60+
this.pseudoRegs[PseudoRegNames.BP] = Var.fromId(breakpointId);
6261
}
6362

6463
public static get(name: string): Var {

src/cmdlets/breakpoints/bp.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,12 @@ export abstract class TypedBpCmdLet
7878
}
7979

8080
public usage(): Var {
81+
const show = this.usageShow();
8182
const create = this.usageCreate();
8283
const modify = this.usageModify();
8384
const usage: string = `Usage: ${this.name}
8485
${Output.bold('show:')}
85-
86-
${this.name} - show all ${this.bpType} breakpoints
87-
88-
${this.name} ${CmdLetBase.NUM_CHAR}n - show a ${this.bpType} breakpoint
89-
${CmdLetBase.NUM_CHAR}n the number of the breakpoint to show
86+
${show}
9087
9188
${Output.bold('create:')}
9289
${create}
@@ -105,6 +102,15 @@ ${Output.bold('NOTE:')} Set hits to '*' for unlimited breakpoint.`;
105102
return Var.ZERO;
106103
}
107104

105+
protected usageShow(): string {
106+
const usage: string = `
107+
${this.name} - show all ${this.bpType} breakpoints
108+
109+
${this.name} ${CmdLetBase.NUM_CHAR}n - show a ${this.bpType} breakpoint
110+
${CmdLetBase.NUM_CHAR}n the number of the breakpoint to show`;
111+
return usage;
112+
}
113+
108114
protected parseConditional(token: Token): string | null {
109115
const literal = token.getLiteral();
110116
if (literal !== TypedBpCmdLet.CONDITIONAL_CHAR) return null;

src/cmdlets/breakpoints/code.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Bp, BpType } from '../../breakpoints/bp.js';
1+
import { BpType } from '../../breakpoints/bp.js';
22
import { Bps } from '../../breakpoints/bps.js';
33
import {
44
BpCodeInstruction,
@@ -60,7 +60,7 @@ abstract class CodeBpCmdLet extends TypedBpCmdLet {
6060
throw new Error(`unexpected breakpoint type: ${this.bpType}`);
6161
}
6262

63-
return Bp.idToVar(idx);
63+
return Var.fromId(idx);
6464
}
6565

6666
protected runModify(tokens: Token[]): Var | null {
@@ -89,7 +89,7 @@ abstract class CodeBpCmdLet extends TypedBpCmdLet {
8989
Output.writeln(`Modified ${bp.toString()}`);
9090
this.editBreakpoint(bp, conditional);
9191

92-
return Bp.idToVar(index);
92+
return Var.fromId(index);
9393
}
9494

9595
protected override usageCreate(): string {

src/cmdlets/breakpoints/mem.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Bp, BpType } from '../../breakpoints/bp.js';
1+
import { BpType } from '../../breakpoints/bp.js';
22
import { Bps } from '../../breakpoints/bps.js';
33
import { BpReadMemory, BpWriteMemory } from '../../breakpoints/memory.js';
44
import { CmdLetBase } from '../../commands/cmdlet.js';
@@ -46,7 +46,7 @@ abstract class MemoryBpCmdLet extends TypedBpCmdLet {
4646
throw new Error(`unexpected breakpoint type: ${this.bpType}`);
4747
}
4848

49-
return Bp.idToVar(idx);
49+
return Var.fromId(idx);
5050
}
5151

5252
protected runModify(tokens: Token[]): Var | null {
@@ -75,7 +75,7 @@ abstract class MemoryBpCmdLet extends TypedBpCmdLet {
7575
Output.writeln(`Modified ${bp.toString()}`);
7676
this.editBreakpoint(bp, conditional);
7777

78-
return Bp.idToVar(index);
78+
return Var.fromId(index);
7979
}
8080

8181
protected override usageCreate(): string {

src/cmdlets/breakpoints/replace.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { Token } from '../../io/token.js';
22
import { Var } from '../../vars/var.js';
33
import { TypedBpCmdLet } from './bp.js';
4-
import { Bp, BpType } from '../../breakpoints/bp.js';
4+
import { BpType } from '../../breakpoints/bp.js';
55
import { Bps } from '../../breakpoints/bps.js';
66
import { BpReplacement } from '../../breakpoints/replace.js';
77
import { Output } from '../../io/output.js';
8+
import { CmdLetBase } from '../../commands/cmdlet.js';
89

910
export class ReplaceCmdLet extends TypedBpCmdLet {
1011
name = 'replace';
1112
bpType = BpType.Replacement;
12-
help = `replace a function with another implementation (returns the address of the trampoline)`;
13+
help = `replace a function with another implementation`;
1314

1415
public runCreate(tokens: Token[]): Var | null {
1516
const vars = this.transform(tokens, [this.parseVar, this.parseVar]);
@@ -22,7 +23,7 @@ export class ReplaceCmdLet extends TypedBpCmdLet {
2223
Bps.add(bp);
2324
bp.enable();
2425
Output.writeln(`Created ${bp.toString()}`);
25-
return Bp.idToVar(index);
26+
return Var.fromId(index);
2627
} catch (error) {
2728
throw new Error(`failed to replace ${address} with ${target}, ${error}`);
2829
}
@@ -44,6 +45,15 @@ export class ReplaceCmdLet extends TypedBpCmdLet {
4445
return bp.trampoline;
4546
}
4647

48+
protected override usageShow(): string {
49+
const usage: string = `
50+
${this.name} - show all ${this.bpType} breakpoints
51+
52+
${this.name} ${CmdLetBase.NUM_CHAR}n - show a ${this.bpType} breakpoint (returns the address of the trampoline)
53+
${CmdLetBase.NUM_CHAR}n the number of the breakpoint to show`;
54+
return usage;
55+
}
56+
4757
protected override usageCreate(): string {
4858
const usage: string = `
4959
replace dest src - replace function

src/cmdlets/breakpoints/trace.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Bp, BpType } from '../../breakpoints/bp.js';
1+
import { BpType } from '../../breakpoints/bp.js';
22
import { Bps } from '../../breakpoints/bps.js';
33
import {
44
BpBlockTrace,
@@ -60,7 +60,7 @@ abstract class TraceBpCmdLet extends TypedBpCmdLet {
6060
throw new Error(`unexpected breakpoint type: ${this.bpType}`);
6161
}
6262

63-
return Bp.idToVar(idx);
63+
return Var.fromId(idx);
6464
}
6565

6666
protected runModify(tokens: Token[]): Var | null {
@@ -92,7 +92,7 @@ abstract class TraceBpCmdLet extends TypedBpCmdLet {
9292
Output.writeln(`Modified ${bp.toString()}`);
9393
this.editBreakpoint(bp, conditional);
9494

95-
return Bp.idToVar(index);
95+
return Var.fromId(index);
9696
}
9797

9898
protected override usageCreate(): string {

src/cmdlets/development/js.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,9 @@ js path - load commandlet JS script
9696
path the absolute path of the commandlet script to load (note that paths with spaces must be quoted)`;
9797

9898
public runSync(tokens: Token[]): Var {
99-
const vars = this.transform(tokens, [this.parseLiteral]);
99+
const vars = this.transform(tokens, [this.parseString]);
100100
if (vars === null) return this.usage();
101-
let [name] = vars as [string];
102-
103-
if (name.length > 1 && name.startsWith('"') && name.endsWith('"')) {
104-
name = name.slice(1, name.length - 1);
105-
}
101+
const [name] = vars as [string];
106102

107103
Output.writeln(`Loading: ${name}`);
108104

@@ -212,7 +208,7 @@ js path - load commandlet JS script
212208
CmdLets.registerCmdlet(cmdlet);
213209
}
214210

215-
return Var.ZERO;
211+
return new Var(name);
216212
}
217213

218214
private checkMandatoryMembers(cmdlet: CmdLet) {

0 commit comments

Comments
 (0)