Skip to content

Commit 29ece2a

Browse files
committed
improve x64
1 parent ac35661 commit 29ece2a

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

examples/linux/simple_strace_x64.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var Interruptor = require('../dist/android-x64-strace.min.js').target.LinuxX64();
2+
3+
4+
Interruptor.newAgentTracer({
5+
followThread: true,
6+
exclude : {
7+
syscall: [/clock_gettime/]
8+
}
9+
}).start();
10+
11+
12+

src/arch/LinuxX64InterruptorAgent.ts

+16-12
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,10 @@ export class LinuxX64InterruptorAgent extends InterruptorAgent{
183183
setupBuiltinHook(){
184184
}
185185

186-
locateEIP( pContext: any):string{
186+
locateRIP( pContext: any):string{
187187
let l = "", tid:number =-1;
188-
const r = Process.findRangeByAddress(pContext.eip);
188+
189+
const r = Process.findRangeByAddress(pContext.rip);
189190

190191
if(this.output.tid) {
191192
tid = Process.getCurrentThreadId();
@@ -196,21 +197,21 @@ export class LinuxX64InterruptorAgent extends InterruptorAgent{
196197
if(this.output.module){
197198
if(r != null){
198199
if(r.file != null){
199-
if(this.output.hidePackage!=null){
200-
l += `[${ r.file.path.replace(this.output.hidePackage, "HIDDEN")} +${pContext.eip.sub(r.base)}]`;
200+
if(this.output.hide!=null){
201+
l += `[${ r.file.path.replace(this.output.hide, "HIDDEN")} +${pContext.rip.sub(r.base)}]`;
201202
}else{
202-
l += `[${ r.file.path } +${pContext.eip.sub(r.base)}]`;
203+
l += `[${ r.file.path } +${pContext.rip.sub(r.base)}]`;
203204
}
204205
}else{
205-
l += `[${r.base} +${pContext.eip.sub(r.base)}]`;
206+
l += `[${r.base} +${pContext.rip.sub(r.base)}]`;
206207
}
207208
}else{
208-
// l += `[<unknow> lr=${pContext.lr}]`;
209+
l += `[<unknow> rip=${pContext.rip}]`;
209210
}
210211
}
211212

212-
//if(this.output.lr)
213-
// l += `[lr=${pContext.lr}]`;
213+
if(this.output.lr)
214+
l += `[lr=${pContext.rip}]`;
214215

215216
return l;
216217
}
@@ -488,7 +489,7 @@ export class LinuxX64InterruptorAgent extends InterruptorAgent{
488489
const sysSignature = SYSC_MAP_NUM[ sysNR.toInt32() ];
489490

490491
if(sysSignature==null) {
491-
console.log( ' ['+this.locateEIP(pContext)+'] \x1b[35;01m' + CC.OP + ' ('+sysNR+')\x1b[0m =<unknow>');
492+
console.log( ' ['+this.locateRIP(pContext)+'] \x1b[35;01m' + CC.OP + ' ('+sysNR+')\x1b[0m =<unknow>');
492493
return;
493494
}
494495

@@ -515,7 +516,7 @@ export class LinuxX64InterruptorAgent extends InterruptorAgent{
515516
* @param pSysNum
516517
*/
517518
formatLogLine( pContext:any, pSysc:string, pInst:string, pSysNum:number):string {
518-
let s = this.locateEIP(pContext);
519+
let s = this.locateRIP(pContext);
519520
s += this.output.inst ? ` \x1b[35;01m${pInst} :: ${pSysNum} \x1b[0m` : "";
520521
s += ` ${pSysc}`;
521522
return s;
@@ -651,6 +652,7 @@ export class LinuxX64InterruptorAgent extends InterruptorAgent{
651652

652653
pStalkerInterator.putCallout(function(context) {
653654
const n = context[CC.NR].toInt32();
655+
654656
if(context.dxc==null) context.dxc = {FD:{}};
655657
if(isExcludedFn!=null && isExcludedFn(n)) return;
656658

@@ -667,8 +669,10 @@ export class LinuxX64InterruptorAgent extends InterruptorAgent{
667669
pExtra.onLeave = null;
668670
}
669671

672+
670673
// debug
671-
//console.log("["+pInstruction.address+" : "+pInstruction.address.sub(pExtra.mod.__mod.base)+"] > "+Instruction.parse(pInstruction.address));
674+
// console.log("["+pInstruction.address+" : "+pInstruction.address.sub(pExtra.mod.__mod.base)+"] > "+Instruction.parse(pInstruction.address));
675+
//console.log("["+pInstruction.address+"] > "+Instruction.parse(pInstruction.address));
672676

673677
if (pInstruction.mnemonic === CC.OP) {
674678

src/common/InterruptorAgent.ts

+1
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ export class InterruptorAgent {
449449

450450
let threadExtra:any = pExtra;
451451
threadExtra.hookAfter = null;
452+
threadExtra.onLeave = null;
452453

453454
while ((instruction = iterator.next()) !== null) {
454455
next = 1;

0 commit comments

Comments
 (0)