Skip to content

Commit ddac004

Browse files
author
Your Name
committed
Switch to using init params to configure debugging.
1 parent a5646a2 commit ddac004

5 files changed

Lines changed: 44 additions & 17 deletions

File tree

.vscode/tasks.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,29 @@
6363
"Target",
6464
"Build"
6565
]
66+
},
67+
{
68+
"type": "shell",
69+
"command": "frida-inject -s frida-cshell.js -P '{\"verbose\": true}' --interactive -f ./target",
70+
"problemMatcher": [],
71+
"label": "Debug",
72+
"group": {
73+
"kind": "build",
74+
"isDefault": true
75+
},
76+
"presentation": {
77+
"echo": true,
78+
"reveal": "always",
79+
"focus": true,
80+
"panel": "shared",
81+
"showReuseMessage": false,
82+
"clear": true,
83+
"close": true
84+
},
85+
"dependsOn": [
86+
"Target",
87+
"Build"
88+
]
6689
}
6790
]
6891
}

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

src/entrypoint.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@
1010
import { Input } from './input.js';
1111
import { Output } from './output.js';
1212

13-
Output.banner();
14-
Output.prompt();
13+
type InitParams = {
14+
verbose: boolean | undefined;
15+
};
1516

1617
rpc.exports = {
18+
init(stage: string, params: InitParams | undefined) {
19+
const verbose = params?.verbose ?? false;
20+
Output.setVerbose(verbose);
21+
Output.writeln(`init - stage: ${stage}, verbose: ${verbose}`, true);
22+
Output.banner();
23+
Output.prompt();
24+
},
1725
/**
1826
* Support reading from stdin for communications with the injected script.
1927
* With the console in its default canonical mode, we will read a line at a
@@ -31,8 +39,4 @@ rpc.exports = {
3139
getFridaTerminalMode() {
3240
return 'raw';
3341
},
34-
35-
setDevelopment(dev: boolean) {
36-
Output.setDevelopment(dev);
37-
},
3842
};

src/output.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class Output {
2424
'\\____|___/_| |_|\\___|_|_| ',
2525
];
2626

27-
private static development: boolean = false;
27+
private static verbose: boolean = false;
2828

2929
public static banner() {
3030
this.shell
@@ -62,25 +62,25 @@ export class Output {
6262
this.write(backspaces);
6363
}
6464

65-
public static write(buffer?: string, development: boolean = false) {
66-
if (development && !this.development) return;
65+
public static write(buffer?: string, verbose: boolean = false) {
66+
if (verbose && !this.verbose) return;
6767

6868
if (buffer) {
6969
const fixed = buffer.replace(new RegExp('\n', 'g'), '\r\n');
7070
send(['frida:stderr', fixed]);
7171
}
7272
}
7373

74-
public static writeln(buffer?: string, development: boolean = false) {
74+
public static writeln(buffer?: string, verbose: boolean = false) {
7575
if (buffer) {
76-
this.write(`${buffer}\n`, development);
76+
this.write(`${buffer}\n`, verbose);
7777
} else {
78-
this.write('\n', development);
78+
this.write('\n', verbose);
7979
}
8080
}
8181

82-
public static setDevelopment(dev: boolean): void {
83-
this.development = dev;
82+
public static setVerbose(dev: boolean): void {
83+
this.verbose = dev;
8484
}
8585

8686
public static bold(input: string): string {

0 commit comments

Comments
 (0)