summaryrefslogtreecommitdiffhomepage
path: root/tun
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-02-07 22:37:14 +0100
committerSimon Rozman <simon@rozman.si>2019-02-07 23:50:43 +0100
commit9d830826c53d9b8cd14cf0fcd43fdf4183de4c47 (patch)
treed24f8a43b46f93b236bbf41bf99c2b87e2164ed5 /tun
parentbd963497da908d3910668dab9dab4ac7654a638a (diff)
setupapi: Rename SP_CLASSINSTALL_HEADER to ClassInstallHeader
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'tun')
-rw-r--r--tun/wintun/setupapi/setupapi_windows.go8
-rw-r--r--tun/wintun/setupapi/types_windows.go14
-rw-r--r--tun/wintun/setupapi/zsetupapi_windows.go4
-rw-r--r--tun/wintun/wintun_windows.go14
4 files changed, 20 insertions, 20 deletions
diff --git a/tun/wintun/setupapi/setupapi_windows.go b/tun/wintun/setupapi/setupapi_windows.go
index ca944f1..0d9e695 100644
--- a/tun/wintun/setupapi/setupapi_windows.go
+++ b/tun/wintun/setupapi/setupapi_windows.go
@@ -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)
}
diff --git a/tun/wintun/setupapi/types_windows.go b/tun/wintun/setupapi/types_windows.go
index ae60bd0..7994f3c 100644
--- a/tun/wintun/setupapi/types_windows.go
+++ b/tun/wintun/setupapi/types_windows.go
@@ -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
}
diff --git a/tun/wintun/setupapi/zsetupapi_windows.go b/tun/wintun/setupapi/zsetupapi_windows.go
index 2e8a685..5789b3e 100644
--- a/tun/wintun/setupapi/zsetupapi_windows.go
+++ b/tun/wintun/setupapi/zsetupapi_windows.go
@@ -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 {
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go
index b510d9a..1763692 100644
--- a/tun/wintun/wintun_windows.go
+++ b/tun/wintun/wintun_windows.go
@@ -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)))