in providers/windows/process_windows.go [212:228]
func readProcessUnicodeString(handle syscall.Handle, s *windows.UnicodeString) ([]byte, error) {
// Allocate an extra UTF-16 null character at the end in case the read string
// is not terminated.
extra := 2
if s.Size&1 != 0 {
extra = 3 // If size is odd, need 3 nulls to terminate.
}
buf := make([]byte, int(s.Size)+extra)
nRead, err := windows.ReadProcessMemory(handle, s.Buffer, buf[:s.Size])
if err != nil {
return nil, err
}
if nRead != uintptr(s.Size) {
return nil, fmt.Errorf("unicode string: short read: (%d/%d)", nRead, s.Size)
}
return buf, nil
}