33 lines
717 B
Go
33 lines
717 B
Go
package instance
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"path/filepath"
|
||
|
|
"strings"
|
||
|
|
|
||
|
|
"tea.chunkbyte.com/kato/go-worm/lib/config"
|
||
|
|
)
|
||
|
|
|
||
|
|
func shouldKill(selfPID, pid uint32, selfPath, imagePath, installed, exeName string) bool {
|
||
|
|
if pid == 0 || pid == selfPID {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
if imagePath != "" && sameFilePath(imagePath, selfPath) {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
if installed != "" && imagePath != "" && sameFilePath(imagePath, installed) {
|
||
|
|
return true
|
||
|
|
}
|
||
|
|
base := exeName
|
||
|
|
if base == "" && imagePath != "" {
|
||
|
|
base = filepath.Base(imagePath)
|
||
|
|
}
|
||
|
|
return strings.EqualFold(base, config.InstalledExeName)
|
||
|
|
}
|
||
|
|
|
||
|
|
func sameFilePath(a, b string) bool {
|
||
|
|
if a == "" || b == "" {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
return strings.EqualFold(filepath.Clean(a), filepath.Clean(b))
|
||
|
|
}
|