|
|
@ -12,6 +12,7 @@ import (
|
|
|
|
"reflect"
|
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"syscall"
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
"unicode/utf16"
|
|
|
|
"unicode/utf16"
|
|
|
|
"unsafe"
|
|
|
|
"unsafe"
|
|
|
|
|
|
|
|
|
|
|
@ -720,24 +721,36 @@ func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, er
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var buf [syscall.MAX_LONG_PATH]uint16
|
|
|
|
var fileName string
|
|
|
|
n, err := windows.GetFinalPathNameByHandle(windows.Handle(file), &buf[0], syscall.MAX_LONG_PATH, 0)
|
|
|
|
ch := make(chan struct{})
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
continue
|
|
|
|
go func() {
|
|
|
|
}
|
|
|
|
var buf [syscall.MAX_LONG_PATH]uint16
|
|
|
|
|
|
|
|
n, err := windows.GetFinalPathNameByHandle(windows.Handle(file), &buf[0], syscall.MAX_LONG_PATH, 0)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fileName := string(utf16.Decode(buf[:n]))
|
|
|
|
fileName = string(utf16.Decode(buf[:n]))
|
|
|
|
fileInfo, _ := os.Stat(fileName)
|
|
|
|
ch <- struct{}{}
|
|
|
|
if fileInfo.IsDir() {
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select {
|
|
|
|
|
|
|
|
case <-time.NewTimer(100 * time.Millisecond).C:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
case <-ch:
|
|
|
|
|
|
|
|
fileInfo, _ := os.Stat(fileName)
|
|
|
|
|
|
|
|
if fileInfo.IsDir() {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if _, exists := fileExists[fileName]; !exists {
|
|
|
|
if _, exists := fileExists[fileName]; !exists {
|
|
|
|
files = append(files, OpenFilesStat{
|
|
|
|
files = append(files, OpenFilesStat{
|
|
|
|
Path: fileName,
|
|
|
|
Path: fileName,
|
|
|
|
Fd: uint64(file),
|
|
|
|
Fd: uint64(file),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
fileExists[fileName] = true
|
|
|
|
fileExists[fileName] = true
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|