]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
setupapi: Rename SP_CLASSINSTALL_HEADER to ClassInstallHeader
authorSimon Rozman <simon@rozman.si>
Thu, 7 Feb 2019 21:37:14 +0000 (22:37 +0100)
committerSimon Rozman <simon@rozman.si>
Thu, 7 Feb 2019 22:50:43 +0000 (23:50 +0100)
Signed-off-by: Simon Rozman <simon@rozman.si>
tun/wintun/setupapi/setupapi_windows.go
tun/wintun/setupapi/types_windows.go
tun/wintun/setupapi/zsetupapi_windows.go
tun/wintun/wintun_windows.go

index ca944f134b406da9a9a5d124e16f9ff91871f331..0d9e6954894fad22da2450169d2b366d0187a6b4 100644 (file)
@@ -348,10 +348,10 @@ func (deviceInfoSet DevInfo) GetDeviceInstallParams(deviceInfoData *DevInfoData)
 }
 
 // SetupDiGetClassInstallParams function retrieves class installation parameters for a device information set or a particular device information element.
-//sys  SetupDiGetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *SP_CLASSINSTALL_HEADER, classInstallParamsSize uint32, requiredSize *uint32) (err error) = setupapi.SetupDiGetClassInstallParamsW
+//sys  SetupDiGetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) (err error) = setupapi.SetupDiGetClassInstallParamsW
 
 // GetClassInstallParams method retrieves class installation parameters for a device information set or a particular device information element.
-func (deviceInfoSet DevInfo) GetClassInstallParams(deviceInfoData *DevInfoData, classInstallParams *SP_CLASSINSTALL_HEADER, classInstallParamsSize uint32, requiredSize *uint32) error {
+func (deviceInfoSet DevInfo) GetClassInstallParams(deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) error {
        return SetupDiGetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize, requiredSize)
 }
 
@@ -363,10 +363,10 @@ func (deviceInfoSet DevInfo) SetDeviceInstallParams(deviceInfoData *DevInfoData,
 }
 
 // SetupDiSetClassInstallParams function sets or clears class install parameters for a device information set or a particular device information element.
-//sys  SetupDiSetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *SP_CLASSINSTALL_HEADER, classInstallParamsSize uint32) (err error) = setupapi.SetupDiSetClassInstallParamsW
+//sys  SetupDiSetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32) (err error) = setupapi.SetupDiSetClassInstallParamsW
 
 // SetClassInstallParams method sets or clears class install parameters for a device information set or a particular device information element.
-func (deviceInfoSet DevInfo) SetClassInstallParams(deviceInfoData *DevInfoData, classInstallParams *SP_CLASSINSTALL_HEADER, classInstallParamsSize uint32) error {
+func (deviceInfoSet DevInfo) SetClassInstallParams(deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32) error {
        return SetupDiSetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize)
 }
 
index ae60bd0eb4ce5387cf044ea7432b3d395e6f5729..7994f3c63f97b7c360a7e27a3f89f8ca5f9c1ed1 100644 (file)
@@ -255,12 +255,18 @@ const (
        DI_FLAGSEX_SEARCH_PUBLISHED_INFS    DI_FLAGSEX = 0x80000000 // Tell SetupDiBuildDriverInfoList to do a "published INF" search
 )
 
