func tryDialPipe(ctx context.Context, path *string) (syscall.Handle, error) {
	for {
		select {
		case <-ctx.Done():
			return syscall.Handle(0), ctx.Err()
		default:
			h, err := createFile(*path, syscall.GENERIC_READ|syscall.GENERIC_WRITE, 0, nil, syscall.OPEN_EXISTING, syscall.FILE_FLAG_OVERLAPPED|cSECURITY_SQOS_PRESENT|cSECURITY_ANONYMOUS, 0)
			if err == nil {
				return h, nil
			}
			if err != cERROR_PIPE_BUSY {
				return h, &os.PathError{Err: err, Op: "open", Path: *path}
			}
			time.Sleep(time.Millisecond * 10)
		}
	}
}
tryDialPipe attempts to dial the pipe at `path` until `ctx` cancellation or timeout.
package winio
import (
	"context"
	"errors"
	"fmt"
	"io"
	"net"
	"os"
	"runtime"
	"syscall"
	"time"
	"unsafe"
)
type ioStatusBlock struct {
	Status, Information uintptr
}
type objectAttributes struct {
	Length             uintptr
	RootDirectory      uintptr
	ObjectName         *unicodeString
	Attributes         uintptr
	SecurityDescriptor *securityDescriptor
	SecurityQoS        uintptr
}
type unicodeString struct {
	Length        uint16
	MaximumLength uint16
	Buffer        uintptr
}
type securityDescriptor struct {
	Revision byte
	Sbz1     byte
	Control  uint16
	Owner    uintptr
	Group    uintptr
	Sacl     uintptr
	Dacl     uintptr
}
type ntstatus int32
func (status ntstatus) Err() error {
	if status >= 0 {
		return nil
	}
	return rtlNtStatusToDosError(status)
}
const (
	cERROR_PIPE_BUSY      = syscall.Errno(231)
	cERROR_NO_DATA        = syscall.Errno(232)
	cERROR_PIPE_CONNECTED = syscall.Errno(535)
	cERROR_SEM_TIMEOUT    = syscall.Errno(121)
	cSECURITY_SQOS_PRESENT = 0x100000
	cSECURITY_ANONYMOUS    = 0
	cPIPE_TYPE_MESSAGE = 4
	cPIPE_READMODE_MESSAGE = 2
	cFILE_OPEN   = 1
	cFILE_CREATE = 2
	cFILE_PIPE_MESSAGE_TYPE          = 1
	cFILE_PIPE_REJECT_REMOTE_CLIENTS = 2
	cSE_DACL_PRESENT = 4
)
var (
	ErrPipeListenerClosed = errors.New("use of closed network connection")
	errPipeWriteClosed = errors.New("pipe has been closed for write")
)
type win32Pipe struct {
	*win32File
	path string
}
type win32MessageBytePipe struct {
	win32Pipe
	writeClosed bool
	readEOF     bool
}
type pipeAddress string
func (f *win32Pipe) LocalAddr() net.Addr {
	return pipeAddress(f.path)
}
func (f *win32Pipe) RemoteAddr() net.Addr {
	return pipeAddress(f.path)
}
func (f *win32Pipe) SetDeadline(t time.Time) error {
	f.SetReadDeadline(t)
	f.SetWriteDeadline(t)
	return nil
}
func (f *win32MessageBytePipe) CloseWrite() error {
	if f.writeClosed {
		return errPipeWriteClosed
	}
	err := f.win32File.Flush()
	if err != nil {
		return err
	}
	_, err = f.win32File.Write(nil)
	if err != nil {
		return err
	}
	f.writeClosed = true
	return nil
}
func (f *win32MessageBytePipe) Write(b []byte) (int, error) {
	if f.writeClosed {
		return 0, errPipeWriteClosed
	}
	if len(b) == 0 {
		return 0, nil
	}
	return f.win32File.Write(b)
}
func (f *win32MessageBytePipe) Read(b []byte) (int, error) {
	if f.readEOF {
		return 0, io.EOF
	}
	n, err := f.win32File.Read(b)
	if err == io.EOF {
		f.readEOF = true
	} else if err == syscall.ERROR_MORE_DATA {
		err = nil
	}
	return n, err
}
func (s pipeAddress) Network() string {
	return "pipe"
}
func (s pipeAddress) String() string {
	return string(s)
}