Exemple #1
1
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
}
Exemple #2
0
func (self *FirewallRuleCollection) NewEnumerator() (*FirewallRuleEnumerator, error) {
	if self.object == nil {
		return nil, NewWindowsError("INetFwRules::get__NewEnum", COMErrorPointer)
	}
	var punkEnumerator *wrappers.IUnknown
	if hr := self.object.Get__NewEnum(&punkEnumerator); wrappers.FAILED(hr) {
		return nil, NewWindowsError("INetFwRules::get__NewEnum", COMError(hr))
	}
	defer punkEnumerator.Release()
	var enumerator uintptr
	if hr := punkEnumerator.QueryInterface(&wrappers.IID_IEnumVARIANT, &enumerator); wrappers.FAILED(hr) {
		return nil, NewWindowsError("IUnknown::QueryInterface", COMError(hr))
	}
	return &FirewallRuleEnumerator{object: (*wrappers.IEnumVARIANT)(unsafe.Pointer(enumerator))}, nil
}
Exemple #3
0
func GetSpecialFolderPath(folder SpecialFolder) (string, error) {
	buf := [wrappers.MAX_PATH]uint16{}
	if hr := wrappers.SHGetFolderPath(0, uint32(folder), 0, 0, &buf[0]); wrappers.FAILED(hr) {
		return "", NewWindowsError("SHGetFolderPath", COMError(hr))
	}
	return syscall.UTF16ToString((&buf)[:]), nil
}
Exemple #4
0
func GetKnownFolderPath(folder KnownFolder) (string, error) {
	var path *uint16
	if hr := wrappers.SHGetKnownFolderPath((*wrappers.GUID)(&folder), 0, 0, &path); wrappers.FAILED(hr) {
		return "", NewWindowsError("SHGetKnownFolderPath", COMError(hr))
	}
	defer wrappers.CoTaskMemFree((*byte)(unsafe.Pointer(path)))
	return LpstrToString(path), nil
}
Exemple #5
0
func (self *FirewallRule) SetProtocol(protocol FirewallProtocol) error {
	if self.object == nil {
		return NewWindowsError("INetFwRule::put_Protocol", COMErrorPointer)
	}
	if hr := self.object.Put_Protocol(int32(protocol)); wrappers.FAILED(hr) {
		return NewWindowsError("INetFwRule::put_Protocol", COMError(hr))
	}
	return nil
}
Exemple #6
0
func (self *FirewallRuleEnumerator) Skip(count uint) error {
	if self.object == nil {
		return NewWindowsError("IEnumVARIANT::Skip", COMErrorPointer)
	}
	if hr := self.object.Skip(uint32(count)); wrappers.FAILED(hr) {
		return NewWindowsError("IEnumVARIANT::Skip", COMError(hr))
	}
	return nil
}
Exemple #7
0
func (self *FirewallRule) SetAction(action FirewallAction) error {
	if self.object == nil {
		return NewWindowsError("INetFwRule::put_Action", COMErrorPointer)
	}
	if hr := self.object.Put_Action(int32(action)); wrappers.FAILED(hr) {
		return NewWindowsError("INetFwRule::put_Action", COMError(hr))
	}
	return nil
}
Exemple #8
0
func (self *FirewallRule) SetEdgeTraversal(enabled bool) error {
	if self.object == nil {
		return NewWindowsError("INetFwRule::put_EdgeTraversal", COMErrorPointer)
	}
	if hr := self.object.Put_EdgeTraversal(enabled); wrappers.FAILED(hr) {
		return NewWindowsError("INetFwRule::put_EdgeTraversal", COMError(hr))
	}
	return nil
}
Exemple #9
0
func (self *FirewallRuleEnumerator) Reset() error {
	if self.object == nil {
		return NewWindowsError("IEnumVARIANT::Reset", COMErrorPointer)
	}
	if hr := self.object.Reset(); wrappers.FAILED(hr) {
		return NewWindowsError("IEnumVARIANT::Reset", COMError(hr))
	}
	return nil
}
Exemple #10
0
func (self *FirewallRuleCollection) Add(rule *FirewallRule) error {
	if self.object == nil {
		return NewWindowsError("INetFwRules::Add", COMErrorPointer)
	}
	if hr := self.object.Add(rule.object); wrappers.FAILED(hr) {
		return NewWindowsError("INetFwRules::Add", COMError(hr))
	}
	return nil
}
Exemple #11
0
func (self *FirewallRule) GetEdgeTraversal() (bool, error) {
	if self.object == nil {
		return false, NewWindowsError("INetFwRule::get_EdgeTraversal", COMErrorPointer)
	}
	var enabled bool
	if hr := self.object.Get_EdgeTraversal(&enabled); wrappers.FAILED(hr) {
		return false, NewWindowsError("INetFwRule::put_EdgeTraversal", COMError(hr))
	}
	return enabled, nil
}
Exemple #12
0
func (self *FirewallRule) GetGrouping() (string, error) {
	if self.object == nil {
		return "", NewWindowsError("INetFwRule::get_Grouping", COMErrorPointer)
	}
	var contextRaw *uint16
	if hr := self.object.Get_Grouping(&contextRaw); wrappers.FAILED(hr) {
		return "", NewWindowsError("INetFwRule::get_Grouping", COMError(hr))
	}
	return BstrToString(contextRaw), nil
}
Exemple #13
0
func (self *FirewallRule) GetAction() (FirewallAction, error) {
	if self.object == nil {
		return 0, NewWindowsError("INetFwRule::get_Action", COMErrorPointer)
	}
	var actionRaw int32
	if hr := self.object.Get_Action(&actionRaw); wrappers.FAILED(hr) {
		return 0, NewWindowsError("INetFwRule::get_Action", COMError(hr))
	}
	return FirewallAction(actionRaw), nil
}
Exemple #14
0
func (self *FirewallRule) GetDescription() (string, error) {
	if self.object == nil {
		return "", NewWindowsError("INetFwRule::get_Description", COMErrorPointer)
	}
	var descRaw *uint16
	if hr := self.object.Get_Description(&descRaw); wrappers.FAILED(hr) {
		return "", NewWindowsError("INetFwRule::get_Description", COMError(hr))
	}
	return BstrToString(descRaw), nil
}
Exemple #15
0
func (self *FirewallRule) GetRemoteAddresses() (string, error) {
	if self.object == nil {
		return "", NewWindowsError("INetFwRule::get_RemoteAddresses", COMErrorPointer)
	}
	var remoteAddrsRaw *uint16
	if hr := self.object.Get_RemoteAddresses(&remoteAddrsRaw); wrappers.FAILED(hr) {
		return "", NewWindowsError("INetFwRule::get_RemoteAddresses", COMError(hr))
	}
	return BstrToString(remoteAddrsRaw), nil
}
Exemple #16
0
func (self *FirewallRule) GetLocalPorts() (string, error) {
	if self.object == nil {
		return "", NewWindowsError("INetFwRule::get_LocalPorts", COMErrorPointer)
	}
	var portNumbersRaw *uint16
	if hr := self.object.Get_LocalPorts(&portNumbersRaw); wrappers.FAILED(hr) {
		return "", NewWindowsError("INetFwRule::get_LocalPorts", COMError(hr))
	}
	return BstrToString(portNumbersRaw), nil
}
Exemple #17
0
func (self *FirewallRule) GetProtocol() (FirewallProtocol, error) {
	if self.object == nil {
		return 0, NewWindowsError("INetFwRule::get_Protocol", COMErrorPointer)
	}
	var protocolRaw int32
	if hr := self.object.Get_Protocol(&protocolRaw); wrappers.FAILED(hr) {
		return 0, NewWindowsError("INetFwRule::get_Protocol", COMError(hr))
	}
	return FirewallProtocol(protocolRaw), nil
}
Exemple #18
0
func (self *ADSystemInfo) GetDomainDNSName() (string, error) {
	if self.object == nil {
		return "", NewWindowsError("IADsADSystemInfo::get_DomainDNSName", COMErrorPointer)
	}
	var retvalRaw *uint16
	if hr := self.object.Get_DomainDNSName(&retvalRaw); wrappers.FAILED(hr) {
		return "", NewWindowsError("IADsADSystemInfo::get_DomainDNSName", COMError(hr))
	}
	return BstrToString(retvalRaw), nil
}
Exemple #19
0
func (self *FirewallRule) GetName() (string, error) {
	if self.object == nil {
		return "", NewWindowsError("INetFwRule::get_Name", COMErrorPointer)
	}
	var nameRaw *uint16
	if hr := self.object.Get_Name(&nameRaw); wrappers.FAILED(hr) {
		return "", NewWindowsError("INetFwRule::get_Name", COMError(hr))
	}
	return BstrToString(nameRaw), nil
}
Exemple #20
0
func (self *FirewallPolicy) GetRules() (*FirewallRuleCollection, error) {
	if self.object == nil {
		return nil, NewWindowsError("INetFwPolicy2::get_Rules", COMErrorPointer)
	}
	var rules *wrappers.INetFwRules
	if hr := self.object.Get_Rules(&rules); wrappers.FAILED(hr) {
		return nil, NewWindowsError("INetFwPolicy2::get_Rules", COMError(hr))
	}
	return &FirewallRuleCollection{object: rules}, nil
}
Exemple #21
0
func (self *FirewallRule) GetInterfaceTypes() (string, error) {
	if self.object == nil {
		return "", NewWindowsError("INetFwRule::get_InterfaceTypes", COMErrorPointer)
	}
	var interfaceTypesRaw *uint16
	if hr := self.object.Get_InterfaceTypes(&interfaceTypesRaw); wrappers.FAILED(hr) {
		return "", NewWindowsError("INetFwRule::get_InterfaceTypes", COMError(hr))
	}
	return BstrToString(interfaceTypesRaw), nil
}
Exemple #22
0
func (self *FirewallRuleCollection) GetCount() (int, error) {
	if self.object == nil {
		return 0, NewWindowsError("INetFwRules::get_Count", COMErrorPointer)
	}
	var count int32
	if hr := self.object.Get_Count(&count); wrappers.FAILED(hr) {
		return 0, NewWindowsError("INetFwRules::get_Count", COMError(hr))
	}
	return int(count), nil
}
Exemple #23
0
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
}
Exemple #24
0
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
}
Exemple #25
0
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
}
Exemple #26
0
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
}
Exemple #27
0
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
}
Exemple #28
0
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
}
Exemple #29
0
func NewADWinNTSystemInfo() (*ADWinNTSystemInfo, error) {
	var object uintptr
	hr := wrappers.CoCreateInstance(
		&wrappers.CLSID_WinNTSystemInfo,
		nil,
		wrappers.CLSCTX_INPROC_SERVER,
		&wrappers.IID_IADsWinNTSystemInfo,
		&object)
	if wrappers.FAILED(hr) {
		return nil, NewWindowsError("CoCreateInstance", COMError(hr))
	}
	return &ADWinNTSystemInfo{object: (*wrappers.IADsWinNTSystemInfo)(unsafe.Pointer(object))}, nil
}
Exemple #30
0
func NewFirewallManager() (*FirewallManager, error) {
	var object uintptr
	hr := wrappers.CoCreateInstance(
		&wrappers.CLSID_NetFwMgr,
		nil,
		wrappers.CLSCTX_INPROC_SERVER,
		&wrappers.IID_INetFwMgr,
		&object)
	if wrappers.FAILED(hr) {
		return nil, NewWindowsError("CoCreateInstance", COMError(hr))
	}
	return &FirewallManager{object: (*wrappers.INetFwMgr)(unsafe.Pointer(object))}, nil
}