-// SP_CLASSINSTALL_HEADER is the first member of any class install parameters structure. It contains the device installation request code that defines the format of the rest of the install parameters structure.
-type SP_CLASSINSTALL_HEADER struct {
-       Size            uint32
+// ClassInstallHeader is the first member of any class install parameters structure. It contains the device installation request code that defines the format of the rest of the install parameters structure.
+type ClassInstallHeader struct {
+       size            uint32
        InstallFunction DI_FUNCTION
 }
 
+func MakeClassInstallHeader(installFunction DI_FUNCTION) *ClassInstallHeader {
+       hdr := &ClassInstallHeader{InstallFunction: installFunction}
+       hdr.size = uint32(unsafe.Sizeof(*hdr))
+       return hdr
+}
+
 // DICS_FLAG specifies the scope of a device property change
 type DICS_FLAG uint32
 
@@ -280,7 +286,7 @@ const (
 
 // SP_REMOVEDEVICE_PARAMS is a structure corresponding to a DIF_REMOVE install function.
 type SP_REMOVEDEVICE_PARAMS struct {
-       ClassInstallHeader SP_CLASSINSTALL_HEADER
+       ClassInstallHeader ClassInstallHeader
        Scope              DI_REMOVEDEVICE
        HwProfile          uint32
 }
index 2e8a6854f43016d99405ce0884d5209b30ed4add..5789b3e597e866ea39e9bd86985f283e21e30538 100644 (file)
@@ -285,7 +285,7 @@ func setupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInf
        return
 }
 
-func SetupDiGetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *SP_CLASSINSTALL_HEADER, classInstallParamsSize uint32, requiredSize *uint32) (err error) {
+func SetupDiGetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) (err error) {
        r1, _, e1 := syscall.Syscall6(procSetupDiGetClassInstallParamsW.Addr(), 5, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(classInstallParams)), uintptr(classInstallParamsSize), uintptr(unsafe.Pointer(requiredSize)), 0)
        if r1 == 0 {
                if e1 != 0 {
@@ -309,7 +309,7 @@ func SetupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInf
        return
 }
 
-func SetupDiSetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *SP_CLASSINSTALL_HEADER, classInstallParamsSize uint32) (err error) {
+func SetupDiSetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32) (err error) {
        r1, _, e1 := syscall.Syscall6(procSetupDiSetClassInstallParamsW.Addr(), 4, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(classInstallParams)), uintptr(classInstallParamsSize), 0, 0)
        if r1 == 0 {
                if e1 != 0 {
index b510d9a0435c4ff3c021fb54eff871a869921e66..176369216e809e1f5b0574a20ba9bfb9149f9493 100644 (file)
@@ -250,12 +250,9 @@ func CreateInterface(description string, hwndParent uintptr) (*Wintun, bool, err
 
        // The interface failed to install, or the interface ID was unobtainable. Clean-up.
        removeDeviceParams := setupapi.SP_REMOVEDEVICE_PARAMS{
-               ClassInstallHeader: setupapi.SP_CLASSINSTALL_HEADER{
-                       InstallFunction: setupapi.DIF_REMOVE,
-               },
-               Scope: setupapi.DI_REMOVEDEVICE_GLOBAL,
+               ClassInstallHeader: *setupapi.MakeClassInstallHeader(setupapi.DIF_REMOVE),
+               Scope:              setupapi.DI_REMOVEDEVICE_GLOBAL,
        }
-       removeDeviceParams.ClassInstallHeader.Size = uint32(unsafe.Sizeof(removeDeviceParams.ClassInstallHeader))
 
        // Set class installer parameters for DIF_REMOVE.
        if devInfoList.SetClassInstallParams(deviceData, &removeDeviceParams.ClassInstallHeader, uint32(unsafe.Sizeof(removeDeviceParams))) == nil {
@@ -314,12 +311,9 @@ func (wintun *Wintun) DeleteInterface(hwndParent uintptr) (bool, bool, error) {
                if *ifid == *ifid2 {
                        // Remove the device.
                        removeDeviceParams := setupapi.SP_REMOVEDEVICE_PARAMS{
-                               ClassInstallHeader: setupapi.SP_CLASSINSTALL_HEADER{
-                                       InstallFunction: setupapi.DIF_REMOVE,
-                               },
-                               Scope: setupapi.DI_REMOVEDEVICE_GLOBAL,
+                               ClassInstallHeader: *setupapi.MakeClassInstallHeader(setupapi.DIF_REMOVE),
+                               Scope:              setupapi.DI_REMOVEDEVICE_GLOBAL,
                        }
-                       removeDeviceParams.ClassInstallHeader.Size = uint32(unsafe.Sizeof(removeDeviceParams.ClassInstallHeader))
 
                        // Set class installer parameters for DIF_REMOVE.
                        err = devInfoList.SetClassInstallParams(deviceData, &removeDeviceParams.ClassInstallHeader, uint32(unsafe.Sizeof(removeDeviceParams)))