From 16da32be82c5df9a338c27758247c0b7b0bd8fea Mon Sep 17 00:00:00 2001 From: James Nugent Date: Sun, 14 Apr 2019 19:23:05 +0000 Subject: [PATCH] windows: add GetFileInformationByHandleEx function Change-Id: I950762ef59c665d027641b4410ac30697edad22d Reviewed-on: https://go-review.googlesource.com/c/sys/+/171939 Reviewed-by: Alex Brainman Run-TryBot: Alex Brainman TryBot-Result: Gobot Gobot --- windows/syscall_windows.go | 1 + windows/zsyscall_windows.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index 7aff0d02..4c9bc55b 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -146,6 +146,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys findNextFile1(handle Handle, data *win32finddata1) (err error) = FindNextFileW //sys FindClose(handle Handle) (err error) //sys GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) +//sys GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) //sys GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) = GetCurrentDirectoryW //sys SetCurrentDirectory(path *uint16) (err error) = SetCurrentDirectoryW //sys CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) = CreateDirectoryW diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go index eb9f0629..7060f434 100644 --- a/windows/zsyscall_windows.go +++ b/windows/zsyscall_windows.go @@ -86,6 +86,7 @@ var ( procFindNextFileW = modkernel32.NewProc("FindNextFileW") procFindClose = modkernel32.NewProc("FindClose") procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle") + procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW") procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW") @@ -772,6 +773,18 @@ func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (e return } +func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) { r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) n = uint32(r0)