Skip to content

Commit

Permalink
Changes to print default .cshellrc in banner
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jul 8, 2024
1 parent a2c5041 commit 6e89329
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/cmdlets/src.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export class SrcCmdLet extends CmdLet {
category = 'misc';
help = 'load script';

public static readonly defaultPath = `${Process.getHomeDir()}/.cshellrc`;
private lastPath = SrcCmdLet.defaultPath;
private static lastPath: string | null = null;

public static loadInitScript() {
public static loadInitScript(path: string) {
this.lastPath = path;
const src = new SrcCmdLet();
src.runScript(SrcCmdLet.defaultPath);
src.runScript(path);
}

public runSync(tokens: Token[]): Var {
Expand All @@ -46,7 +46,7 @@ export class SrcCmdLet extends CmdLet {
name = name.slice(1, name.length - 1);

Output.writeln(`Loading: ${name}`);
this.lastPath = name;
SrcCmdLet.lastPath = name;
this.runScript(name);

return Var.ZERO;
Expand Down Expand Up @@ -76,8 +76,10 @@ export class SrcCmdLet extends CmdLet {
private runWithoutName(tokens: Token[]): Var | null {
if (tokens.length !== 0) return null;

Output.writeln(`Loading: ${this.lastPath}`);
this.runScript(this.lastPath);
if (SrcCmdLet.lastPath === null) throw new Error('path not initialized');

Output.writeln(`Loading: ${SrcCmdLet.lastPath}`);
this.runScript(SrcCmdLet.lastPath);
return Var.ZERO;
}

Expand Down
4 changes: 3 additions & 1 deletion src/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { Regs } from './breakpoints/regs.js';
import { Format } from './misc/format.js';
import { SrcCmdLet } from './cmdlets/src.js';

export const DEFAULT_SRC_PATH: string = `${Process.getHomeDir()}/.cshellrc`;

type InitParams = {
verbose: boolean;
};
Expand All @@ -25,7 +27,7 @@ rpc.exports = {
Output.writeln(`init - stage: ${stage}, verbose: ${verbose}`, true);
Output.banner();
Process.setExceptionHandler(exceptionHandler);
SrcCmdLet.loadInitScript();
SrcCmdLet.loadInitScript(DEFAULT_SRC_PATH);
Input.prompt();
},
/**
Expand Down
2 changes: 2 additions & 0 deletions src/io/output.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CharCode } from './char.js';
import { Vars } from '../vars/vars.js';
import { DEFAULT_SRC_PATH } from '../entrypoint.js';

export class Output {
private static readonly VERSION = '@VER@';
Expand Down Expand Up @@ -40,6 +41,7 @@ export class Output {
`CSHELL v${this.VERSION}, running in FRIDA ${Frida.version} using ${Script.runtime}`,
),
);
this.writeln(`init script: ${Output.bold(DEFAULT_SRC_PATH)}`);

this.writeln('Attached to:');
this.writeln(`\tPID: ${this.green(Process.id.toString())}`);
Expand Down

0 comments on commit 6e89329

Please sign in to comment.