github.com/iDigitalFlame/xmt@v0.5.4/cmd/asm_windows.go (about) 1 //go:build windows 2 // +build windows 3 4 // Copyright (C) 2020 - 2023 iDigitalFlame 5 // 6 // This program is free software: you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation, either version 3 of the License, or 9 // any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program. If not, see <https://www.gnu.org/licenses/>. 18 // 19 20 package cmd 21 22 import "github.com/iDigitalFlame/xmt/cmd/filter" 23 24 // Pid returns the process ID of the owning process (the process running 25 // the thread.) 26 // 27 // This may return zero if the thread has not yet been started. 28 func (a *Assembly) Pid() uint32 { 29 return a.t.Pid() 30 } 31 32 // Start will attempt to start the Assembly thread and will return any errors 33 // that occur while starting the thread. 34 // 35 // This function will return 'ErrEmptyCommand' if the 'Data' parameter is empty or 36 // the 'ErrAlreadyStarted' error if attempting to start a thread that already has 37 // been started previously. 38 // 39 // Always returns 'ErrNoWindows' on non-Windows devices. 40 func (a *Assembly) Start() error { 41 if len(a.Data) == 0 { 42 return ErrEmptyCommand 43 } 44 if err := a.t.Start(0, a.Timeout, 0, a.Data); err != nil { 45 return err 46 } 47 go a.t.wait(0, 0) 48 return nil 49 } 50 51 // SetParent will instruct the Assembly thread to choose a parent with the supplied 52 // process Filter. If the Filter is nil this will use the current process (default). 53 // 54 // This function has no effect if the device is not running Windows. 55 func (a *Assembly) SetParent(f *filter.Filter) { 56 a.t.filter = f 57 }