diff --git a/windows/exec_windows.go b/windows/exec_windows.go index aa4ff5a7..9d42248e 100644 --- a/windows/exec_windows.go +++ b/windows/exec_windows.go @@ -130,9 +130,8 @@ func SetNonblock(fd Handle, nonblocking bool) (err error) { return nil } -// getFullPath retrieves the full path of the specified file. -// Just a wrapper for Windows GetFullPathName api. -func getFullPath(name string) (path string, err error) { +// FullPath retrieves the full path of the specified file. +func FullPath(name string) (path string, err error) { p, err := UTF16PtrFromString(name) if err != nil { return "", err @@ -161,7 +160,7 @@ func isSlash(c uint8) bool { } func normalizeDir(dir string) (name string, err error) { - ndir, err := getFullPath(dir) + ndir, err := FullPath(dir) if err != nil { return "", err } @@ -200,9 +199,9 @@ func joinExeDirAndFName(dir, p string) (name string, err error) { return "", err } if volToUpper(int(p[0])) == volToUpper(int(d[0])) { - return getFullPath(d + "\\" + p[2:]) + return FullPath(d + "\\" + p[2:]) } else { - return getFullPath(p) + return FullPath(p) } } } else { @@ -212,9 +211,9 @@ func joinExeDirAndFName(dir, p string) (name string, err error) { return "", err } if isSlash(p[0]) { - return getFullPath(d[:2] + p) + return FullPath(d[:2] + p) } else { - return getFullPath(d + "\\" + p) + return FullPath(d + "\\" + p) } } // we shouldn't be here diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index c318c53d..7a0d8c3e 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -515,6 +515,7 @@ const socket_error = uintptr(^uint32(0)) //sys GetProtoByName(name string) (p *Protoent, err error) [failretval==nil] = ws2_32.getprotobyname //sys DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) = dnsapi.DnsQuery_W //sys DnsRecordListFree(rl *DNSRecord, freetype uint32) = dnsapi.DnsRecordListFree +//sys DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) = dnsapi.DnsNameCompare_W //sys GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) = ws2_32.GetAddrInfoW //sys FreeAddrInfoW(addrinfo *AddrinfoW) = ws2_32.FreeAddrInfoW //sys GetIfEntry(pIfRow *MibIfRow) (errcode error) = iphlpapi.GetIfEntry diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go index 69f0e376..e6a76624 100644 --- a/windows/zsyscall_windows.go +++ b/windows/zsyscall_windows.go @@ -140,6 +140,7 @@ var ( procgetprotobyname = modws2_32.NewProc("getprotobyname") procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W") procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") + procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W") procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") procGetIfEntry = modiphlpapi.NewProc("GetIfEntry") @@ -1635,6 +1636,12 @@ func DnsRecordListFree(rl *DNSRecord, freetype uint32) { return } +func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) { + r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0) + same = r0 != 0 + return +} + func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) { r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0) if r0 != 0 { diff --git a/windows/ztypes_windows.go b/windows/ztypes_windows.go index c51107b8..4cd63616 100644 --- a/windows/ztypes_windows.go +++ b/windows/ztypes_windows.go @@ -694,6 +694,18 @@ const ( DNS_TYPE_NBSTAT = 0xff01 ) +const ( + DNS_INFO_NO_RECORDS = 0x251D +) + +const ( + // flags inside DNSRecord.Dw + DnsSectionQuestion = 0x0000 + DnsSectionAnswer = 0x0001 + DnsSectionAuthority = 0x0002 + DnsSectionAdditional = 0x0003 +) + type DNSSRVData struct { Target *uint16 Priority uint16