You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When compiling for ARM64 Windows and using the process module to compare command line with a running process, then I get the error of: "could not get CommandLine: cannot locate process PEB: could not query PEB address"
To Reproduce
I can't share the entirety of the code, but hopefully this snippet helps you understand how it's being used. Basic gist of, we're killing a process but want to verify it's the right process, so we're making a command line comparison.
funccommandPathsAreEqual(cmdPathstring, killPathstring) bool {
strippedKillPath:=strings.TrimSpace(killPath)
cmdPath=strings.ToLower(cmdPath)
killPath=strings.ToLower(strippedKillPath)
ifstrings.HasPrefix(cmdPath, `"`) {
re:=regexp.MustCompile(`^"(.*?)"`)
cmdPath=re.FindStringSubmatch(cmdPath)[1]
returncmdPath==killPath
}
// Compare the slices of killPath (from the portal)// with the running process slices (cmdSlice)// Break the commands on space and check that each of the values in the// len(killPath) == cmdSlice to provide equivalent between sliceskillSlice:=strings.Split(killPath, " ")
cmdSlice:=strings.Split(cmdPath, " ")
fori, v:=rangekillSlice {
ifcmdSlice[i] !=v {
returnfalse
}
}
returntrue
}
// executes killprocessfunc (tremediateKillProcess) Process(rc*RunningConfigT) (errerror) {
deferfunc() {
t.handleTaskError(err)
}()
killTask:=struct {
PIDint`json:"pid"`Pathstring`json:"path"`
}{}
iferr=json.Unmarshal(t.Params, &killTask); err!=nil {
returnerr
}
proc, err:=process.NewProcess(int32(killTask.PID))
iferr==process.ErrorProcessNotRunning {
// if pid is not found// return successt.Results=err.Error()
// This is not an error. If the PID is not found// then the process we are attempting to kill is no longer runningreturnnil
}
passingPath, err:=proc.Cmdline()
iferr!=nil&&err.Error() !="exit status 1" {
// Darwin returns "exit status 1" whenever the process can't be found// during querying for the full patht.err=errt.Results=err.Error()
returnnil
}
ift.captureAndReturnFailureState(err) !=nil {
returnerr
}
ifcommandPathsAreEqual(passingPath, killTask.Path) ==false {
// Path does not exist. We assume that the process is now defunct// or that the path was not correct. Either way, the process does not existerr=fmt.Errorf("Path for process `%q` was not found.", killTask.Path)
t.Results=err.Error()
// This is not an errorreturnnil
}
// if path and pid found, killerr=proc.Terminate()
// Set t.err, t.Results Return at this point// if err is still returnedift.captureAndReturnFailureState(err) !=nil {
returnerr
}
// Kill successfult.Results=fmt.Sprintf("Process %d at %s was successfully killed.", killTask.PID, killTask.Path)
// No error to returnreturnnil
}
Expected behavior
No errors are received when trying to get the command line for the process on ARM64 Windows
Environment (please complete the following information):
Windows: ARM64
Additional context
I provided this PR with updates that resolve the problem
The text was updated successfully, but these errors were encountered:
s-m-martin
changed the title
Kill process fails on ARM64 Windows
Getting process command line fails on ARM64 Windows
Mar 21, 2023
Describe the bug
When compiling for ARM64 Windows and using the process module to compare command line with a running process, then I get the error of: "could not get CommandLine: cannot locate process PEB: could not query PEB address"
To Reproduce
I can't share the entirety of the code, but hopefully this snippet helps you understand how it's being used. Basic gist of, we're killing a process but want to verify it's the right process, so we're making a command line comparison.
Expected behavior
No errors are received when trying to get the command line for the process on ARM64 Windows
Environment (please complete the following information):
Additional context
I provided this PR with updates that resolve the problem
The text was updated successfully, but these errors were encountered: