func (self *FirewallRuleEnumerator) Next() (*FirewallRule, error) { if self.object == nil { return nil, NewWindowsError("IEnumVARIANT::Next", COMErrorPointer) } var varRaw wrappers.VARIANT if hr := self.object.Next(1, &varRaw, nil); wrappers.FAILED(hr) { return nil, NewWindowsError("IEnumVARIANT::Next", COMError(hr)) } else if hr == wrappers.S_FALSE { return nil, nil } defer wrappers.VariantClear(&varRaw) var varDispatch wrappers.VARIANT if hr := wrappers.VariantChangeType(&varDispatch, &varRaw, 0, wrappers.VT_DISPATCH); wrappers.FAILED(hr) { return nil, NewWindowsError("VariantChangeType", COMError(hr)) } defer wrappers.VariantClear(&varDispatch) dispatch := (*wrappers.IDispatch)(unsafe.Pointer(uintptr(varDispatch.Val[0]))) var rule uintptr if hr := dispatch.QueryInterface(&wrappers.IID_INetFwRule, &rule); wrappers.FAILED(hr) { return nil, NewWindowsError("IUnknown::QueryInterface", COMError(hr)) } return &FirewallRule{object: (*wrappers.INetFwRule)(unsafe.Pointer(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 }