Skip to content

Commit c3353ab

Browse files
author
Your Name
committed
Add support for greater than and less than operators
1 parent c13bd51 commit c3353ab

5 files changed

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

src/cmdlets/development/js.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ import {
5050
XorCmdLet,
5151
TrueCmdLet,
5252
FalseCmdLet,
53+
GreaterThanCmdLet,
54+
GreaterThanEqualsCmdLet,
55+
LessThanCmdLet,
56+
LessThanEqualsCmdLet,
5357
} from '../math/math.js';
5458
import { ModCmdLet } from '../modules/mod.js';
5559
import { ReadCmdLet } from '../data/read.js';
@@ -114,6 +118,8 @@ js path - load commandlet JS script
114118
Format: Format,
115119
FunctionEntryBpCmdLet: FunctionEntryBpCmdLet,
116120
FunctionExitBpCmdLet: FunctionExitBpCmdLet,
121+
GreaterThanCmdLet: GreaterThanCmdLet,
122+
GreaterThanEqualsCmdLet: GreaterThanEqualsCmdLet,
117123
GrepCmdLet: GrepCmdLet,
118124
HelpCmdLet: HelpCmdLet,
119125
History: History,
@@ -122,6 +128,8 @@ js path - load commandlet JS script
122128
Input: Input,
123129
InsnBpCmdLet: InsnBpCmdLet,
124130
LdCmdLet: LdCmdLet,
131+
LessThanCmdLet: LessThanCmdLet,
132+
LessThanEqualsCmdLet: LessThanEqualsCmdLet,
125133
Line: Line,
126134
LogCmdLet: LogCmdLet,
127135
MacroCmdLet: MacroCmdLet,

src/cmdlets/math/math.ts

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export class EqCmdLet extends BinaryOpCmdLet {
294294
name = '==';
295295
help = 'test equality of op1 and op2';
296296

297-
protected OPERATION: string = 'eq';
297+
protected OPERATION: string = 'equals';
298298

299299
protected op(op0: UInt64, op1: UInt64): UInt64 {
300300
const val = uint64(op0.equals(op1) ? 1 : 0);
@@ -307,7 +307,7 @@ export class NeCmdLet extends BinaryOpCmdLet {
307307
name = '!=';
308308
help = 'test inequality of op1 and op2';
309309

310-
protected OPERATION: string = 'nu';
310+
protected OPERATION: string = 'not equals';
311311

312312
protected op(op0: UInt64, op1: UInt64): UInt64 {
313313
const val = uint64(op0.equals(op1) ? 0 : 1);
@@ -316,6 +316,58 @@ export class NeCmdLet extends BinaryOpCmdLet {
316316
}
317317
}
318318

319+
export class GreaterThanCmdLet extends BinaryOpCmdLet {
320+
name = '>';
321+
help = 'test if op1 greater than op2';
322+
323+
protected OPERATION: string = 'greater than';
324+
325+
protected op(op0: UInt64, op1: UInt64): UInt64 {
326+
const val = uint64(op0.compare(op1) > 0 ? 1 : 0);
327+
this.output(op0, op1, val);
328+
return val;
329+
}
330+
}
331+
332+
export class GreaterThanEqualsCmdLet extends BinaryOpCmdLet {
333+
name = '>=';
334+
help = 'test if op1 greater or equal to op2';
335+
336+
protected OPERATION: string = 'greater than or equal to';
337+
338+
protected op(op0: UInt64, op1: UInt64): UInt64 {
339+
const val = uint64(op0.compare(op1) >= 0 ? 1 : 0);
340+
this.output(op0, op1, val);
341+
return val;
342+
}
343+
}
344+
345+
export class LessThanCmdLet extends BinaryOpCmdLet {
346+
name = '<';
347+
help = 'test if op1 less than op2';
348+
349+
protected OPERATION: string = 'less than';
350+
351+
protected op(op0: UInt64, op1: UInt64): UInt64 {
352+
const val = uint64(op0.compare(op1) < 0 ? 1 : 0);
353+
this.output(op0, op1, val);
354+
return val;
355+
}
356+
}
357+
358+
export class LessThanEqualsCmdLet extends BinaryOpCmdLet {
359+
name = '<=';
360+
help = 'test if op1 less than or equal to op2';
361+
362+
protected OPERATION: string = 'less than or equal to';
363+
364+
protected op(op0: UInt64, op1: UInt64): UInt64 {
365+
const val = uint64(op0.compare(op1) <= 0 ? 1 : 0);
366+
this.output(op0, op1, val);
367+
return val;
368+
}
369+
}
370+
319371
export class NotCmdLet extends UnaryOpCmdLet {
320372
name = '~';
321373
help = 'bitwise not an operand';

src/commands/cmdlets.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ import {
2727
NeCmdLet,
2828
FalseCmdLet,
2929
TrueCmdLet,
30+
GreaterThanCmdLet,
31+
GreaterThanEqualsCmdLet,
32+
LessThanCmdLet,
33+
LessThanEqualsCmdLet,
3034
} from '../cmdlets/math/math.js';
3135
import { HistoryCmdLet } from '../cmdlets/misc/history.js';
3236
import { HelpCmdLet } from '../cmdlets/misc/help.js';
@@ -84,6 +88,8 @@ export class CmdLets {
8488
this.registerCmdletType(ExitCmdLet);
8589
this.registerCmdletType(FalseCmdLet);
8690
this.registerCmdletType(FdCmdLet);
91+
this.registerCmdletType(GreaterThanCmdLet);
92+
this.registerCmdletType(GreaterThanEqualsCmdLet);
8793
this.registerCmdletType(GrepCmdLet);
8894
this.registerCmdletType(FunctionEntryBpCmdLet);
8995
this.registerCmdletType(FunctionExitBpCmdLet);
@@ -93,6 +99,8 @@ export class CmdLets {
9399
this.registerCmdletType(InsnBpCmdLet);
94100
this.registerCmdletType(JsCmdLet);
95101
this.registerCmdletType(LdCmdLet);
102+
this.registerCmdletType(LessThanCmdLet);
103+
this.registerCmdletType(LessThanEqualsCmdLet);
96104
this.registerCmdletType(LogCmdLet);
97105
this.registerCmdletType(OrCmdLet);
98106
this.registerCmdletType(ReadCmdLet);

0 commit comments

Comments
 (0)