[SHELL32_APITEST] SHChangeNotify: Improve coverity (#6798)
[reactos.git] / dll / win32 / pstorec / pstorec.c
1 /*
2 * Protected Storage (pstores)
3 *
4 * Copyright 2004 Mike McCormack for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include <stdarg.h>
22
23 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "initguid.h"
28 #include "ole2.h"
29 #include "pstore.h"
30
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(pstores);
34
35 typedef struct
36 {
37 IPStore IPStore_iface;
38 LONG ref;
39 } PStore_impl;
40
41 static inline PStore_impl *impl_from_IPStore(IPStore *iface)
42 {
43 return CONTAINING_RECORD(iface, PStore_impl, IPStore_iface);
44 }
45
46 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
47 {
48 TRACE("%p %x %p\n", hinst, fdwReason, fImpLoad);
49
50 switch (fdwReason)
51 {
52 case DLL_WINE_PREATTACH:
53 return FALSE; /* prefer native version */
54 case DLL_PROCESS_ATTACH:
55 DisableThreadLibraryCalls(hinst);
56 break;
57 }
58 return TRUE;
59 }
60
61 /**************************************************************************
62 * IPStore->QueryInterface
63 */
64 static HRESULT WINAPI PStore_fnQueryInterface(
65 IPStore* iface,
66 REFIID riid,
67 LPVOID *ppvObj)
68 {
69 PStore_impl *This = impl_from_IPStore(iface);
70
71 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObj);
72
73 *ppvObj = NULL;
74
75 if (IsEqualIID(riid, &IID_IPStore) || IsEqualIID(riid, &IID_IUnknown))
76 {
77 *ppvObj = &This->IPStore_iface;
78 }
79
80 if (*ppvObj)
81 {
82 IUnknown_AddRef((IUnknown*)(*ppvObj));
83 return S_OK;
84 }
85 TRACE("-- Interface: E_NOINTERFACE\n");
86 return E_NOINTERFACE;
87 }
88
89 /******************************************************************************
90 * IPStore->AddRef
91 */
92 static ULONG WINAPI PStore_fnAddRef(IPStore* iface)
93 {
94 PStore_impl *This = impl_from_IPStore(iface);
95
96 TRACE("%p %u\n", This, This->ref);
97
98 return InterlockedIncrement( &This->ref );
99 }
100
101 /******************************************************************************
102 * IPStore->Release
103 */
104 static ULONG WINAPI PStore_fnRelease(IPStore* iface)
105 {
106 PStore_impl *This = impl_from_IPStore(iface);
107 LONG ref;
108
109 TRACE("%p %u\n", This, This->ref);
110
111 ref = InterlockedDecrement( &This->ref );
112 if( !ref )
113 HeapFree( GetProcessHeap(), 0, This );
114
115 return ref;
116 }
117
118 /******************************************************************************
119 * IPStore->GetInfo
120 */
121 static HRESULT WINAPI PStore_fnGetInfo( IPStore* iface, PPST_PROVIDERINFO* ppProperties)
122 {
123 FIXME("\n");
124 return E_NOTIMPL;
125 }
126
127 /******************************************************************************
128 * IPStore->GetProvParam
129 */
130 static HRESULT WINAPI PStore_fnGetProvParam( IPStore* iface,
131 DWORD dwParam, DWORD* pcbData, BYTE** ppbData, DWORD dwFlags)
132 {
133 FIXME("\n");
134 return E_NOTIMPL;
135 }
136
137 /******************************************************************************
138 * IPStore->SetProvParam
139 */
140 static HRESULT WINAPI PStore_fnSetProvParam( IPStore* This,
141 DWORD dwParam, DWORD cbData, BYTE* pbData, DWORD* dwFlags)
142 {
143 FIXME("\n");
144 return E_NOTIMPL;
145 }
146
147 /******************************************************************************
148 * IPStore->CreateType
149 */
150 static HRESULT WINAPI PStore_fnCreateType( IPStore* This,
151 PST_KEY Key, const GUID* pType, PPST_TYPEINFO pInfo, DWORD dwFlags)
152 {
153 FIXME("%p %08x %s %p(%d,%s) %08x\n", This, Key, debugstr_guid(pType),
154 pInfo, pInfo->cbSize, debugstr_w(pInfo->szDisplayName), dwFlags);
155
156 return E_NOTIMPL;
157 }
158
159 /******************************************************************************
160 * IPStore->GetTypeInfo
161 */
162 static HRESULT WINAPI PStore_fnGetTypeInfo( IPStore* This,
163 PST_KEY Key, const GUID* pType, PPST_TYPEINFO** ppInfo, DWORD dwFlags)
164 {
165 FIXME("\n");
166 return E_NOTIMPL;
167 }
168
169 /******************************************************************************
170 * IPStore->DeleteType
171 */
172 static HRESULT WINAPI PStore_fnDeleteType( IPStore* This,
173 PST_KEY Key, const GUID* pType, DWORD dwFlags)
174 {
175 FIXME("%p %d %s %08x\n", This, Key, debugstr_guid(pType), dwFlags);
176 return E_NOTIMPL;
177 }
178
179 /******************************************************************************
180 * IPStore->CreateSubtype
181 */
182 static HRESULT WINAPI PStore_fnCreateSubtype( IPStore* This,
183 PST_KEY Key, const GUID* pType, const GUID* pSubtype,
184 PPST_TYPEINFO pInfo, PPST_ACCESSRULESET pRules, DWORD dwFlags)
185 {
186 FIXME("%p %08x %s %s %p %p %08x\n", This, Key, debugstr_guid(pType),
187 debugstr_guid(pSubtype), pInfo, pRules, dwFlags);
188 return E_NOTIMPL;
189 }
190
191 /******************************************************************************
192 * IPStore->GetSubtypeInfo
193 */
194 static HRESULT WINAPI PStore_fnGetSubtypeInfo( IPStore* This,
195 PST_KEY Key, const GUID* pType, const GUID* pSubtype,
196 PPST_TYPEINFO** ppInfo, DWORD dwFlags)
197 {
198 FIXME("\n");
199 return E_NOTIMPL;
200 }
201
202 /******************************************************************************
203 * IPStore->DeleteSubtype
204 */
205 static HRESULT WINAPI PStore_fnDeleteSubtype( IPStore* This,
206 PST_KEY Key, const GUID* pType, const GUID* pSubtype, DWORD dwFlags)
207 {
208 FIXME("%p %u %s %s %08x\n", This, Key,
209 debugstr_guid(pType), debugstr_guid(pSubtype), dwFlags);
210 return E_NOTIMPL;
211 }
212
213 /******************************************************************************
214 * IPStore->ReadAccessRuleset
215 */
216 static HRESULT WINAPI PStore_fnReadAccessRuleset( IPStore* This,
217 PST_KEY Key, const GUID* pType, const GUID* pSubtype, PPST_TYPEINFO pInfo,
218 PPST_ACCESSRULESET** ppRules, DWORD dwFlags)
219 {
220 FIXME("\n");
221 return E_NOTIMPL;
222 }
223
224 /******************************************************************************
225 * IPStore->WriteAccessRuleSet
226 */
227 static HRESULT WINAPI PStore_fnWriteAccessRuleset( IPStore* This,
228 PST_KEY Key, const GUID* pType, const GUID* pSubtype,
229 PPST_TYPEINFO pInfo, PPST_ACCESSRULESET pRules, DWORD dwFlags)
230 {
231 FIXME("\n");
232 return E_NOTIMPL;
233 }
234
235 /******************************************************************************
236 * IPStore->EnumTypes
237 */
238 static HRESULT WINAPI PStore_fnEnumTypes( IPStore* This, PST_KEY Key,
239 DWORD dwFlags, IEnumPStoreTypes** ppenum)
240 {
241 FIXME("\n");
242 return E_NOTIMPL;
243 }
244
245 /******************************************************************************
246 * IPStore->EnumSubtypes
247 */
248 static HRESULT WINAPI PStore_fnEnumSubtypes( IPStore* This, PST_KEY Key,
249 const GUID* pType, DWORD dwFlags, IEnumPStoreTypes** ppenum)
250 {
251 FIXME("\n");
252 return E_NOTIMPL;
253 }
254
255 /******************************************************************************
256 * IPStore->DeleteItem
257 */
258 static HRESULT WINAPI PStore_fnDeleteItem( IPStore* This, PST_KEY Key,
259 const GUID* pItemType, const GUID* pItemSubType, LPCWSTR szItemName,
260 PPST_PROMPTINFO pPromptInfo, DWORD dwFlags)
261 {
262 FIXME("\n");
263 return E_NOTIMPL;
264 }
265
266 /******************************************************************************
267 * IPStore->ReadItem
268 */
269 static HRESULT WINAPI PStore_fnReadItem( IPStore* This, PST_KEY Key,
270 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR szItemName,
271 DWORD *cbData, BYTE** pbData, PPST_PROMPTINFO pPromptInfo, DWORD dwFlags)
272 {
273 FIXME("%p %08x %s %s %s %p %p %p %08x\n", This, Key,
274 debugstr_guid(pItemType), debugstr_guid(pItemSubtype),
275 debugstr_w(szItemName), cbData, pbData, pPromptInfo, dwFlags);
276 return E_NOTIMPL;
277 }
278
279 /******************************************************************************
280 * IPStore->WriteItem
281 */
282 static HRESULT WINAPI PStore_fnWriteItem( IPStore* This, PST_KEY Key,
283 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR szItemName,
284 DWORD cbData, BYTE* ppbData, PPST_PROMPTINFO pPromptInfo,
285 DWORD dwDefaultConfirmationStyle, DWORD dwFlags)
286 {
287 FIXME("%p %08x %s %s %s %d %p %p %08x\n", This, Key,
288 debugstr_guid(pItemType), debugstr_guid(pItemSubtype),
289 debugstr_w(szItemName), cbData, ppbData, pPromptInfo, dwFlags);
290 return E_NOTIMPL;
291 }
292
293 /******************************************************************************
294 * IPStore->OpenItem
295 */
296 static HRESULT WINAPI PStore_fnOpenItem( IPStore* This, PST_KEY Key,
297 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR szItemName,
298 PST_ACCESSMODE ModeFlags, PPST_PROMPTINFO pPromptInfo, DWORD dwFlags )
299 {
300 FIXME("(%p,%08x,%s,%s,%s,%08x,%p,%08x) stub\n", This, Key, debugstr_guid(pItemType),
301 debugstr_guid(pItemSubtype), debugstr_w(szItemName), ModeFlags, pPromptInfo, dwFlags);
302 return E_NOTIMPL;
303 }
304
305 /******************************************************************************
306 * IPStore->CloseItem
307 */
308 static HRESULT WINAPI PStore_fnCloseItem( IPStore* This, PST_KEY Key,
309 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR* szItemName,
310 DWORD dwFlags)
311 {
312 FIXME("\n");
313 return E_NOTIMPL;
314 }
315
316 /******************************************************************************
317 * IPStore->EnumItems
318 */
319 static HRESULT WINAPI PStore_fnEnumItems( IPStore* This, PST_KEY Key,
320 const GUID* pItemType, const GUID* pItemSubtype, DWORD dwFlags,
321 IEnumPStoreItems** ppenum)
322 {
323 FIXME("\n");
324 return E_NOTIMPL;
325 }
326
327
328 static const IPStoreVtbl pstores_vtbl =
329 {
330 PStore_fnQueryInterface,
331 PStore_fnAddRef,
332 PStore_fnRelease,
333 PStore_fnGetInfo,
334 PStore_fnGetProvParam,
335 PStore_fnSetProvParam,
336 PStore_fnCreateType,
337 PStore_fnGetTypeInfo,
338 PStore_fnDeleteType,
339 PStore_fnCreateSubtype,
340 PStore_fnGetSubtypeInfo,
341 PStore_fnDeleteSubtype,
342 PStore_fnReadAccessRuleset,
343 PStore_fnWriteAccessRuleset,
344 PStore_fnEnumTypes,
345 PStore_fnEnumSubtypes,
346 PStore_fnDeleteItem,
347 PStore_fnReadItem,
348 PStore_fnWriteItem,
349 PStore_fnOpenItem,
350 PStore_fnCloseItem,
351 PStore_fnEnumItems
352 };
353
354 HRESULT WINAPI PStoreCreateInstance( IPStore** ppProvider,
355 PST_PROVIDERID* pProviderID, void* pReserved, DWORD dwFlags)
356 {
357 PStore_impl *ips;
358
359 TRACE("%p %s %p %08x\n", ppProvider, debugstr_guid(pProviderID), pReserved, dwFlags);
360
361 ips = HeapAlloc( GetProcessHeap(), 0, sizeof (PStore_impl) );
362 if( !ips )
363 return E_OUTOFMEMORY;
364
365 ips->IPStore_iface.lpVtbl = &pstores_vtbl;
366 ips->ref = 1;
367
368 *ppProvider = &ips->IPStore_iface;
369
370 return S_OK;
371 }
372
373 HRESULT WINAPI DllRegisterServer(void)
374 {
375 FIXME("\n");
376 return S_OK;
377 }
378
379 HRESULT WINAPI DllUnregisterServer(void)
380 {
381 FIXME("\n");
382 return S_OK;
383 }
384
385 /***********************************************************************
386 * DllGetClassObject (PSTOREC.@)
387 */
388 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
389 {
390 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
391 return CLASS_E_CLASSNOTAVAILABLE;
392 }
393
394 HRESULT WINAPI DllCanUnloadNow(void)
395 {
396 return S_FALSE;
397 }