2019-08-21 06:40:44 +00:00
|
|
|
/* SPDX-License-Identifier: MIT
|
|
|
|
*
|
2020-05-02 08:08:26 +00:00
|
|
|
* Copyright (C) 2020 WireGuard LLC. All Rights Reserved.
|
2019-08-21 06:40:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package nci
|
|
|
|
|
|
|
|
import "golang.org/x/sys/windows"
|
|
|
|
|
|
|
|
//sys nciSetConnectionName(guid *windows.GUID, newName *uint16) (ret error) = nci.NciSetConnectionName
|
|
|
|
//sys nciGetConnectionName(guid *windows.GUID, destName *uint16, inDestNameBytes uint32, outDestNameBytes *uint32) (ret error) = nci.NciGetConnectionName
|
|
|
|
|
|
|
|
func SetConnectionName(guid *windows.GUID, newName string) error {
|
|
|
|
newName16, err := windows.UTF16PtrFromString(newName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nciSetConnectionName(guid, newName16)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ConnectionName(guid *windows.GUID) (string, error) {
|
|
|
|
var name [0x400]uint16
|
|
|
|
err := nciGetConnectionName(guid, &name[0], uint32(len(name)*2), nil)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return windows.UTF16ToString(name[:]), nil
|
|
|
|
}
|