mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-30 03:03:10 +01:00
setupapi: Rename SP_CLASSINSTALL_HEADER to ClassInstallHeader
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
bd963497da
commit
9d830826c5
@ -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.
|
// 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.
|
// 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)
|
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.
|
// 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.
|
// 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)
|
return SetupDiSetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,12 +255,18 @@ const (
|
|||||||
DI_FLAGSEX_SEARCH_PUBLISHED_INFS DI_FLAGSEX = 0x80000000 // Tell SetupDiBuildDriverInfoList to do a "published INF" search
|
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.
|
// 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 SP_CLASSINSTALL_HEADER struct {
|
type ClassInstallHeader struct {
|
||||||
Size uint32
|
size uint32
|
||||||
InstallFunction DI_FUNCTION
|
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
|
// DICS_FLAG specifies the scope of a device property change
|
||||||
type DICS_FLAG uint32
|
type DICS_FLAG uint32
|
||||||
|
|
||||||
@ -280,7 +286,7 @@ const (
|
|||||||
|
|
||||||
// SP_REMOVEDEVICE_PARAMS is a structure corresponding to a DIF_REMOVE install function.
|
// SP_REMOVEDEVICE_PARAMS is a structure corresponding to a DIF_REMOVE install function.
|
||||||
type SP_REMOVEDEVICE_PARAMS struct {
|
type SP_REMOVEDEVICE_PARAMS struct {
|
||||||
ClassInstallHeader SP_CLASSINSTALL_HEADER
|
ClassInstallHeader ClassInstallHeader
|
||||||
Scope DI_REMOVEDEVICE
|
Scope DI_REMOVEDEVICE
|
||||||
HwProfile uint32
|
HwProfile uint32
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ func setupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInf
|
|||||||
return
|
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)
|
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 r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
@ -309,7 +309,7 @@ func SetupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInf
|
|||||||
return
|
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)
|
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 r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
@ -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.
|
// The interface failed to install, or the interface ID was unobtainable. Clean-up.
|
||||||
removeDeviceParams := setupapi.SP_REMOVEDEVICE_PARAMS{
|
removeDeviceParams := setupapi.SP_REMOVEDEVICE_PARAMS{
|
||||||
ClassInstallHeader: setupapi.SP_CLASSINSTALL_HEADER{
|
ClassInstallHeader: *setupapi.MakeClassInstallHeader(setupapi.DIF_REMOVE),
|
||||||
InstallFunction: setupapi.DIF_REMOVE,
|
Scope: setupapi.DI_REMOVEDEVICE_GLOBAL,
|
||||||
},
|
|
||||||
Scope: setupapi.DI_REMOVEDEVICE_GLOBAL,
|
|
||||||
}
|
}
|
||||||
removeDeviceParams.ClassInstallHeader.Size = uint32(unsafe.Sizeof(removeDeviceParams.ClassInstallHeader))
|
|
||||||
|
|
||||||
// Set class installer parameters for DIF_REMOVE.
|
// Set class installer parameters for DIF_REMOVE.
|
||||||
if devInfoList.SetClassInstallParams(deviceData, &removeDeviceParams.ClassInstallHeader, uint32(unsafe.Sizeof(removeDeviceParams))) == nil {
|
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 {
|
if *ifid == *ifid2 {
|
||||||
// Remove the device.
|
// Remove the device.
|
||||||
removeDeviceParams := setupapi.SP_REMOVEDEVICE_PARAMS{
|
removeDeviceParams := setupapi.SP_REMOVEDEVICE_PARAMS{
|
||||||
ClassInstallHeader: setupapi.SP_CLASSINSTALL_HEADER{
|
ClassInstallHeader: *setupapi.MakeClassInstallHeader(setupapi.DIF_REMOVE),
|
||||||
InstallFunction: setupapi.DIF_REMOVE,
|
Scope: setupapi.DI_REMOVEDEVICE_GLOBAL,
|
||||||
},
|
|
||||||
Scope: setupapi.DI_REMOVEDEVICE_GLOBAL,
|
|
||||||
}
|
}
|
||||||
removeDeviceParams.ClassInstallHeader.Size = uint32(unsafe.Sizeof(removeDeviceParams.ClassInstallHeader))
|
|
||||||
|
|
||||||
// Set class installer parameters for DIF_REMOVE.
|
// Set class installer parameters for DIF_REMOVE.
|
||||||
err = devInfoList.SetClassInstallParams(deviceData, &removeDeviceParams.ClassInstallHeader, uint32(unsafe.Sizeof(removeDeviceParams)))
|
err = devInfoList.SetClassInstallParams(deviceData, &removeDeviceParams.ClassInstallHeader, uint32(unsafe.Sizeof(removeDeviceParams)))
|
||||||
|
Loading…
Reference in New Issue
Block a user