@@ -10,6 +10,7 @@ import (
10
10
"fmt"
11
11
"io"
12
12
"os"
13
+ "path/filepath"
13
14
"reflect"
14
15
"strings"
15
16
"syscall"
@@ -319,18 +320,19 @@ func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
319
320
}
320
321
321
322
func (p * Process ) NameWithContext (ctx context.Context ) (string , error ) {
322
- ppid , _ , name , err := getFromSnapProcess (p .Pid )
323
- if err != nil {
324
- return "" , fmt .Errorf ("could not get Name: %s" , err )
323
+ if p .Pid == 0 {
324
+ return "System Idle Process" , nil
325
+ }
326
+ if p .Pid == 4 {
327
+ return "System" , nil
325
328
}
326
329
327
- // if no errors and not cached already, cache ppid
328
- p .parent = ppid
329
- if 0 == p .getPpid () {
330
- p .setPpid (ppid )
330
+ exe , err := p .ExeWithContext (ctx )
331
+ if err != nil {
332
+ return "" , fmt .Errorf ("could not get Name: %s" , err )
331
333
}
332
334
333
- return name , nil
335
+ return filepath . Base ( exe ) , nil
334
336
}
335
337
336
338
func (p * Process ) TgidWithContext (ctx context.Context ) (int32 , error ) {
@@ -987,15 +989,9 @@ func is32BitProcess(h windows.Handle) bool {
987
989
988
990
var procIs32Bits bool
989
991
switch processorArchitecture {
990
- case PROCESSOR_ARCHITECTURE_INTEL :
991
- fallthrough
992
- case PROCESSOR_ARCHITECTURE_ARM :
992
+ case PROCESSOR_ARCHITECTURE_INTEL , PROCESSOR_ARCHITECTURE_ARM :
993
993
procIs32Bits = true
994
- case PROCESSOR_ARCHITECTURE_ARM64 :
995
- fallthrough
996
- case PROCESSOR_ARCHITECTURE_IA64 :
997
- fallthrough
998
- case PROCESSOR_ARCHITECTURE_AMD64 :
994
+ case PROCESSOR_ARCHITECTURE_ARM64 , PROCESSOR_ARCHITECTURE_IA64 , PROCESSOR_ARCHITECTURE_AMD64 :
999
995
var wow64 uint
1000
996
1001
997
ret , _ , _ := common .ProcNtQueryInformationProcess .Call (
0 commit comments