var ptrace_ptr = Module.getExportByName(null, 'ptrace');
var ptrace = new SystemFunction(ptrace_ptr, 'int', ['int', 'int', 'int', 'int']);
var PTRACE_TRACEME = 0;
var PTRACE_PEEKTEXT = 1;
var PTRACE_PEEKDATA = 2;
var PTRACE_PEEKUSR = 3;
var PTRACE_POKETEXT = 4;
var PTRACE_POKEDATA = 5;
var PTRACE_POKEUSR = 6;
var PTRACE_CONT = 7;
var PTRACE_KILL = 8;
var PTRACE_SINGLESTEP = 9;
var PTRACE_ATTACH = 16;
var PTRACE_DETACH = 17;
var PTRACE_SYSCALL = 24;
var PTRACE_SETOPTIONS = 0x4200;
var PTRACE_GETEVENTMSG = 0x4201;
var PTRACE_GETSIGINFO = 0x4202;
var PTRACE_SETSIGINFO = 0x4203;
var PTRACE_GETREGSET = 0x4204;
var PTRACE_SETREGSET = 0x4205;
var PTRACE_SEIZE = 0x4206;
var PTRACE_INTERRUPT = 0x4207;
var PTRACE_LISTEN = 0x4208;
var PTRACE_PEEKSIGINFO = 0x4209;
console.log("ptrace " + ptrace_ptr);
console.log("run ptrae PTRACE_DETACH");
var ret = ptrace(PTRACE_DETACH, 6521, 0, 0);
console.log("ptrace return value = " + ret.value);
console.log("errno " + ret.errno);
输出的结果如下:
Attaching...
ptrace 0xe7a76e85
run ptrae PTRACE_DETACH
ptrace return value = -1
errno 3
[Remote::PID::6545]->
这个errno为3,这个错误说的是No such process。就是没有这个进程。确实没搞懂为什么会报这个错。当然我的想法不一定正确,只是让各位帮忙分析一下这个思路是否可行。