msvcrt: Stop at trylevel for ControlPc on target frame for non-consolidate unwinds.
[wine.git] / dlls / hnetcfg / apps.c
blob2b8d78c6f4c6bdd3f36d0fadb8bd8d6857005208
1 /*
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
19 #include "config.h"
20 #include <stdarg.h>
21 #include <stdio.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "netfw.h"
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_app
39 INetFwAuthorizedApplication INetFwAuthorizedApplication_iface;
40 LONG refs;
41 } fw_app;
43 static inline fw_app *impl_from_INetFwAuthorizedApplication( INetFwAuthorizedApplication *iface )
45 return CONTAINING_RECORD(iface, fw_app, INetFwAuthorizedApplication_iface);
48 static ULONG WINAPI fw_app_AddRef(
49 INetFwAuthorizedApplication *iface )
51 fw_app *fw_app = impl_from_INetFwAuthorizedApplication( iface );
52 return InterlockedIncrement( &fw_app->refs );
55 static ULONG WINAPI fw_app_Release(
56 INetFwAuthorizedApplication *iface )
58 fw_app *fw_app = impl_from_INetFwAuthorizedApplication( iface );
59 LONG refs = InterlockedDecrement( &fw_app->refs );
60 if (!refs)
62 TRACE("destroying %p\n", fw_app);
63 HeapFree( GetProcessHeap(), 0, fw_app );
65 return refs;
68 static HRESULT WINAPI fw_app_QueryInterface(
69 INetFwAuthorizedApplication *iface,
70 REFIID riid,
71 void **ppvObject )
73 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
75 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
77 if ( IsEqualGUID( riid, &IID_INetFwAuthorizedApplication ) ||
78 IsEqualGUID( riid, &IID_IDispatch ) ||
79 IsEqualGUID( riid, &IID_IUnknown ) )
81 *ppvObject = iface;
83 else
85 FIXME("interface %s not implemented\n", debugstr_guid(riid));
86 return E_NOINTERFACE;
88 INetFwAuthorizedApplication_AddRef( iface );
89 return S_OK;
92 static HRESULT WINAPI fw_app_GetTypeInfoCount(
93 INetFwAuthorizedApplication *iface,
94 UINT *pctinfo )
96 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
98 TRACE("%p %p\n", This, pctinfo);
99 *pctinfo = 1;
100 return S_OK;
103 static ITypeLib *typelib;
104 static ITypeInfo *typeinfo[last_tid];
106 static REFIID tid_id[] =
108 &IID_INetFwAuthorizedApplication,
109 &IID_INetFwAuthorizedApplications,
110 &IID_INetFwMgr,
111 &IID_INetFwOpenPort,
112 &IID_INetFwOpenPorts,
113 &IID_INetFwPolicy,
114 &IID_INetFwPolicy2,
115 &IID_INetFwProfile
118 HRESULT get_typeinfo( enum type_id tid, ITypeInfo **ret )
120 HRESULT hr;
122 if (!typelib)
124 ITypeLib *lib;
126 hr = LoadRegTypeLib( &LIBID_NetFwPublicTypeLib, 1, 0, LOCALE_SYSTEM_DEFAULT, &lib );
127 if (FAILED(hr))
129 ERR("LoadRegTypeLib failed: %08x\n", hr);
130 return hr;
132 if (InterlockedCompareExchangePointer( (void **)&typelib, lib, NULL ))
133 ITypeLib_Release( lib );
135 if (!typeinfo[tid])
137 ITypeInfo *info;
139 hr = ITypeLib_GetTypeInfoOfGuid( typelib, tid_id[tid], &info );
140 if (FAILED(hr))
142 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_id[tid]), hr);
143 return hr;
145 if (InterlockedCompareExchangePointer( (void **)(typeinfo + tid), info, NULL ))
146 ITypeInfo_Release( info );
148 *ret = typeinfo[tid];
149 ITypeInfo_AddRef(typeinfo[tid]);
150 return S_OK;
153 void release_typelib(void)
155 unsigned i;
157 for (i = 0; i < sizeof(typeinfo)/sizeof(*typeinfo); i++)
158 if (typeinfo[i])
159 ITypeInfo_Release(typeinfo[i]);
161 if (typelib)
162 ITypeLib_Release(typelib);
165 static HRESULT WINAPI fw_app_GetTypeInfo(
166 INetFwAuthorizedApplication *iface,
167 UINT iTInfo,
168 LCID lcid,
169 ITypeInfo **ppTInfo )
171 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
173 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
174 return get_typeinfo( INetFwAuthorizedApplication_tid, ppTInfo );
177 static HRESULT WINAPI fw_app_GetIDsOfNames(
178 INetFwAuthorizedApplication *iface,
179 REFIID riid,
180 LPOLESTR *rgszNames,
181 UINT cNames,
182 LCID lcid,
183 DISPID *rgDispId )
185 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
186 ITypeInfo *typeinfo;
187 HRESULT hr;
189 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
191 hr = get_typeinfo( INetFwAuthorizedApplication_tid, &typeinfo );
192 if (SUCCEEDED(hr))
194 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
195 ITypeInfo_Release( typeinfo );
197 return hr;
200 static HRESULT WINAPI fw_app_Invoke(
201 INetFwAuthorizedApplication *iface,
202 DISPID dispIdMember,
203 REFIID riid,
204 LCID lcid,
205 WORD wFlags,
206 DISPPARAMS *pDispParams,
207 VARIANT *pVarResult,
208 EXCEPINFO *pExcepInfo,
209 UINT *puArgErr )
211 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
212 ITypeInfo *typeinfo;
213 HRESULT hr;
215 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
216 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
218 hr = get_typeinfo( INetFwAuthorizedApplication_tid, &typeinfo );
219 if (SUCCEEDED(hr))
221 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwAuthorizedApplication_iface, dispIdMember,
222 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
223 ITypeInfo_Release( typeinfo );
225 return hr;
228 static HRESULT WINAPI fw_app_get_Name(
229 INetFwAuthorizedApplication *iface,
230 BSTR *name )
232 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
234 FIXME("%p, %p\n", This, name);
235 return E_NOTIMPL;
238 static HRESULT WINAPI fw_app_put_Name(
239 INetFwAuthorizedApplication *iface,
240 BSTR name )
242 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
244 FIXME("%p, %s\n", This, debugstr_w(name));
245 return S_OK;
248 static HRESULT WINAPI fw_app_get_ProcessImageFileName(
249 INetFwAuthorizedApplication *iface,
250 BSTR *imageFileName )
252 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
254 FIXME("%p, %p\n", This, imageFileName);
255 return E_NOTIMPL;
258 static HRESULT WINAPI fw_app_put_ProcessImageFileName(
259 INetFwAuthorizedApplication *iface,
260 BSTR imageFileName )
262 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
264 FIXME("%p, %s\n", This, debugstr_w(imageFileName));
265 return S_OK;
268 static HRESULT WINAPI fw_app_get_IpVersion(
269 INetFwAuthorizedApplication *iface,
270 NET_FW_IP_VERSION *ipVersion )
272 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
274 TRACE("%p, %p\n", This, ipVersion);
276 if (!ipVersion)
277 return E_POINTER;
278 *ipVersion = NET_FW_IP_VERSION_ANY;
279 return S_OK;
282 static HRESULT WINAPI fw_app_put_IpVersion(
283 INetFwAuthorizedApplication *iface,
284 NET_FW_IP_VERSION ipVersion )
286 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
288 TRACE("%p, %u\n", This, ipVersion);
289 return S_OK;
292 static HRESULT WINAPI fw_app_get_Scope(
293 INetFwAuthorizedApplication *iface,
294 NET_FW_SCOPE *scope )
296 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
298 FIXME("%p, %p\n", This, scope);
299 return E_NOTIMPL;
302 static HRESULT WINAPI fw_app_put_Scope(
303 INetFwAuthorizedApplication *iface,
304 NET_FW_SCOPE scope )
306 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
308 FIXME("%p, %u\n", This, scope);
309 return S_OK;
312 static HRESULT WINAPI fw_app_get_RemoteAddresses(
313 INetFwAuthorizedApplication *iface,
314 BSTR *remoteAddrs )
316 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
318 FIXME("%p, %p\n", This, remoteAddrs);
319 return E_NOTIMPL;
322 static HRESULT WINAPI fw_app_put_RemoteAddresses(
323 INetFwAuthorizedApplication *iface,
324 BSTR remoteAddrs )
326 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
328 FIXME("%p, %s\n", This, debugstr_w(remoteAddrs));
329 return E_NOTIMPL;
332 static HRESULT WINAPI fw_app_get_Enabled(
333 INetFwAuthorizedApplication *iface,
334 VARIANT_BOOL *enabled )
336 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
338 FIXME("%p, %p\n", This, enabled);
340 *enabled = VARIANT_FALSE;
341 return S_OK;
344 static HRESULT WINAPI fw_app_put_Enabled(
345 INetFwAuthorizedApplication *iface,
346 VARIANT_BOOL enabled )
348 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
350 FIXME("%p, %d\n", This, enabled);
351 return S_OK;
354 static const struct INetFwAuthorizedApplicationVtbl fw_app_vtbl =
356 fw_app_QueryInterface,
357 fw_app_AddRef,
358 fw_app_Release,
359 fw_app_GetTypeInfoCount,
360 fw_app_GetTypeInfo,
361 fw_app_GetIDsOfNames,
362 fw_app_Invoke,
363 fw_app_get_Name,
364 fw_app_put_Name,
365 fw_app_get_ProcessImageFileName,
366 fw_app_put_ProcessImageFileName,
367 fw_app_get_IpVersion,
368 fw_app_put_IpVersion,
369 fw_app_get_Scope,
370 fw_app_put_Scope,
371 fw_app_get_RemoteAddresses,
372 fw_app_put_RemoteAddresses,
373 fw_app_get_Enabled,
374 fw_app_put_Enabled
377 HRESULT NetFwAuthorizedApplication_create( IUnknown *pUnkOuter, LPVOID *ppObj )
379 fw_app *fa;
381 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
383 fa = HeapAlloc( GetProcessHeap(), 0, sizeof(*fa) );
384 if (!fa) return E_OUTOFMEMORY;
386 fa->INetFwAuthorizedApplication_iface.lpVtbl = &fw_app_vtbl;
387 fa->refs = 1;
389 *ppObj = &fa->INetFwAuthorizedApplication_iface;
391 TRACE("returning iface %p\n", *ppObj);
392 return S_OK;
394 typedef struct fw_apps
396 INetFwAuthorizedApplications INetFwAuthorizedApplications_iface;
397 LONG refs;
398 } fw_apps;
400 static inline fw_apps *impl_from_INetFwAuthorizedApplications( INetFwAuthorizedApplications *iface )
402 return CONTAINING_RECORD(iface, fw_apps, INetFwAuthorizedApplications_iface);
405 static ULONG WINAPI fw_apps_AddRef(
406 INetFwAuthorizedApplications *iface )
408 fw_apps *fw_apps = impl_from_INetFwAuthorizedApplications( iface );
409 return InterlockedIncrement( &fw_apps->refs );
412 static ULONG WINAPI fw_apps_Release(
413 INetFwAuthorizedApplications *iface )
415 fw_apps *fw_apps = impl_from_INetFwAuthorizedApplications( iface );
416 LONG refs = InterlockedDecrement( &fw_apps->refs );
417 if (!refs)
419 TRACE("destroying %p\n", fw_apps);
420 HeapFree( GetProcessHeap(), 0, fw_apps );
422 return refs;
425 static HRESULT WINAPI fw_apps_QueryInterface(
426 INetFwAuthorizedApplications *iface,
427 REFIID riid,
428 void **ppvObject )
430 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
432 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
434 if ( IsEqualGUID( riid, &IID_INetFwAuthorizedApplications ) ||
435 IsEqualGUID( riid, &IID_IDispatch ) ||
436 IsEqualGUID( riid, &IID_IUnknown ) )
438 *ppvObject = iface;
440 else
442 FIXME("interface %s not implemented\n", debugstr_guid(riid));
443 return E_NOINTERFACE;
445 INetFwAuthorizedApplications_AddRef( iface );
446 return S_OK;
449 static HRESULT WINAPI fw_apps_GetTypeInfoCount(
450 INetFwAuthorizedApplications *iface,
451 UINT *pctinfo )
453 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
455 FIXME("%p %p\n", This, pctinfo);
456 return E_NOTIMPL;
459 static HRESULT WINAPI fw_apps_GetTypeInfo(
460 INetFwAuthorizedApplications *iface,
461 UINT iTInfo,
462 LCID lcid,
463 ITypeInfo **ppTInfo )
465 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
467 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
468 return get_typeinfo( INetFwAuthorizedApplications_tid, ppTInfo );
471 static HRESULT WINAPI fw_apps_GetIDsOfNames(
472 INetFwAuthorizedApplications *iface,
473 REFIID riid,
474 LPOLESTR *rgszNames,
475 UINT cNames,
476 LCID lcid,
477 DISPID *rgDispId )
479 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
480 ITypeInfo *typeinfo;
481 HRESULT hr;
483 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
485 hr = get_typeinfo( INetFwAuthorizedApplications_tid, &typeinfo );
486 if (SUCCEEDED(hr))
488 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
489 ITypeInfo_Release( typeinfo );
491 return hr;
494 static HRESULT WINAPI fw_apps_Invoke(
495 INetFwAuthorizedApplications *iface,
496 DISPID dispIdMember,
497 REFIID riid,
498 LCID lcid,
499 WORD wFlags,
500 DISPPARAMS *pDispParams,
501 VARIANT *pVarResult,
502 EXCEPINFO *pExcepInfo,
503 UINT *puArgErr )
505 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
506 ITypeInfo *typeinfo;
507 HRESULT hr;
509 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
510 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
512 hr = get_typeinfo( INetFwAuthorizedApplications_tid, &typeinfo );
513 if (SUCCEEDED(hr))
515 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwAuthorizedApplications_iface, dispIdMember,
516 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
517 ITypeInfo_Release( typeinfo );
519 return hr;
522 static HRESULT WINAPI fw_apps_get_Count(
523 INetFwAuthorizedApplications *iface,
524 LONG *count )
526 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
528 FIXME("%p, %p\n", This, count);
529 return E_NOTIMPL;
532 static HRESULT WINAPI fw_apps_Add(
533 INetFwAuthorizedApplications *iface,
534 INetFwAuthorizedApplication *app )
536 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
538 FIXME("%p, %p\n", This, app);
539 return S_OK;
542 static HRESULT WINAPI fw_apps_Remove(
543 INetFwAuthorizedApplications *iface,
544 BSTR imageFileName )
546 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
548 FIXME("%p, %s\n", This, debugstr_w(imageFileName));
549 return S_OK;
552 static HRESULT WINAPI fw_apps_Item(
553 INetFwAuthorizedApplications *iface,
554 BSTR imageFileName,
555 INetFwAuthorizedApplication **app )
557 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
559 TRACE("%p, %s, %p\n", This, debugstr_w(imageFileName), app);
560 return NetFwAuthorizedApplication_create( NULL, (void **)app );
563 static HRESULT WINAPI fw_apps_get__NewEnum(
564 INetFwAuthorizedApplications *iface,
565 IUnknown **newEnum )
567 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
569 FIXME("%p, %p\n", This, newEnum);
570 return E_NOTIMPL;
573 static const struct INetFwAuthorizedApplicationsVtbl fw_apps_vtbl =
575 fw_apps_QueryInterface,
576 fw_apps_AddRef,
577 fw_apps_Release,
578 fw_apps_GetTypeInfoCount,
579 fw_apps_GetTypeInfo,
580 fw_apps_GetIDsOfNames,
581 fw_apps_Invoke,
582 fw_apps_get_Count,
583 fw_apps_Add,
584 fw_apps_Remove,
585 fw_apps_Item,
586 fw_apps_get__NewEnum
589 HRESULT NetFwAuthorizedApplications_create( IUnknown *pUnkOuter, LPVOID *ppObj )
591 fw_apps *fa;
593 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
595 fa = HeapAlloc( GetProcessHeap(), 0, sizeof(*fa) );
596 if (!fa) return E_OUTOFMEMORY;
598 fa->INetFwAuthorizedApplications_iface.lpVtbl = &fw_apps_vtbl;
599 fa->refs = 1;
601 *ppObj = &fa->INetFwAuthorizedApplications_iface;
603 TRACE("returning iface %p\n", *ppObj);
604 return S_OK;