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