diff --git a/proc/proc_windows.go b/proc/proc_windows.go index 41948daa..abd302be 100644 --- a/proc/proc_windows.go +++ b/proc/proc_windows.go @@ -544,6 +544,9 @@ func (dbp *Process) resume() error { } func killProcess(pid int) error { - fmt.Println("killProcess") - return fmt.Errorf("not implemented: killProcess") + p, err := os.FindProcess(pid) + if err != nil { + return err + } + return p.Kill() } diff --git a/proc/ptrace_windows.go b/proc/ptrace_windows.go index 066d4084..96e347ba 100644 --- a/proc/ptrace_windows.go +++ b/proc/ptrace_windows.go @@ -9,5 +9,5 @@ func PtraceAttach(pid int) error { } func PtraceDetach(tid, sig int) error { - return fmt.Errorf("not implemented: PtraceDetach") + return _DebugActiveProcessStop(uint32(tid)) } diff --git a/proc/syscall_windows.go b/proc/syscall_windows.go index 848a3951..3154ad69 100644 --- a/proc/syscall_windows.go +++ b/proc/syscall_windows.go @@ -89,4 +89,5 @@ func _NT_SUCCESS(x _NTSTATUS) bool { //sys _DebugBreakProcess(process syscall.Handle) (err error) = kernel32.DebugBreakProcess //sys _WaitForDebugEvent(debugevent *_DEBUG_EVENT, milliseconds uint32) (err error) = kernel32.WaitForDebugEvent //sys _DebugActiveProcess(processid uint32) (err error) = kernel32.DebugActiveProcess +//sys _DebugActiveProcessStop(processid uint32) (err error) = kernel32.DebugActiveProcessStop //sys _QueryFullProcessImageName(process syscall.Handle, flags uint32, exename *uint16, size *uint32) (err error) = kernel32.QueryFullProcessImageNameW diff --git a/proc/zsyscall_windows.go b/proc/zsyscall_windows.go index 8ab0aba3..ee2b33ca 100644 --- a/proc/zsyscall_windows.go +++ b/proc/zsyscall_windows.go @@ -24,6 +24,7 @@ var ( procDebugBreakProcess = modkernel32.NewProc("DebugBreakProcess") procWaitForDebugEvent = modkernel32.NewProc("WaitForDebugEvent") procDebugActiveProcess = modkernel32.NewProc("DebugActiveProcess") + procDebugActiveProcessStop = modkernel32.NewProc("DebugActiveProcessStop") procQueryFullProcessImageNameW = modkernel32.NewProc("QueryFullProcessImageNameW") ) @@ -155,6 +156,18 @@ func _DebugActiveProcess(processid uint32) (err error) { return } +func _DebugActiveProcessStop(processid uint32) (err error) { + r1, _, e1 := syscall.Syscall(procDebugActiveProcessStop.Addr(), 1, uintptr(processid), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = error(e1) + } else { + err = syscall.EINVAL + } + } + return +} + func _QueryFullProcessImageName(process syscall.Handle, flags uint32, exename *uint16, size *uint32) (err error) { r1, _, e1 := syscall.Syscall6(procQueryFullProcessImageNameW.Addr(), 4, uintptr(process), uintptr(flags), uintptr(unsafe.Pointer(exename)), uintptr(unsafe.Pointer(size)), 0, 0) if r1 == 0 {