diff --git a/ptrace.nimble b/ptrace.nimble index f23e2ed..a6c10e4 100644 --- a/ptrace.nimble +++ b/ptrace.nimble @@ -1,9 +1,11 @@ [Package] name = "ptrace" -version = "0.0.1" +version = "0.0.2" author = "Huy Doan" description = "ptrace wrapper for Nim" license = "MIT" +skipDirs = "tests" + [Deps] Requires: "nim >= 0.10.0" diff --git a/ptrace/ptrace.nim b/ptrace/ptrace.nim index 51f080e..e17d05c 100644 --- a/ptrace/ptrace.nim +++ b/ptrace/ptrace.nim @@ -1,8 +1,8 @@ import posix {.pragma: c, - importc, - header: "sys/ptrace.h" + importc, + header: "sys/ptrace.h" .} type @@ -11,21 +11,22 @@ type r14*: culong r13*: culong r12*: culong - bp*: culong - bx*: culong + rbp*: culong + rbx*: culong r11*: culong r10*: culong r9*: culong r8*: culong - ax*: culong - xc*: culong - dx*: culong - si*: culong - di*: culong - orig_ax*: culong - ip*: culong - flags*: culong - sp*: culong + rax*: culong + rcx*: culong + rdx*: culong + rsi*: culong + rdi*: culong + orig_rax*: culong + rip*: culong + cs*: culong + eflags*: culong + rsp*: culong ss*: culong fs_base*: culong gs_base*: culong @@ -62,6 +63,8 @@ var PTRACE_INTERRUPT* {.c.}: cint PTRACE_LISTEN* {.c.}: cint + + const PTRACE_EVENT_FORK* = 1 PTRACE_EVENT_VFORK* = 2 @@ -171,7 +174,7 @@ when isMainModule: discard wait(a) var regs = getRegs(child) - echo "orig_ax: ", regs.orig_ax + echo "orig_rax: ", regs.orig_rax if errno != 0: echo errno, " ", strerror(errno) diff --git a/tests/test1.nim b/tests/test1.nim index 69e2aef..9b37b64 100644 --- a/tests/test1.nim +++ b/tests/test1.nim @@ -7,7 +7,8 @@ var child: Pid var orig_eax, eax: clong var params: array[3, clong] var status: cint -var insyscall = 0; +var insyscall = 0 + child = fork() @@ -27,6 +28,10 @@ else: params[1] = ptrace(PTRACE_PEEKUSER, child, RCX, nil) params[2] = ptrace(PTRACE_PEEKUSER, child, RDX, nil) echo "Write called with ", params[0], ", ", params[1], ", ", params[2] + + let regs: Registers = getRegs(child) + echo regs.rbx, " ", regs.rcx, " ", regs.rdx + else: eax = ptrace(PTRACE_PEEKUSER, child, RAX, nil) echo "Write returned with ", eax