func TranslateADName(name string, fromType ADNameType, toType ADNameType) (string, error) { var object uintptr hr := wrappers.CoCreateInstance( &wrappers.CLSID_NameTranslate, nil, wrappers.CLSCTX_INPROC_SERVER, &wrappers.IID_IADsNameTranslate, &object) if wrappers.FAILED(hr) { return "", NewWindowsError("CoCreateInstance", COMError(hr)) } trans := (*wrappers.IADsNameTranslate)(unsafe.Pointer(object)) defer trans.Release() if hr := trans.Init(wrappers.ADS_NAME_INITTYPE_GC, nil); wrappers.FAILED(hr) { return "", NewWindowsError("IADsNameTranslate::Init", COMError(hr)) } nameRaw := wrappers.SysAllocString(syscall.StringToUTF16Ptr(name)) defer wrappers.SysFreeString(nameRaw) if hr := trans.Set(int32(fromType), nameRaw); wrappers.FAILED(hr) { return "", NewWindowsError("IADsNameTranslate::Set", COMError(hr)) } var outRaw *uint16 if hr := trans.Get(int32(toType), &outRaw); wrappers.FAILED(hr) { return "", NewWindowsError("IADsNameTranslate::Get", COMError(hr)) } return BstrToString(outRaw), nil }
func (self *FirewallRule) SetGrouping(context string) error { if self.object == nil { return NewWindowsError("INetFwRule::put_Grouping", COMErrorPointer) } contextRaw := wrappers.SysAllocString(syscall.StringToUTF16Ptr(context)) defer wrappers.SysFreeString(contextRaw) if hr := self.object.Put_Grouping(contextRaw); wrappers.FAILED(hr) { return NewWindowsError("INetFwRule::put_grouping", COMError(hr)) } return nil }
func (self *FirewallRule) SetName(name string) error { if self.object == nil { return NewWindowsError("INetFwRule::put_Name", COMErrorPointer) } nameRaw := wrappers.SysAllocString(syscall.StringToUTF16Ptr(name)) defer wrappers.SysFreeString(nameRaw) if hr := self.object.Put_Name(nameRaw); wrappers.FAILED(hr) { return NewWindowsError("INetFwRule::put_Name", COMError(hr)) } return nil }
func (self *FirewallRule) SetInterfaceTypes(interfaceTypes string) error { if self.object == nil { return NewWindowsError("INetFwRule::put_InterfaceTypes", COMErrorPointer) } interfaceTypesRaw := wrappers.SysAllocString(syscall.StringToUTF16Ptr(interfaceTypes)) defer wrappers.SysFreeString(interfaceTypesRaw) if hr := self.object.Put_InterfaceTypes(interfaceTypesRaw); wrappers.FAILED(hr) { return NewWindowsError("INetFwRule::put_InterfaceTypes", COMError(hr)) } return nil }
func (self *FirewallRule) SetRemotePorts(portNumbers string) error { if self.object == nil { return NewWindowsError("INetFwRule::put_RemotePorts", COMErrorPointer) } portNumbersRaw := wrappers.SysAllocString(syscall.StringToUTF16Ptr(portNumbers)) defer wrappers.SysFreeString(portNumbersRaw) if hr := self.object.Put_RemotePorts(portNumbersRaw); wrappers.FAILED(hr) { return NewWindowsError("INetFwRule::put_RemotePorts", COMError(hr)) } return nil }
func (self *FirewallRule) SetDescription(desc string) error { if self.object == nil { return NewWindowsError("INetFwRule::put_Description", COMErrorPointer) } descRaw := wrappers.SysAllocString(syscall.StringToUTF16Ptr(desc)) defer wrappers.SysFreeString(descRaw) if hr := self.object.Put_Description(descRaw); wrappers.FAILED(hr) { return NewWindowsError("INetFwRule::put_Description", COMError(hr)) } return nil }
func (self *FirewallRuleCollection) Item(name string) (*FirewallRule, error) { if self.object == nil { return nil, NewWindowsError("INetFwRules::Item", COMErrorPointer) } nameRaw := wrappers.SysAllocString(syscall.StringToUTF16Ptr(name)) defer wrappers.SysFreeString(nameRaw) var rule *wrappers.INetFwRule if hr := self.object.Item(nameRaw, &rule); wrappers.FAILED(hr) { return nil, NewWindowsError("INetFwRules::Item", COMError(hr)) } return &FirewallRule{object: rule}, nil }
func (self *FirewallManager) IsPortAllowed(imageFileName string, ipVersion FirewallIPVersion, portNumber int, localAddress string, ipProtocol FirewallProtocol) (allowed bool, restricted bool, err error) { if self.object == nil { err = COMErrorPointer return } var imageFileNameRaw *uint16 if imageFileName != "" { imageFileNameRaw = wrappers.SysAllocString(syscall.StringToUTF16Ptr(imageFileName)) defer wrappers.SysFreeString(imageFileNameRaw) } var localAddressRaw *uint16 if localAddress != "" { localAddressRaw = wrappers.SysAllocString(syscall.StringToUTF16Ptr(localAddress)) defer wrappers.SysFreeString(localAddressRaw) } var allowedRaw wrappers.VARIANT wrappers.VariantInit(&allowedRaw) defer wrappers.VariantClear(&allowedRaw) var restrictedRaw wrappers.VARIANT wrappers.VariantInit(&restrictedRaw) defer wrappers.VariantClear(&restrictedRaw) hr := self.object.IsPortAllowed( imageFileNameRaw, int32(ipVersion), int32(portNumber), localAddressRaw, int32(ipProtocol), &allowedRaw, &restrictedRaw) if wrappers.SUCCEEDED(hr) { allowed = allowedRaw.Vt == wrappers.VT_BOOL && int16(allowedRaw.Val[0]) != wrappers.VARIANT_FALSE restricted = restrictedRaw.Vt == wrappers.VT_BOOL && int16(restrictedRaw.Val[0]) != wrappers.VARIANT_FALSE } else { err = NewWindowsError("INetFwMgr::IsPortAllowed", COMError(hr)) } return }