From 3518587229cd9a3c7e318c6313852a0095c38e41 Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Wed, 28 Oct 2020 14:35:39 +0800 Subject: [PATCH] windows: add GetFinalPathNameByHandleW https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew Fixes #41686 Change-Id: I207676364a3abc8658498bcd060c8f9694161867 Reviewed-on: https://go-review.googlesource.com/c/sys/+/264577 Trust: Meng Zhuo Run-TryBot: Meng Zhuo TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- windows/syscall_windows.go | 1 + windows/zsyscall_windows.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index cd71f570..88cff4e0 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -350,6 +350,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetThreadPreferredUILanguages //sys getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetUserPreferredUILanguages //sys getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetSystemPreferredUILanguages +//sys GetFinalPathNameByHandleW(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) = kernel32.GetFinalPathNameByHandleW // Process Status API (PSAPI) //sys EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go index f50d0373..a1c801d1 100644 --- a/windows/zsyscall_windows.go +++ b/windows/zsyscall_windows.go @@ -209,6 +209,7 @@ var ( procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle") procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") procGetFileType = modkernel32.NewProc("GetFileType") + procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW") procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW") procGetLastError = modkernel32.NewProc("GetLastError") procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW") @@ -1717,6 +1718,15 @@ func GetFileType(filehandle Handle) (n uint32, err error) { return } +func GetFinalPathNameByHandleW(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) { + r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0) + n = uint32(r0) + if n == 0 { + err = errnoErr(e1) + } + return +} + func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) { r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0) n = uint32(r0)