2 * Copyright 2009 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
33 #include "hnetcfg_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg
);
37 typedef struct fw_policy
39 INetFwPolicy INetFwPolicy_iface
;
43 static inline fw_policy
*impl_from_INetFwPolicy( INetFwPolicy
*iface
)
45 return CONTAINING_RECORD(iface
, fw_policy
, INetFwPolicy_iface
);
48 typedef struct fw_policy2
50 INetFwPolicy2 INetFwPolicy2_iface
;
54 static inline fw_policy2
*impl_from_INetFwPolicy2( INetFwPolicy2
*iface
)
56 return CONTAINING_RECORD(iface
, fw_policy2
, INetFwPolicy2_iface
);
59 static ULONG WINAPI
fw_policy_AddRef(
62 fw_policy
*fw_policy
= impl_from_INetFwPolicy( iface
);
63 return InterlockedIncrement( &fw_policy
->refs
);
66 static ULONG WINAPI
fw_policy_Release(
69 fw_policy
*fw_policy
= impl_from_INetFwPolicy( iface
);
70 LONG refs
= InterlockedDecrement( &fw_policy
->refs
);
73 TRACE("destroying %p\n", fw_policy
);
74 HeapFree( GetProcessHeap(), 0, fw_policy
);
79 static HRESULT WINAPI
fw_policy_QueryInterface(
84 fw_policy
*This
= impl_from_INetFwPolicy( iface
);
86 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
88 if ( IsEqualGUID( riid
, &IID_INetFwPolicy
) ||
89 IsEqualGUID( riid
, &IID_IDispatch
) ||
90 IsEqualGUID( riid
, &IID_IUnknown
) )
96 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
99 INetFwPolicy_AddRef( iface
);
103 static HRESULT WINAPI
fw_policy_GetTypeInfoCount(
107 fw_policy
*This
= impl_from_INetFwPolicy( iface
);
109 TRACE("%p %p\n", This
, pctinfo
);
114 static HRESULT WINAPI
fw_policy_GetTypeInfo(
118 ITypeInfo
**ppTInfo
)
120 fw_policy
*This
= impl_from_INetFwPolicy( iface
);
122 TRACE("%p %u %u %p\n", This
, iTInfo
, lcid
, ppTInfo
);
123 return get_typeinfo( INetFwPolicy_tid
, ppTInfo
);
126 static HRESULT WINAPI
fw_policy_GetIDsOfNames(
134 fw_policy
*This
= impl_from_INetFwPolicy( iface
);
138 TRACE("%p %s %p %u %u %p\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
140 hr
= get_typeinfo( INetFwPolicy_tid
, &typeinfo
);
143 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, rgszNames
, cNames
, rgDispId
);
144 ITypeInfo_Release( typeinfo
);
149 static HRESULT WINAPI
fw_policy_Invoke(
155 DISPPARAMS
*pDispParams
,
157 EXCEPINFO
*pExcepInfo
,
160 fw_policy
*This
= impl_from_INetFwPolicy( iface
);
164 TRACE("%p %d %s %d %d %p %p %p %p\n", This
, dispIdMember
, debugstr_guid(riid
),
165 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
167 hr
= get_typeinfo( INetFwPolicy_tid
, &typeinfo
);
170 hr
= ITypeInfo_Invoke( typeinfo
, &This
->INetFwPolicy_iface
, dispIdMember
,
171 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
172 ITypeInfo_Release( typeinfo
);
177 static HRESULT WINAPI
fw_policy_get_CurrentProfile(
179 INetFwProfile
**profile
)
181 fw_policy
*This
= impl_from_INetFwPolicy( iface
);
183 TRACE("%p, %p\n", This
, profile
);
184 return NetFwProfile_create( NULL
, (void **)profile
);
187 static HRESULT WINAPI
fw_policy_GetProfileByType(
189 NET_FW_PROFILE_TYPE profileType
,
190 INetFwProfile
**profile
)
192 fw_policy
*This
= impl_from_INetFwPolicy( iface
);
194 FIXME("%p, %u, %p\n", This
, profileType
, profile
);
198 static const struct INetFwPolicyVtbl fw_policy_vtbl
=
200 fw_policy_QueryInterface
,
203 fw_policy_GetTypeInfoCount
,
204 fw_policy_GetTypeInfo
,
205 fw_policy_GetIDsOfNames
,
207 fw_policy_get_CurrentProfile
,
208 fw_policy_GetProfileByType
211 HRESULT
NetFwPolicy_create( IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
215 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
217 fp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*fp
) );
218 if (!fp
) return E_OUTOFMEMORY
;
220 fp
->INetFwPolicy_iface
.lpVtbl
= &fw_policy_vtbl
;
223 *ppObj
= &fp
->INetFwPolicy_iface
;
225 TRACE("returning iface %p\n", *ppObj
);
229 static HRESULT WINAPI
fwpolicy2_QueryInterface(INetFwPolicy2
*iface
, REFIID riid
, void **out
)
231 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
233 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), out
);
235 if ( IsEqualGUID( riid
, &IID_INetFwPolicy2
) ||
236 IsEqualGUID( riid
, &IID_IDispatch
) ||
237 IsEqualGUID( riid
, &IID_IUnknown
) )
243 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
244 return E_NOINTERFACE
;
246 INetFwPolicy2_AddRef( iface
);
250 static ULONG WINAPI
fwpolicy2_AddRef(INetFwPolicy2
*iface
)
252 fw_policy2
*fw_policy
= impl_from_INetFwPolicy2( iface
);
253 return InterlockedIncrement( &fw_policy
->refs
);
256 static ULONG WINAPI
fwpolicy2_Release(INetFwPolicy2
*iface
)
258 fw_policy2
*fw_policy
= impl_from_INetFwPolicy2( iface
);
259 LONG refs
= InterlockedDecrement( &fw_policy
->refs
);
262 TRACE("destroying %p\n", fw_policy
);
263 HeapFree( GetProcessHeap(), 0, fw_policy
);
268 static HRESULT WINAPI
fwpolicy2_GetTypeInfoCount(INetFwPolicy2
*iface
, UINT
*pctinfo
)
270 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
272 TRACE("%p %p\n", This
, pctinfo
);
277 static HRESULT WINAPI
fwpolicy2_GetTypeInfo(INetFwPolicy2
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
**info
)
279 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
281 TRACE("%p %u %u %p\n", This
, iTInfo
, lcid
, info
);
282 return get_typeinfo( INetFwPolicy2_tid
, info
);
285 static HRESULT WINAPI
fwpolicy2_GetIDsOfNames(INetFwPolicy2
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
286 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
288 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
292 TRACE("%p %s %p %u %u %p\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
294 hr
= get_typeinfo( INetFwPolicy2_tid
, &typeinfo
);
297 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, rgszNames
, cNames
, rgDispId
);
298 ITypeInfo_Release( typeinfo
);
303 static HRESULT WINAPI
fwpolicy2_Invoke(INetFwPolicy2
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
304 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
306 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
310 TRACE("%p %d %s %d %d %p %p %p %p\n", This
, dispIdMember
, debugstr_guid(riid
),
311 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
313 hr
= get_typeinfo( INetFwPolicy2_tid
, &typeinfo
);
316 hr
= ITypeInfo_Invoke( typeinfo
, &This
->INetFwPolicy2_iface
, dispIdMember
,
317 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
318 ITypeInfo_Release( typeinfo
);
323 static HRESULT WINAPI
fwpolicy2_get_CurrentProfileTypes(INetFwPolicy2
*iface
, LONG
*profile
)
325 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
327 FIXME("%p %p\n", This
, profile
);
331 static HRESULT WINAPI
fwpolicy2_get_FirewallEnabled(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT_BOOL
*enabled
)
333 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
335 FIXME("%p %d %p\n", This
, profileType
, enabled
);
339 static HRESULT WINAPI
fwpolicy2_put_FirewallEnabled(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT_BOOL enabled
)
341 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
343 FIXME("%p %d %d\n", This
, profileType
, enabled
);
347 static HRESULT WINAPI
fwpolicy2_get_ExcludedInterfaces(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT
*interfaces
)
349 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
351 FIXME("%p %d %p\n", This
, profileType
, interfaces
);
355 static HRESULT WINAPI
fwpolicy2_put_ExcludedInterfaces(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT interfaces
)
357 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
358 FIXME("%p %d\n", This
, profileType
);
362 static HRESULT WINAPI
fwpolicy2_get_BlockAllInboundTraffic(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT_BOOL
*block
)
364 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
366 FIXME("%p %d %p\n", This
, profileType
, block
);
370 static HRESULT WINAPI
fwpolicy2_put_BlockAllInboundTraffic(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT_BOOL block
)
372 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
374 FIXME("%p %d %d\n", This
, profileType
, block
);
378 static HRESULT WINAPI
fwpolicy2_get_NotificationsDisabled(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT_BOOL
*disabled
)
380 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
382 FIXME("%p %d %p\n", This
, profileType
, disabled
);
386 static HRESULT WINAPI
fwpolicy2_put_NotificationsDisabled(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT_BOOL disabled
)
388 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
390 FIXME("%p %d %d\n", This
, profileType
, disabled
);
394 static HRESULT WINAPI
fwpolicy2_get_UnicastResponsesToMulticastBroadcastDisabled(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT_BOOL
*disabled
)
396 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
398 FIXME("%p %d %p\n", This
, profileType
, disabled
);
402 static HRESULT WINAPI
fwpolicy2_put_UnicastResponsesToMulticastBroadcastDisabled(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, VARIANT_BOOL disabled
)
404 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
406 FIXME("%p %d %d\n", This
, profileType
, disabled
);
410 static HRESULT WINAPI
fwpolicy2_get_Rules(INetFwPolicy2
*iface
, INetFwRules
**rules
)
412 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
414 FIXME("%p %p\n", This
, rules
);
418 static HRESULT WINAPI
fwpolicy2_get_ServiceRestriction(INetFwPolicy2
*iface
, INetFwServiceRestriction
**ServiceRestriction
)
420 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
422 FIXME("%p %p\n", This
, ServiceRestriction
);
426 static HRESULT WINAPI
fwpolicy2_EnableRuleGroup(INetFwPolicy2
*iface
, LONG bitmask
, BSTR group
, VARIANT_BOOL enable
)
428 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
430 FIXME("%p %d %s %d\n", This
, bitmask
, debugstr_w(group
), enable
);
434 static HRESULT WINAPI
fwpolicy2_IsRuleGroupEnabled(INetFwPolicy2
*iface
, LONG bitmask
, BSTR group
, VARIANT_BOOL
*enabled
)
436 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
438 FIXME("%p %d %s %p\n", This
, bitmask
, debugstr_w(group
), enabled
);
442 static HRESULT WINAPI
fwpolicy2_RestoreLocalFirewallDefaults(INetFwPolicy2
*iface
)
444 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
450 static HRESULT WINAPI
fwpolicy2_get_DefaultInboundAction(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, NET_FW_ACTION
*action
)
452 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
454 FIXME("%p %d %p\n", This
, profileType
, action
);
458 static HRESULT WINAPI
fwpolicy2_put_DefaultInboundAction(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, NET_FW_ACTION action
)
460 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
462 FIXME("%p %d %d\n", This
, profileType
, action
);
466 static HRESULT WINAPI
fwpolicy2_get_DefaultOutboundAction(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, NET_FW_ACTION
*action
)
468 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
470 FIXME("%p %d %p\n", This
, profileType
, action
);
474 static HRESULT WINAPI
fwpolicy2_put_DefaultOutboundAction(INetFwPolicy2
*iface
, NET_FW_PROFILE_TYPE2 profileType
, NET_FW_ACTION action
)
476 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
478 FIXME("%p %d %d\n", This
, profileType
, action
);
482 static HRESULT WINAPI
fwpolicy2_get_IsRuleGroupCurrentlyEnabled(INetFwPolicy2
*iface
, BSTR group
, VARIANT_BOOL
*enabled
)
484 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
486 FIXME("%p %s %p\n", This
, debugstr_w(group
), enabled
);
490 static HRESULT WINAPI
fwpolicy2_get_LocalPolicyModifyState(INetFwPolicy2
*iface
, NET_FW_MODIFY_STATE
*modifyState
)
492 fw_policy2
*This
= impl_from_INetFwPolicy2( iface
);
494 FIXME("%p %p\n", This
, modifyState
);
498 static const struct INetFwPolicy2Vtbl fw_policy2_vtbl
=
500 fwpolicy2_QueryInterface
,
503 fwpolicy2_GetTypeInfoCount
,
504 fwpolicy2_GetTypeInfo
,
505 fwpolicy2_GetIDsOfNames
,
507 fwpolicy2_get_CurrentProfileTypes
,
508 fwpolicy2_get_FirewallEnabled
,
509 fwpolicy2_put_FirewallEnabled
,
510 fwpolicy2_get_ExcludedInterfaces
,
511 fwpolicy2_put_ExcludedInterfaces
,
512 fwpolicy2_get_BlockAllInboundTraffic
,
513 fwpolicy2_put_BlockAllInboundTraffic
,
514 fwpolicy2_get_NotificationsDisabled
,
515 fwpolicy2_put_NotificationsDisabled
,
516 fwpolicy2_get_UnicastResponsesToMulticastBroadcastDisabled
,
517 fwpolicy2_put_UnicastResponsesToMulticastBroadcastDisabled
,
519 fwpolicy2_get_ServiceRestriction
,
520 fwpolicy2_EnableRuleGroup
,
521 fwpolicy2_IsRuleGroupEnabled
,
522 fwpolicy2_RestoreLocalFirewallDefaults
,
523 fwpolicy2_get_DefaultInboundAction
,
524 fwpolicy2_put_DefaultInboundAction
,
525 fwpolicy2_get_DefaultOutboundAction
,
526 fwpolicy2_put_DefaultOutboundAction
,
527 fwpolicy2_get_IsRuleGroupCurrentlyEnabled
,
528 fwpolicy2_get_LocalPolicyModifyState
531 HRESULT
NetFwPolicy2_create( IUnknown
*outer
, void **obj
)
535 TRACE("(%p,%p)\n", outer
, obj
);
537 fp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*fp
) );
538 if (!fp
) return E_OUTOFMEMORY
;
540 fp
->INetFwPolicy2_iface
.lpVtbl
= &fw_policy2_vtbl
;
543 *obj
= &fp
->INetFwPolicy2_iface
;
545 TRACE("returning iface %p\n", *obj
);