ReactOS 0.4.16-dev-1946-g52006dd
netcfgclass_iface.c
Go to the documentation of this file.
1#include "precomp.h"
2
3typedef struct
4{
5 const INetCfgClass *lpVtbl;
6 const INetCfgClassSetup *lpVtblSetup;
9 INetCfg *pNetCfg;
11
13{
14 return (INetCfgClassImpl*)((char *)iface - FIELD_OFFSET(INetCfgClassImpl, lpVtblSetup));
15}
16
17/***************************************************************
18 * INetCfgClassSetup
19 */
20
24 INetCfgClassSetup *iface,
25 REFIID iid,
26 LPVOID *ppvObj)
27{
29 return INetCfgClass_QueryInterface((INetCfgClass*)This, iid, ppvObj);
30}
31
32
36 INetCfgClassSetup *iface)
37{
39 return INetCfgClass_AddRef((INetCfgClass*)This);
40}
41
45 INetCfgClassSetup *iface)
46{
48 return INetCfgClass_Release((INetCfgClass*)This);
49}
50
54 _In_ INetCfgClassSetup *iface,
56 _In_opt_ OBO_TOKEN *pOboToken,
57 _Out_opt_ INetCfgComponent **ppnccItem)
58{
59// INetCfgClassImpl *This = impl_from_INetCfgClassSetup(iface);
60 return S_OK;
61}
62
66 _In_ INetCfgClassSetup *iface,
67 _In_ LPCWSTR pszwComponentId,
68 _In_opt_ OBO_TOKEN *pOboToken,
69 _In_opt_ DWORD dwSetupFlags,
70 _In_opt_ DWORD dwUpgradeFromBuildNo,
71 _In_opt_ LPCWSTR pszwAnswerFile,
72 _In_opt_ LPCWSTR pszwAnswerSections,
73 _Out_opt_ INetCfgComponent **ppComponent)
74{
75// INetCfgClassImpl *This = impl_from_INetCfgClassSetup(iface);
76
77 if (ppComponent)
78 *ppComponent = NULL;
79
80 InstallNetworkComponent(pszwComponentId);
81
82 return S_OK;
83}
84
85
89 _In_ INetCfgClassSetup *iface,
90 _In_ INetCfgComponent *pComponent,
91 _In_opt_ OBO_TOKEN *pOboToken,
92 _Out_opt_ LPWSTR *pmszwRefs)
93{
94// INetCfgClassImpl *This = impl_from_INetCfgClassSetup(iface);
95
96 return S_OK;
97}
98
99static const INetCfgClassSetupVtbl vt_NetCfgClassSetup =
100{
107};
108
109/***************************************************************
110 * INetCfgClass
111 */
112
114WINAPI
116 INetCfgClass *iface,
117 REFIID iid,
118 LPVOID *ppvObj)
119{
121 *ppvObj = NULL;
122
123 if (IsEqualIID (iid, &IID_IUnknown) ||
125 {
126 *ppvObj = This;
127 INetCfgClass_AddRef(iface);
128 return S_OK;
129 }
130 else if (IsEqualIID (iid, &IID_INetCfgClassSetup))
131 {
132 *ppvObj = (LPVOID)&This->lpVtblSetup;
133 INetCfgClass_AddRef(iface);
134 return S_OK;
135 }
136
137 return E_NOINTERFACE;
138}
139
140ULONG
141WINAPI
143 INetCfgClass *iface)
144{
146 ULONG refCount = InterlockedIncrement(&This->ref);
147
148 return refCount;
149}
150
151ULONG
152WINAPI
154 INetCfgClass *iface)
155{
157 ULONG refCount = InterlockedDecrement(&This->ref);
158
159 if (!refCount)
160 {
162 }
163 return refCount;
164}
165
167WINAPI
169 INetCfgClass *iface,
170 LPCWSTR pszwComponentId,
171 INetCfgComponent **pComponent)
172{
174 NetCfgComponentItem *pHead;
175
176 if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NET))
177 pHead = ((INetCfgImpl*)(This->pNetCfg))->pNet;
178 else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETTRANS))
179 pHead = ((INetCfgImpl*)(This->pNetCfg))->pProtocol;
180 else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETSERVICE))
181 pHead = ((INetCfgImpl*)(This->pNetCfg))->pService;
182 else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETCLIENT))
183 pHead = ((INetCfgImpl*)(This->pNetCfg))->pClient;
184 else
185 return E_NOINTERFACE;
186
187 while (pHead)
188 {
189 if (!_wcsicmp(pHead->szId, pszwComponentId))
190 {
191 return INetCfgComponent_Constructor(NULL, &IID_INetCfgComponent, (LPVOID*)pComponent, pHead, This->pNetCfg);
192 }
193 pHead = pHead->pNext;
194 }
195
196 return S_FALSE;
197}
198
200WINAPI
202 INetCfgClass *iface,
203 IEnumNetCfgComponent **ppenumComponent)
204{
206 NetCfgComponentItem *pHead;
207
208 if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NET))
209 pHead = ((INetCfgImpl*)(This->pNetCfg))->pNet;
210 else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETTRANS))
211 pHead = ((INetCfgImpl*)(This->pNetCfg))->pProtocol;
212 else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETSERVICE))
213 pHead = ((INetCfgImpl*)(This->pNetCfg))->pService;
214 else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETCLIENT))
215 pHead = ((INetCfgImpl*)(This->pNetCfg))->pClient;
216 else
217 return E_NOINTERFACE;
218
219 return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, pHead, This->pNetCfg);
220}
221
222static const INetCfgClassVtbl vt_NetCfgClass =
223{
229};
230
232WINAPI
234 IUnknown *pUnkOuter,
235 REFIID riid,
236 LPVOID *ppv,
237 const GUID *pguidClass,
238 INetCfg *pNetCfg)
239{
241
242 if (!ppv)
243 return E_POINTER;
244
246 if (!This)
247 return E_OUTOFMEMORY;
248
249 This->ref = 1;
250 This->lpVtbl = (const INetCfgClass*)&vt_NetCfgClass;
251 This->lpVtblSetup = (const INetCfgClassSetup*)&vt_NetCfgClassSetup;
252
253 memcpy(&This->ClassGuid, pguidClass, sizeof(GUID));
254 This->pNetCfg = pNetCfg;
255
256 if (!SUCCEEDED(INetCfgClass_QueryInterface((INetCfgClass*)This, riid, ppv)))
257 {
258 INetCfgClass_Release((INetCfgClass*)This);
259 return E_NOINTERFACE;
260 }
261
262 INetCfgClass_Release((INetCfgClass*)This);
263 return S_OK;
264}
#define __inline
Definition: _wctype.cpp:15
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
const GUID IID_IUnknown
static HWND hwndParent
Definition: cryptui.c:300
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT WINAPI INetCfgComponent_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv, NetCfgComponentItem *pItem, INetCfg *pNCfg)
HRESULT WINAPI IEnumNetCfgComponent_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv, NetCfgComponentItem *pItem, INetCfg *pNCfg)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG WINAPI INetCfgClass_fnAddRef(INetCfgClass *iface)
ULONG WINAPI INetCfgClassSetup_fnRelease(INetCfgClassSetup *iface)
static __inline LPINetCfgClassImpl impl_from_INetCfgClassSetup(INetCfgClassSetup *iface)
static const INetCfgClassSetupVtbl vt_NetCfgClassSetup
HRESULT WINAPI INetCfgClass_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv, const GUID *pguidClass, INetCfg *pNetCfg)
HRESULT WINAPI INetCfgClassSetup_fnDeInstall(_In_ INetCfgClassSetup *iface, _In_ INetCfgComponent *pComponent, _In_opt_ OBO_TOKEN *pOboToken, _Out_opt_ LPWSTR *pmszwRefs)
struct INetCfgClassImpl * LPINetCfgClassImpl
HRESULT WINAPI INetCfgClassSetup_fnInstall(_In_ INetCfgClassSetup *iface, _In_ LPCWSTR pszwComponentId, _In_opt_ OBO_TOKEN *pOboToken, _In_opt_ DWORD dwSetupFlags, _In_opt_ DWORD dwUpgradeFromBuildNo, _In_opt_ LPCWSTR pszwAnswerFile, _In_opt_ LPCWSTR pszwAnswerSections, _Out_opt_ INetCfgComponent **ppComponent)
HRESULT WINAPI INetCfgClass_fnFindComponent(INetCfgClass *iface, LPCWSTR pszwComponentId, INetCfgComponent **pComponent)
HRESULT WINAPI INetCfgClassSetup_fnSelectAndInstall(_In_ INetCfgClassSetup *iface, _In_ HWND hwndParent, _In_opt_ OBO_TOKEN *pOboToken, _Out_opt_ INetCfgComponent **ppnccItem)
HRESULT WINAPI INetCfgClass_fnEnumComponents(INetCfgClass *iface, IEnumNetCfgComponent **ppenumComponent)
static const INetCfgClassVtbl vt_NetCfgClass
ULONG WINAPI INetCfgClass_fnRelease(INetCfgClass *iface)
HRESULT WINAPI INetCfgClassSetup_fnQueryInterface(INetCfgClassSetup *iface, REFIID iid, LPVOID *ppvObj)
HRESULT WINAPI INetCfgClass_fnQueryInterface(INetCfgClass *iface, REFIID iid, LPVOID *ppvObj)
ULONG WINAPI INetCfgClassSetup_fnAddRef(INetCfgClassSetup *iface)
EXTERN_C const IID IID_INetCfgClassSetup
Definition: netcfgx.h:361
EXTERN_C const IID IID_INetCfgClass
Definition: netcfgx.h:317
EXTERN_C const IID IID_INetCfgComponent
Definition: netcfgx.h:77
#define INetCfgClass_Release(p)
Definition: netcfgx.h:335
#define INetCfgClass_QueryInterface(p, a, b)
Definition: netcfgx.h:333
#define INetCfgClass_AddRef(p)
Definition: netcfgx.h:334
EXTERN_C const IID IID_IEnumNetCfgComponent
Definition: netcfgx.h:266
#define _Out_opt_
Definition: no_sal2.h:214
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define LPVOID
Definition: nt_native.h:45
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static HRESULT InstallNetworkComponent(LPWSTR pszComponentName, const GUID *pClassGuid)
Definition: setup.cpp:54
const INetCfgClass * lpVtbl
const INetCfgClassSetup * lpVtblSetup
struct tagNetCfgComponentItem * pNext
Definition: precomp.h:54
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_POINTER
Definition: winerror.h:3480
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WCHAR * LPWSTR
Definition: xmlstorage.h:184