Merge from amd64 branch:
[reactos.git] / reactos / 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 "ole2.h"
28 #include "pstore.h"
29
30 #include "wine/debug.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(pstores);
33
34 typedef struct
35 {
36 const IPStoreVtbl *lpVtbl;
37 LONG ref;
38 } PStore_impl;
39
40 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
41 {
42 TRACE("%p %x %p\n", hinst, fdwReason, fImpLoad);
43
44 switch (fdwReason)
45 {
46 case DLL_PROCESS_ATTACH:
47 DisableThreadLibraryCalls(hinst);
48 break;
49 case DLL_PROCESS_DETACH:
50 break;
51 }
52 return TRUE;
53 }
54
55 /**************************************************************************
56 * IPStore->QueryInterface
57 */
58 static HRESULT WINAPI PStore_fnQueryInterface(
59 IPStore* iface,
60 REFIID riid,
61 LPVOID *ppvObj)
62 {
63 PStore_impl *This = (PStore_impl *)iface;
64
65 TRACE("%p %s\n",This,debugstr_guid(riid));
66
67 *ppvObj = NULL;
68
69 if (IsEqualIID(riid, &IID_IUnknown))
70 {
71 *ppvObj = This;
72 }
73
74 if (*ppvObj)
75 {
76 IUnknown_AddRef((IUnknown*)(*ppvObj));
77 return S_OK;
78 }
79 TRACE("-- Interface: E_NOINTERFACE\n");
80 return E_NOINTERFACE;
81 }
82
83 /******************************************************************************
84 * IPStore->AddRef
85 */
86 static ULONG WINAPI PStore_fnAddRef(IPStore* iface)
87 {
88 PStore_impl *This = (PStore_impl *)iface;
89
90 TRACE("%p %u\n", This, This->ref);
91
92 return InterlockedIncrement( &This->ref );
93 }
94
95 /******************************************************************************
96 * IPStore->Release
97 */
98 static ULONG WINAPI PStore_fnRelease(IPStore* iface)
99 {
100 PStore_impl *This = (PStore_impl *)iface;
101 LONG ref;
102
103 TRACE("%p %u\n", This, This->ref);
104
105 ref = InterlockedDecrement( &This->ref );
106 if( !ref )
107 HeapFree( GetProcessHeap(), 0, This );
108
109 return ref;
110 }
111
112 /******************************************************************************
113 * IPStore->GetInfo
114 */
115 static HRESULT WINAPI PStore_fnGetInfo( IPStore* iface, PPST_PROVIDERINFO* ppProperties)
116 {
117 FIXME("\n");
118 return E_NOTIMPL;
119 }
120
121 /******************************************************************************
122 * IPStore->GetProvParam
123 */
124 static HRESULT WINAPI PStore_fnGetProvParam( IPStore* iface,
125 DWORD dwParam, DWORD* pcbData, BYTE** ppbData, DWORD dwFlags)
126 {
127 FIXME("\n");
128 return E_NOTIMPL;
129 }
130
131 /******************************************************************************
132 * IPStore->SetProvParam
133 */
134 static HRESULT WINAPI PStore_fnSetProvParam( IPStore* This,
135 DWORD dwParam, DWORD cbData, BYTE* pbData, DWORD* dwFlags)
136 {
137 FIXME("\n");
138 return E_NOTIMPL;
139 }
140
141 /******************************************************************************
142 * IPStore->CreateType
143 */
144 static HRESULT WINAPI PStore_fnCreateType( IPStore* This,
145 PST_KEY Key, const GUID* pType, PPST_TYPEINFO pInfo, DWORD dwFlags)
146 {
147 FIXME("%p %08x %s %p(%d,%s) %08x\n", This, Key, debugstr_guid(pType),
148 pInfo, pInfo->cbSize, debugstr_w(pInfo->szDisplayName), dwFlags);
149
150 return E_NOTIMPL;
151 }
152
153 /******************************************************************************
154 * IPStore->GetTypeInfo
155 */
156 static HRESULT WINAPI PStore_fnGetTypeInfo( IPStore* This,
157 PST_KEY Key, const GUID* pType, PPST_TYPEINFO** ppInfo, DWORD dwFlags)
158 {
159 FIXME("\n");
160 return E_NOTIMPL;
161 }
162
163 /******************************************************************************
164 * IPStore->DeleteType
165 */
166 static HRESULT WINAPI PStore_fnDeleteType( IPStore* This,
167 PST_KEY Key, const GUID* pType, DWORD dwFlags)
168 {
169 FIXME("%p %d %s %08x\n", This, Key, debugstr_guid(pType), dwFlags);
170 return E_NOTIMPL;
171 }
172
173 /******************************************************************************
174 * IPStore->CreateSubtype
175 */
176 static HRESULT WINAPI PStore_fnCreateSubtype( IPStore* This,
177 PST_KEY Key, const GUID* pType, const GUID* pSubtype,
178 PPST_TYPEINFO pInfo, PPST_ACCESSRULESET pRules, DWORD dwFlags)
179 {
180 FIXME("%p %08x %s %s %p %p %08x\n", This, Key, debugstr_guid(pType),
181 debugstr_guid(pSubtype), pInfo, pRules, dwFlags);
182 return E_NOTIMPL;
183 }
184
185 /******************************************************************************
186 * IPStore->GetSubtypeInfo
187 */
188 static HRESULT WINAPI PStore_fnGetSubtypeInfo( IPStore* This,
189 PST_KEY Key, const GUID* pType, const GUID* pSubtype,
190 PPST_TYPEINFO** ppInfo, DWORD dwFlags)
191 {
192 FIXME("\n");
193 return E_NOTIMPL;
194 }
195
196 /******************************************************************************
197 * IPStore->DeleteSubtype
198 */
199 static HRESULT WINAPI PStore_fnDeleteSubtype( IPStore* This,
200 PST_KEY Key, const GUID* pType, const GUID* pSubtype, DWORD dwFlags)
201 {
202 FIXME("%p %u %s %s %08x\n", This, Key,
203 debugstr_guid(pType), debugstr_guid(pSubtype), dwFlags);
204 return E_NOTIMPL;
205 }
206
207 /******************************************************************************
208 * IPStore->ReadAccessRuleset
209 */
210 static HRESULT WINAPI PStore_fnReadAccessRuleset( IPStore* This,
211 PST_KEY Key, const GUID* pType, const GUID* pSubtype, PPST_TYPEINFO pInfo,
212 PPST_ACCESSRULESET** ppRules, DWORD dwFlags)
213 {
214 FIXME("\n");
215 return E_NOTIMPL;
216 }
217
218 /******************************************************************************
219 * IPStore->WriteAccessRuleSet
220 */
221 static HRESULT WINAPI PStore_fnWriteAccessRuleset( IPStore* This,
222 PST_KEY Key, const GUID* pType, const GUID* pSubtype,
223 PPST_TYPEINFO pInfo, PPST_ACCESSRULESET pRules, DWORD dwFlags)
224 {
225 FIXME("\n");
226 return E_NOTIMPL;
227 }
228
229 /******************************************************************************
230 * IPStore->EnumTypes
231 */
232 static HRESULT WINAPI PStore_fnEnumTypes( IPStore* This, PST_KEY Key,
233 DWORD dwFlags, IEnumPStoreTypes** ppenum)
234 {
235 FIXME("\n");
236 return E_NOTIMPL;
237 }
238
239 /******************************************************************************
240 * IPStore->EnumSubtypes
241 */
242 static HRESULT WINAPI PStore_fnEnumSubtypes( IPStore* This, PST_KEY Key,
243 const GUID* pType, DWORD dwFlags, IEnumPStoreTypes** ppenum)
244 {
245 FIXME("\n");
246 return E_NOTIMPL;
247 }
248
249 /******************************************************************************
250 * IPStore->DeleteItem
251 */
252 static HRESULT WINAPI PStore_fnDeleteItem( IPStore* This, PST_KEY Key,
253 const GUID* pItemType, const GUID* pItemSubType, LPCWSTR szItemName,
254 PPST_PROMPTINFO pPromptInfo, DWORD dwFlags)
255 {
256 FIXME("\n");
257 return E_NOTIMPL;
258 }
259
260 /******************************************************************************
261 * IPStore->ReadItem
262 */
263 static HRESULT WINAPI PStore_fnReadItem( IPStore* This, PST_KEY Key,
264 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR szItemName,
265 DWORD *cbData, BYTE** pbData, PPST_PROMPTINFO pPromptInfo, DWORD dwFlags)
266 {
267 FIXME("%p %08x %s %s %s %p %p %p %08x\n", This, Key,
268 debugstr_guid(pItemType), debugstr_guid(pItemSubtype),
269 debugstr_w(szItemName), cbData, pbData, pPromptInfo, dwFlags);
270 return E_NOTIMPL;
271 }
272
273 /******************************************************************************
274 * IPStore->WriteItem
275 */
276 static HRESULT WINAPI PStore_fnWriteItem( IPStore* This, PST_KEY Key,
277 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR szItemName,
278 DWORD cbData, BYTE* ppbData, PPST_PROMPTINFO pPromptInfo,
279 DWORD dwDefaultConfirmationStyle, DWORD dwFlags)
280 {
281 FIXME("%p %08x %s %s %s %d %p %p %08x\n", This, Key,
282 debugstr_guid(pItemType), debugstr_guid(pItemSubtype),
283 debugstr_w(szItemName), cbData, ppbData, pPromptInfo, dwFlags);
284 return E_NOTIMPL;
285 }
286
287 /******************************************************************************
288 * IPStore->OpenItem
289 */
290 static HRESULT WINAPI PStore_fnOpenItem( IPStore* This, PST_KEY Key,
291 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR szItemName,
292 PST_ACCESSMODE ModeFlags, PPST_PROMPTINFO pProomptInfo, DWORD dwFlags )
293 {
294 FIXME("%p %08x %s %s %p %08x %p %08x\n", This, Key,
295 debugstr_guid(pItemType), debugstr_guid(pItemSubtype),
296 debugstr_w(szItemName), ModeFlags, pProomptInfo, dwFlags);
297 return E_NOTIMPL;
298 }
299
300 /******************************************************************************
301 * IPStore->CloseItem
302 */
303 static HRESULT WINAPI PStore_fnCloseItem( IPStore* This, PST_KEY Key,
304 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR* szItemName,
305 DWORD dwFlags)
306 {
307 FIXME("\n");
308 return E_NOTIMPL;
309 }
310
311 /******************************************************************************
312 * IPStore->EnumItems
313 */
314 static HRESULT WINAPI PStore_fnEnumItems( IPStore* This, PST_KEY Key,
315 const GUID* pItemType, const GUID* pItemSubtype, DWORD dwFlags,
316 IEnumPStoreItems** ppenum)
317 {
318 FIXME("\n");
319 return E_NOTIMPL;
320 }
321
322
323 static const IPStoreVtbl pstores_vtbl =
324 {
325 PStore_fnQueryInterface,
326 PStore_fnAddRef,
327 PStore_fnRelease,
328 PStore_fnGetInfo,
329 PStore_fnGetProvParam,
330 PStore_fnSetProvParam,
331 PStore_fnCreateType,
332 PStore_fnGetTypeInfo,
333 PStore_fnDeleteType,
334 PStore_fnCreateSubtype,
335 PStore_fnGetSubtypeInfo,
336 PStore_fnDeleteSubtype,
337 PStore_fnReadAccessRuleset,
338 PStore_fnWriteAccessRuleset,
339 PStore_fnEnumTypes,
340 PStore_fnEnumSubtypes,
341 PStore_fnDeleteItem,
342 PStore_fnReadItem,
343 PStore_fnWriteItem,
344 PStore_fnOpenItem,
345 PStore_fnCloseItem,
346 PStore_fnEnumItems
347 };
348
349 HRESULT WINAPI PStoreCreateInstance( IPStore** ppProvider,
350 PST_PROVIDERID* pProviderID, void* pReserved, DWORD dwFlags)
351 {
352 PStore_impl *ips;
353
354 TRACE("%p %s %p %08x\n", ppProvider, debugstr_guid(pProviderID), pReserved, dwFlags);
355
356 ips = HeapAlloc( GetProcessHeap(), 0, sizeof (PStore_impl) );
357 if( !ips )
358 return E_OUTOFMEMORY;
359
360 ips->lpVtbl = &pstores_vtbl;
361 ips->ref = 1;
362
363 *ppProvider = (IPStore*) ips;
364
365 return S_OK;
366 }
367
368 HRESULT WINAPI DllRegisterServer(void)
369 {
370 FIXME("\n");
371 return S_OK;
372 }
373
374 HRESULT WINAPI DllUnregisterServer(void)
375 {
376 FIXME("\n");
377 return S_OK;
378 }
379
380 /***********************************************************************
381 * DllGetClassObject (PSTOREC.@)
382 */
383 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
384 {
385 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
386 return CLASS_E_CLASSNOTAVAILABLE;
387 }
388
389 HRESULT WINAPI DllCanUnloadNow(void)
390 {
391 FIXME("\n");
392 return S_OK;
393 }