2 * Copyright 2002 Mike McCormack for CodeWeavers
3 * Copyright 2004-2006 Juan Lang
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * - The concept of physical stores and locations isn't implemented. (This
21 * doesn't mean registry stores et al aren't implemented. See the PSDK for
22 * registering and enumerating physical stores and locations.)
23 * - Many flags, options and whatnot are unimplemented.
27 #include "wine/port.h"
37 #include "wine/debug.h"
38 #include "wine/list.h"
39 #include "wine/exception.h"
40 #include "crypt32_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(crypt
);
44 static const WINE_CONTEXT_INTERFACE gCertInterface
= {
45 (CreateContextFunc
)CertCreateCertificateContext
,
46 (AddContextToStoreFunc
)CertAddCertificateContextToStore
,
47 (AddEncodedContextToStoreFunc
)CertAddEncodedCertificateToStore
,
48 (DuplicateContextFunc
)CertDuplicateCertificateContext
,
49 (EnumContextsInStoreFunc
)CertEnumCertificatesInStore
,
50 (EnumPropertiesFunc
)CertEnumCertificateContextProperties
,
51 (GetContextPropertyFunc
)CertGetCertificateContextProperty
,
52 (SetContextPropertyFunc
)CertSetCertificateContextProperty
,
53 (SerializeElementFunc
)CertSerializeCertificateStoreElement
,
54 (FreeContextFunc
)CertFreeCertificateContext
,
55 (DeleteContextFunc
)CertDeleteCertificateFromStore
,
57 PCWINE_CONTEXT_INTERFACE pCertInterface
= &gCertInterface
;
59 static const WINE_CONTEXT_INTERFACE gCRLInterface
= {
60 (CreateContextFunc
)CertCreateCRLContext
,
61 (AddContextToStoreFunc
)CertAddCRLContextToStore
,
62 (AddEncodedContextToStoreFunc
)CertAddEncodedCRLToStore
,
63 (DuplicateContextFunc
)CertDuplicateCRLContext
,
64 (EnumContextsInStoreFunc
)CertEnumCRLsInStore
,
65 (EnumPropertiesFunc
)CertEnumCRLContextProperties
,
66 (GetContextPropertyFunc
)CertGetCRLContextProperty
,
67 (SetContextPropertyFunc
)CertSetCRLContextProperty
,
68 (SerializeElementFunc
)CertSerializeCRLStoreElement
,
69 (FreeContextFunc
)CertFreeCRLContext
,
70 (DeleteContextFunc
)CertDeleteCRLFromStore
,
72 PCWINE_CONTEXT_INTERFACE pCRLInterface
= &gCRLInterface
;
74 static const WINE_CONTEXT_INTERFACE gCTLInterface
= {
75 (CreateContextFunc
)CertCreateCTLContext
,
76 (AddContextToStoreFunc
)CertAddCTLContextToStore
,
77 (AddEncodedContextToStoreFunc
)CertAddEncodedCTLToStore
,
78 (DuplicateContextFunc
)CertDuplicateCTLContext
,
79 (EnumContextsInStoreFunc
)CertEnumCTLsInStore
,
80 (EnumPropertiesFunc
)CertEnumCTLContextProperties
,
81 (GetContextPropertyFunc
)CertGetCTLContextProperty
,
82 (SetContextPropertyFunc
)CertSetCTLContextProperty
,
83 (SerializeElementFunc
)CertSerializeCTLStoreElement
,
84 (FreeContextFunc
)CertFreeCTLContext
,
85 (DeleteContextFunc
)CertDeleteCTLFromStore
,
87 PCWINE_CONTEXT_INTERFACE pCTLInterface
= &gCTLInterface
;
89 typedef struct _WINE_MEMSTORE
91 WINECRYPT_CERTSTORE hdr
;
92 struct ContextList
*certs
;
93 struct ContextList
*crls
;
94 struct ContextList
*ctls
;
95 } WINE_MEMSTORE
, *PWINE_MEMSTORE
;
97 void CRYPT_InitStore(WINECRYPT_CERTSTORE
*store
, DWORD dwFlags
,
101 store
->dwMagic
= WINE_CRYPTCERTSTORE_MAGIC
;
103 store
->dwOpenFlags
= dwFlags
;
104 store
->properties
= NULL
;
107 void CRYPT_FreeStore(PWINECRYPT_CERTSTORE store
)
109 if (store
->properties
)
110 ContextPropertyList_Free(store
->properties
);
114 BOOL WINAPI
I_CertUpdateStore(HCERTSTORE store1
, HCERTSTORE store2
, DWORD unk0
,
117 static BOOL warned
= FALSE
;
118 const WINE_CONTEXT_INTERFACE
* const interfaces
[] = { pCertInterface
,
119 pCRLInterface
, pCTLInterface
};
122 TRACE("(%p, %p, %08x, %08x)\n", store1
, store2
, unk0
, unk1
);
125 FIXME("semi-stub\n");
129 /* Poor-man's resync: empty first store, then add everything from second
132 for (i
= 0; i
< sizeof(interfaces
) / sizeof(interfaces
[0]); i
++)
137 context
= interfaces
[i
]->enumContextsInStore(store1
, NULL
);
139 interfaces
[i
]->deleteFromStore(context
);
142 context
= interfaces
[i
]->enumContextsInStore(store2
, context
);
144 interfaces
[i
]->addContextToStore(store1
, context
,
145 CERT_STORE_ADD_ALWAYS
, NULL
);
151 static BOOL
CRYPT_MemAddCert(PWINECRYPT_CERTSTORE store
, void *cert
,
152 void *toReplace
, const void **ppStoreContext
)
154 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
155 PCERT_CONTEXT context
;
157 TRACE("(%p, %p, %p, %p)\n", store
, cert
, toReplace
, ppStoreContext
);
159 context
= ContextList_Add(ms
->certs
, cert
, toReplace
);
162 context
->hCertStore
= store
;
164 *ppStoreContext
= CertDuplicateCertificateContext(context
);
166 return context
? TRUE
: FALSE
;
169 static void *CRYPT_MemEnumCert(PWINECRYPT_CERTSTORE store
, void *pPrev
)
171 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
174 TRACE("(%p, %p)\n", store
, pPrev
);
176 ret
= ContextList_Enum(ms
->certs
, pPrev
);
178 SetLastError(CRYPT_E_NOT_FOUND
);
180 TRACE("returning %p\n", ret
);
184 static BOOL
CRYPT_MemDeleteCert(PWINECRYPT_CERTSTORE store
, void *pCertContext
)
186 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
188 ContextList_Delete(ms
->certs
, pCertContext
);
192 static BOOL
CRYPT_MemAddCrl(PWINECRYPT_CERTSTORE store
, void *crl
,
193 void *toReplace
, const void **ppStoreContext
)
195 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
196 PCRL_CONTEXT context
;
198 TRACE("(%p, %p, %p, %p)\n", store
, crl
, toReplace
, ppStoreContext
);
200 context
= ContextList_Add(ms
->crls
, crl
, toReplace
);
203 context
->hCertStore
= store
;
205 *ppStoreContext
= CertDuplicateCRLContext(context
);
207 return context
? TRUE
: FALSE
;
210 static void *CRYPT_MemEnumCrl(PWINECRYPT_CERTSTORE store
, void *pPrev
)
212 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
215 TRACE("(%p, %p)\n", store
, pPrev
);
217 ret
= ContextList_Enum(ms
->crls
, pPrev
);
219 SetLastError(CRYPT_E_NOT_FOUND
);
221 TRACE("returning %p\n", ret
);
225 static BOOL
CRYPT_MemDeleteCrl(PWINECRYPT_CERTSTORE store
, void *pCrlContext
)
227 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
229 ContextList_Delete(ms
->crls
, pCrlContext
);
233 static BOOL
CRYPT_MemAddCtl(PWINECRYPT_CERTSTORE store
, void *ctl
,
234 void *toReplace
, const void **ppStoreContext
)
236 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
237 PCTL_CONTEXT context
;
239 TRACE("(%p, %p, %p, %p)\n", store
, ctl
, toReplace
, ppStoreContext
);
241 context
= ContextList_Add(ms
->ctls
, ctl
, toReplace
);
244 context
->hCertStore
= store
;
246 *ppStoreContext
= CertDuplicateCTLContext(context
);
248 return context
? TRUE
: FALSE
;
251 static void *CRYPT_MemEnumCtl(PWINECRYPT_CERTSTORE store
, void *pPrev
)
253 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
256 TRACE("(%p, %p)\n", store
, pPrev
);
258 ret
= ContextList_Enum(ms
->ctls
, pPrev
);
260 SetLastError(CRYPT_E_NOT_FOUND
);
262 TRACE("returning %p\n", ret
);
266 static BOOL
CRYPT_MemDeleteCtl(PWINECRYPT_CERTSTORE store
, void *pCtlContext
)
268 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
270 ContextList_Delete(ms
->ctls
, pCtlContext
);
274 static void WINAPI
CRYPT_MemCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
276 WINE_MEMSTORE
*store
= hCertStore
;
278 TRACE("(%p, %08x)\n", store
, dwFlags
);
280 FIXME("Unimplemented flags: %08x\n", dwFlags
);
282 ContextList_Free(store
->certs
);
283 ContextList_Free(store
->crls
);
284 ContextList_Free(store
->ctls
);
285 CRYPT_FreeStore((PWINECRYPT_CERTSTORE
)store
);
288 static WINECRYPT_CERTSTORE
*CRYPT_MemOpenStore(HCRYPTPROV hCryptProv
,
289 DWORD dwFlags
, const void *pvPara
)
291 PWINE_MEMSTORE store
;
293 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
295 if (dwFlags
& CERT_STORE_DELETE_FLAG
)
297 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
302 store
= CryptMemAlloc(sizeof(WINE_MEMSTORE
));
305 memset(store
, 0, sizeof(WINE_MEMSTORE
));
306 CRYPT_InitStore(&store
->hdr
, dwFlags
, StoreTypeMem
);
307 store
->hdr
.closeStore
= CRYPT_MemCloseStore
;
308 store
->hdr
.certs
.addContext
= CRYPT_MemAddCert
;
309 store
->hdr
.certs
.enumContext
= CRYPT_MemEnumCert
;
310 store
->hdr
.certs
.deleteContext
= CRYPT_MemDeleteCert
;
311 store
->hdr
.crls
.addContext
= CRYPT_MemAddCrl
;
312 store
->hdr
.crls
.enumContext
= CRYPT_MemEnumCrl
;
313 store
->hdr
.crls
.deleteContext
= CRYPT_MemDeleteCrl
;
314 store
->hdr
.ctls
.addContext
= CRYPT_MemAddCtl
;
315 store
->hdr
.ctls
.enumContext
= CRYPT_MemEnumCtl
;
316 store
->hdr
.ctls
.deleteContext
= CRYPT_MemDeleteCtl
;
317 store
->hdr
.control
= NULL
;
318 store
->certs
= ContextList_Create(pCertInterface
,
319 sizeof(CERT_CONTEXT
));
320 store
->crls
= ContextList_Create(pCRLInterface
,
321 sizeof(CRL_CONTEXT
));
322 store
->ctls
= ContextList_Create(pCTLInterface
,
323 sizeof(CTL_CONTEXT
));
324 /* Mem store doesn't need crypto provider, so close it */
325 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
326 CryptReleaseContext(hCryptProv
, 0);
329 return (PWINECRYPT_CERTSTORE
)store
;
332 static const WCHAR rootW
[] = { 'R','o','o','t',0 };
334 static PWINECRYPT_CERTSTORE
CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv
,
335 DWORD dwFlags
, const void *pvPara
)
337 static const WCHAR fmt
[] = { '%','s','\\','%','s',0 };
338 LPCWSTR storeName
= pvPara
;
340 PWINECRYPT_CERTSTORE store
= NULL
;
344 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
349 SetLastError(E_INVALIDARG
);
352 /* FIXME: In Windows, the root store (even the current user location) is
353 * protected: adding to it or removing from it present a user interface,
354 * and the keys are owned by the system process, not the current user.
355 * Wine's registry doesn't implement access controls, so a similar
356 * mechanism isn't possible yet.
358 if ((dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
) ==
359 CERT_SYSTEM_STORE_LOCAL_MACHINE
&& !lstrcmpiW(storeName
, rootW
))
360 return CRYPT_RootOpenStore(hCryptProv
, dwFlags
);
362 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
364 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
365 root
= HKEY_LOCAL_MACHINE
;
366 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
368 case CERT_SYSTEM_STORE_CURRENT_USER
:
369 root
= HKEY_CURRENT_USER
;
370 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
372 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
373 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
376 FIXME("CERT_SYSTEM_STORE_CURRENT_SERVICE, %s: stub\n",
377 debugstr_w(storeName
));
379 case CERT_SYSTEM_STORE_SERVICES
:
380 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
383 FIXME("CERT_SYSTEM_STORE_SERVICES, %s: stub\n",
384 debugstr_w(storeName
));
386 case CERT_SYSTEM_STORE_USERS
:
387 /* hku\user sid\Software\Microsoft\SystemCertificates */
388 FIXME("CERT_SYSTEM_STORE_USERS, %s: stub\n",
389 debugstr_w(storeName
));
391 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
392 root
= HKEY_CURRENT_USER
;
393 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
395 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
396 root
= HKEY_LOCAL_MACHINE
;
397 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
399 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
400 /* hklm\Software\Microsoft\EnterpriseCertificates */
401 FIXME("CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE, %s: stub\n",
402 debugstr_w(storeName
));
405 SetLastError(E_INVALIDARG
);
409 storePath
= CryptMemAlloc((lstrlenW(base
) + lstrlenW(storeName
) + 2) *
415 REGSAM sam
= dwFlags
& CERT_STORE_READONLY_FLAG
? KEY_READ
:
418 wsprintfW(storePath
, fmt
, base
, storeName
);
419 if (dwFlags
& CERT_STORE_OPEN_EXISTING_FLAG
)
420 rc
= RegOpenKeyExW(root
, storePath
, 0, sam
, &key
);
425 rc
= RegCreateKeyExW(root
, storePath
, 0, NULL
, 0, sam
, NULL
,
427 if (!rc
&& dwFlags
& CERT_STORE_CREATE_NEW_FLAG
&&
428 disp
== REG_OPENED_EXISTING_KEY
)
431 rc
= ERROR_FILE_EXISTS
;
436 store
= CRYPT_RegOpenStore(hCryptProv
, dwFlags
, key
);
441 CryptMemFree(storePath
);
446 static PWINECRYPT_CERTSTORE
CRYPT_SysRegOpenStoreA(HCRYPTPROV hCryptProv
,
447 DWORD dwFlags
, const void *pvPara
)
450 PWINECRYPT_CERTSTORE ret
= NULL
;
452 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
457 SetLastError(ERROR_FILE_NOT_FOUND
);
460 len
= MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, NULL
, 0);
463 LPWSTR storeName
= CryptMemAlloc(len
* sizeof(WCHAR
));
467 MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, storeName
, len
);
468 ret
= CRYPT_SysRegOpenStoreW(hCryptProv
, dwFlags
, storeName
);
469 CryptMemFree(storeName
);
475 static PWINECRYPT_CERTSTORE
CRYPT_SysOpenStoreW(HCRYPTPROV hCryptProv
,
476 DWORD dwFlags
, const void *pvPara
)
478 HCERTSTORE store
= 0;
481 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
486 SetLastError(ERROR_FILE_NOT_FOUND
);
489 /* This returns a different error than system registry stores if the
490 * location is invalid.
492 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
494 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
495 case CERT_SYSTEM_STORE_CURRENT_USER
:
496 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
497 case CERT_SYSTEM_STORE_SERVICES
:
498 case CERT_SYSTEM_STORE_USERS
:
499 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
500 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
501 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
505 SetLastError(ERROR_FILE_NOT_FOUND
);
510 HCERTSTORE regStore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
,
511 0, 0, dwFlags
, pvPara
);
515 store
= CertOpenStore(CERT_STORE_PROV_COLLECTION
, 0, 0,
516 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
517 CertAddStoreToCollection(store
, regStore
,
518 dwFlags
& CERT_STORE_READONLY_FLAG
? 0 :
519 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
, 0);
520 CertCloseStore(regStore
, 0);
521 /* CERT_SYSTEM_STORE_CURRENT_USER returns both the HKCU and HKLM
524 if ((dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
) ==
525 CERT_SYSTEM_STORE_CURRENT_USER
)
527 dwFlags
&= ~CERT_SYSTEM_STORE_CURRENT_USER
;
528 dwFlags
|= CERT_SYSTEM_STORE_LOCAL_MACHINE
;
529 regStore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
, 0,
533 CertAddStoreToCollection(store
, regStore
,
534 dwFlags
& CERT_STORE_READONLY_FLAG
? 0 :
535 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
, 0);
536 CertCloseStore(regStore
, 0);
539 /* System store doesn't need crypto provider, so close it */
540 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
541 CryptReleaseContext(hCryptProv
, 0);
547 static PWINECRYPT_CERTSTORE
CRYPT_SysOpenStoreA(HCRYPTPROV hCryptProv
,
548 DWORD dwFlags
, const void *pvPara
)
551 PWINECRYPT_CERTSTORE ret
= NULL
;
553 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
558 SetLastError(ERROR_FILE_NOT_FOUND
);
561 len
= MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, NULL
, 0);
564 LPWSTR storeName
= CryptMemAlloc(len
* sizeof(WCHAR
));
568 MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, storeName
, len
);
569 ret
= CRYPT_SysOpenStoreW(hCryptProv
, dwFlags
, storeName
);
570 CryptMemFree(storeName
);
576 static void WINAPI
CRYPT_MsgCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
578 HCRYPTMSG msg
= hCertStore
;
580 TRACE("(%p, %08x)\n", msg
, dwFlags
);
584 static void *msgProvFuncs
[] = {
588 static PWINECRYPT_CERTSTORE
CRYPT_MsgOpenStore(HCRYPTPROV hCryptProv
,
589 DWORD dwFlags
, const void *pvPara
)
591 PWINECRYPT_CERTSTORE store
= NULL
;
592 HCRYPTMSG msg
= (HCRYPTMSG
)pvPara
;
593 PWINECRYPT_CERTSTORE memStore
;
595 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
597 memStore
= CertOpenStore(CERT_STORE_PROV_MEMORY
, 0, 0,
598 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
602 DWORD size
, count
, i
;
604 size
= sizeof(count
);
605 ret
= CryptMsgGetParam(msg
, CMSG_CERT_COUNT_PARAM
, 0, &count
, &size
);
606 for (i
= 0; ret
&& i
< count
; i
++)
609 ret
= CryptMsgGetParam(msg
, CMSG_CERT_PARAM
, i
, NULL
, &size
);
612 LPBYTE buf
= CryptMemAlloc(size
);
616 ret
= CryptMsgGetParam(msg
, CMSG_CERT_PARAM
, i
, buf
, &size
);
618 ret
= CertAddEncodedCertificateToStore(memStore
,
619 X509_ASN_ENCODING
, buf
, size
, CERT_STORE_ADD_ALWAYS
,
625 size
= sizeof(count
);
626 ret
= CryptMsgGetParam(msg
, CMSG_CRL_COUNT_PARAM
, 0, &count
, &size
);
627 for (i
= 0; ret
&& i
< count
; i
++)
630 ret
= CryptMsgGetParam(msg
, CMSG_CRL_PARAM
, i
, NULL
, &size
);
633 LPBYTE buf
= CryptMemAlloc(size
);
637 ret
= CryptMsgGetParam(msg
, CMSG_CRL_PARAM
, i
, buf
, &size
);
639 ret
= CertAddEncodedCRLToStore(memStore
,
640 X509_ASN_ENCODING
, buf
, size
, CERT_STORE_ADD_ALWAYS
,
648 CERT_STORE_PROV_INFO provInfo
= { 0 };
650 provInfo
.cbSize
= sizeof(provInfo
);
651 provInfo
.cStoreProvFunc
= sizeof(msgProvFuncs
) /
652 sizeof(msgProvFuncs
[0]);
653 provInfo
.rgpvStoreProvFunc
= msgProvFuncs
;
654 provInfo
.hStoreProv
= CryptMsgDuplicate(msg
);
655 store
= CRYPT_ProvCreateStore(dwFlags
, memStore
, &provInfo
);
656 /* Msg store doesn't need crypto provider, so close it */
657 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
658 CryptReleaseContext(hCryptProv
, 0);
661 CertCloseStore(memStore
, 0);
663 TRACE("returning %p\n", store
);
667 static PWINECRYPT_CERTSTORE
CRYPT_PKCSOpenStore(HCRYPTPROV hCryptProv
,
668 DWORD dwFlags
, const void *pvPara
)
671 PWINECRYPT_CERTSTORE store
= NULL
;
672 const CRYPT_DATA_BLOB
*data
= pvPara
;
674 DWORD msgOpenFlags
= dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
? 0 :
675 CMSG_CRYPT_RELEASE_CONTEXT_FLAG
;
677 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
679 msg
= CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING
, msgOpenFlags
, CMSG_SIGNED
,
680 hCryptProv
, NULL
, NULL
);
681 ret
= CryptMsgUpdate(msg
, data
->pbData
, data
->cbData
, TRUE
);
685 msg
= CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING
, msgOpenFlags
, 0,
686 hCryptProv
, NULL
, NULL
);
687 ret
= CryptMsgUpdate(msg
, data
->pbData
, data
->cbData
, TRUE
);
690 DWORD type
, size
= sizeof(type
);
692 /* Only signed messages are allowed, check type */
693 ret
= CryptMsgGetParam(msg
, CMSG_TYPE_PARAM
, 0, &type
, &size
);
694 if (ret
&& type
!= CMSG_SIGNED
)
696 SetLastError(CRYPT_E_INVALID_MSG_TYPE
);
702 store
= CRYPT_MsgOpenStore(0, dwFlags
, msg
);
704 TRACE("returning %p\n", store
);
708 static PWINECRYPT_CERTSTORE
CRYPT_PhysOpenStoreW(HCRYPTPROV hCryptProv
,
709 DWORD dwFlags
, const void *pvPara
)
711 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
712 FIXME("(%ld, %08x, %p): stub\n", hCryptProv
, dwFlags
, pvPara
);
714 FIXME("(%ld, %08x, %s): stub\n", hCryptProv
, dwFlags
,
719 HCERTSTORE WINAPI
CertOpenStore(LPCSTR lpszStoreProvider
,
720 DWORD dwMsgAndCertEncodingType
, HCRYPTPROV_LEGACY hCryptProv
, DWORD dwFlags
,
723 WINECRYPT_CERTSTORE
*hcs
;
724 StoreOpenFunc openFunc
= NULL
;
726 TRACE("(%s, %08x, %08lx, %08x, %p)\n", debugstr_a(lpszStoreProvider
),
727 dwMsgAndCertEncodingType
, hCryptProv
, dwFlags
, pvPara
);
729 if (!HIWORD(lpszStoreProvider
))
731 switch (LOWORD(lpszStoreProvider
))
733 case LOWORD(CERT_STORE_PROV_MSG
):
734 openFunc
= CRYPT_MsgOpenStore
;
736 case LOWORD(CERT_STORE_PROV_MEMORY
):
737 openFunc
= CRYPT_MemOpenStore
;
739 case LOWORD(CERT_STORE_PROV_FILE
):
740 openFunc
= CRYPT_FileOpenStore
;
742 case LOWORD(CERT_STORE_PROV_PKCS7
):
743 openFunc
= CRYPT_PKCSOpenStore
;
745 case LOWORD(CERT_STORE_PROV_REG
):
746 openFunc
= CRYPT_RegOpenStore
;
748 case LOWORD(CERT_STORE_PROV_FILENAME_A
):
749 openFunc
= CRYPT_FileNameOpenStoreA
;
751 case LOWORD(CERT_STORE_PROV_FILENAME_W
):
752 openFunc
= CRYPT_FileNameOpenStoreW
;
754 case LOWORD(CERT_STORE_PROV_COLLECTION
):
755 openFunc
= CRYPT_CollectionOpenStore
;
757 case LOWORD(CERT_STORE_PROV_SYSTEM_A
):
758 openFunc
= CRYPT_SysOpenStoreA
;
760 case LOWORD(CERT_STORE_PROV_SYSTEM_W
):
761 openFunc
= CRYPT_SysOpenStoreW
;
763 case LOWORD(CERT_STORE_PROV_SYSTEM_REGISTRY_A
):
764 openFunc
= CRYPT_SysRegOpenStoreA
;
766 case LOWORD(CERT_STORE_PROV_SYSTEM_REGISTRY_W
):
767 openFunc
= CRYPT_SysRegOpenStoreW
;
769 case LOWORD(CERT_STORE_PROV_PHYSICAL_W
):
770 openFunc
= CRYPT_PhysOpenStoreW
;
773 if (LOWORD(lpszStoreProvider
))
774 FIXME("unimplemented type %d\n", LOWORD(lpszStoreProvider
));
777 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_MEMORY
))
778 openFunc
= CRYPT_MemOpenStore
;
779 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_FILENAME_W
))
780 openFunc
= CRYPT_FileOpenStore
;
781 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SYSTEM
))
782 openFunc
= CRYPT_SysOpenStoreW
;
783 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_COLLECTION
))
784 openFunc
= CRYPT_CollectionOpenStore
;
785 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SYSTEM_REGISTRY
))
786 openFunc
= CRYPT_SysRegOpenStoreW
;
789 FIXME("unimplemented type %s\n", lpszStoreProvider
);
794 hcs
= CRYPT_ProvOpenStore(lpszStoreProvider
, dwMsgAndCertEncodingType
,
795 hCryptProv
, dwFlags
, pvPara
);
797 hcs
= openFunc(hCryptProv
, dwFlags
, pvPara
);
801 HCERTSTORE WINAPI
CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv
,
802 LPCSTR szSubSystemProtocol
)
804 if (!szSubSystemProtocol
)
806 SetLastError(E_INVALIDARG
);
809 return CertOpenStore(CERT_STORE_PROV_SYSTEM_A
, 0, hProv
,
810 CERT_SYSTEM_STORE_CURRENT_USER
, szSubSystemProtocol
);
813 HCERTSTORE WINAPI
CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv
,
814 LPCWSTR szSubSystemProtocol
)
816 if (!szSubSystemProtocol
)
818 SetLastError(E_INVALIDARG
);
821 return CertOpenStore(CERT_STORE_PROV_SYSTEM_W
, 0, hProv
,
822 CERT_SYSTEM_STORE_CURRENT_USER
, szSubSystemProtocol
);
825 #define CertContext_CopyProperties(to, from) \
826 Context_CopyProperties((to), (from), sizeof(CERT_CONTEXT))
828 BOOL WINAPI
CertAddCertificateContextToStore(HCERTSTORE hCertStore
,
829 PCCERT_CONTEXT pCertContext
, DWORD dwAddDisposition
,
830 PCCERT_CONTEXT
*ppStoreContext
)
832 PWINECRYPT_CERTSTORE store
= hCertStore
;
834 PCCERT_CONTEXT toAdd
= NULL
, existing
= NULL
;
836 TRACE("(%p, %p, %08x, %p)\n", hCertStore
, pCertContext
,
837 dwAddDisposition
, ppStoreContext
);
839 if (dwAddDisposition
!= CERT_STORE_ADD_ALWAYS
)
842 DWORD size
= sizeof(hashToAdd
);
844 ret
= CertGetCertificateContextProperty(pCertContext
, CERT_HASH_PROP_ID
,
848 CRYPT_HASH_BLOB blob
= { sizeof(hashToAdd
), hashToAdd
};
850 existing
= CertFindCertificateInStore(hCertStore
,
851 pCertContext
->dwCertEncodingType
, 0, CERT_FIND_SHA1_HASH
, &blob
,
856 switch (dwAddDisposition
)
858 case CERT_STORE_ADD_ALWAYS
:
859 toAdd
= CertDuplicateCertificateContext(pCertContext
);
861 case CERT_STORE_ADD_NEW
:
864 TRACE("found matching certificate, not adding\n");
865 SetLastError(CRYPT_E_EXISTS
);
869 toAdd
= CertDuplicateCertificateContext(pCertContext
);
871 case CERT_STORE_ADD_REPLACE_EXISTING
:
872 toAdd
= CertDuplicateCertificateContext(pCertContext
);
874 case CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
:
875 toAdd
= CertDuplicateCertificateContext(pCertContext
);
877 CertContext_CopyProperties(toAdd
, existing
);
879 case CERT_STORE_ADD_USE_EXISTING
:
882 CertContext_CopyProperties(existing
, pCertContext
);
883 *ppStoreContext
= CertDuplicateCertificateContext(existing
);
886 toAdd
= CertDuplicateCertificateContext(pCertContext
);
888 case CERT_STORE_ADD_NEWER
:
891 if (CompareFileTime(&existing
->pCertInfo
->NotBefore
,
892 &pCertContext
->pCertInfo
->NotBefore
) >= 0)
894 TRACE("existing certificate is newer, not adding\n");
895 SetLastError(CRYPT_E_EXISTS
);
899 toAdd
= CertDuplicateCertificateContext(pCertContext
);
902 toAdd
= CertDuplicateCertificateContext(pCertContext
);
904 case CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
:
907 if (CompareFileTime(&existing
->pCertInfo
->NotBefore
,
908 &pCertContext
->pCertInfo
->NotBefore
) >= 0)
910 TRACE("existing certificate is newer, not adding\n");
911 SetLastError(CRYPT_E_EXISTS
);
916 toAdd
= CertDuplicateCertificateContext(pCertContext
);
917 CertContext_CopyProperties(toAdd
, existing
);
921 toAdd
= CertDuplicateCertificateContext(pCertContext
);
924 FIXME("Unimplemented add disposition %d\n", dwAddDisposition
);
925 SetLastError(E_INVALIDARG
);
932 ret
= store
->certs
.addContext(store
, (void *)toAdd
,
933 (void *)existing
, (const void **)ppStoreContext
);
934 else if (ppStoreContext
)
935 *ppStoreContext
= CertDuplicateCertificateContext(toAdd
);
936 CertFreeCertificateContext(toAdd
);
938 CertFreeCertificateContext(existing
);
940 TRACE("returning %d\n", ret
);
944 PCCERT_CONTEXT WINAPI
CertEnumCertificatesInStore(HCERTSTORE hCertStore
,
945 PCCERT_CONTEXT pPrev
)
947 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
950 TRACE("(%p, %p)\n", hCertStore
, pPrev
);
953 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
956 ret
= (PCCERT_CONTEXT
)hcs
->certs
.enumContext(hcs
, (void *)pPrev
);
960 BOOL WINAPI
CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext
)
964 TRACE("(%p)\n", pCertContext
);
968 else if (!pCertContext
->hCertStore
)
971 CertFreeCertificateContext(pCertContext
);
975 PWINECRYPT_CERTSTORE hcs
= pCertContext
->hCertStore
;
977 if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
980 ret
= hcs
->certs
.deleteContext(hcs
, (void *)pCertContext
);
981 CertFreeCertificateContext(pCertContext
);
986 #define CrlContext_CopyProperties(to, from) \
987 Context_CopyProperties((to), (from), sizeof(CRL_CONTEXT))
989 BOOL WINAPI
CertAddCRLContextToStore(HCERTSTORE hCertStore
,
990 PCCRL_CONTEXT pCrlContext
, DWORD dwAddDisposition
,
991 PCCRL_CONTEXT
* ppStoreContext
)
993 PWINECRYPT_CERTSTORE store
= hCertStore
;
995 PCCRL_CONTEXT toAdd
= NULL
, existing
= NULL
;
997 TRACE("(%p, %p, %08x, %p)\n", hCertStore
, pCrlContext
,
998 dwAddDisposition
, ppStoreContext
);
1000 /* Weird case to pass a test */
1001 if (dwAddDisposition
== 0)
1003 SetLastError(STATUS_ACCESS_VIOLATION
);
1006 if (dwAddDisposition
!= CERT_STORE_ADD_ALWAYS
)
1008 existing
= CertFindCRLInStore(hCertStore
, 0, 0, CRL_FIND_EXISTING
,
1012 switch (dwAddDisposition
)
1014 case CERT_STORE_ADD_ALWAYS
:
1015 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1017 case CERT_STORE_ADD_NEW
:
1020 TRACE("found matching CRL, not adding\n");
1021 SetLastError(CRYPT_E_EXISTS
);
1025 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1027 case CERT_STORE_ADD_NEWER
:
1030 LONG newer
= CompareFileTime(&existing
->pCrlInfo
->ThisUpdate
,
1031 &pCrlContext
->pCrlInfo
->ThisUpdate
);
1034 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1037 TRACE("existing CRL is newer, not adding\n");
1038 SetLastError(CRYPT_E_EXISTS
);
1043 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1045 case CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
:
1048 LONG newer
= CompareFileTime(&existing
->pCrlInfo
->ThisUpdate
,
1049 &pCrlContext
->pCrlInfo
->ThisUpdate
);
1053 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1054 CrlContext_CopyProperties(toAdd
, existing
);
1058 TRACE("existing CRL is newer, not adding\n");
1059 SetLastError(CRYPT_E_EXISTS
);
1064 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1066 case CERT_STORE_ADD_REPLACE_EXISTING
:
1067 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1069 case CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
:
1070 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1072 CrlContext_CopyProperties(toAdd
, existing
);
1074 case CERT_STORE_ADD_USE_EXISTING
:
1076 CrlContext_CopyProperties(existing
, pCrlContext
);
1079 FIXME("Unimplemented add disposition %d\n", dwAddDisposition
);
1086 ret
= store
->crls
.addContext(store
, (void *)toAdd
,
1087 (void *)existing
, (const void **)ppStoreContext
);
1088 else if (ppStoreContext
)
1089 *ppStoreContext
= CertDuplicateCRLContext(toAdd
);
1090 CertFreeCRLContext(toAdd
);
1092 CertFreeCRLContext(existing
);
1094 TRACE("returning %d\n", ret
);
1098 BOOL WINAPI
CertDeleteCRLFromStore(PCCRL_CONTEXT pCrlContext
)
1102 TRACE("(%p)\n", pCrlContext
);
1106 else if (!pCrlContext
->hCertStore
)
1109 CertFreeCRLContext(pCrlContext
);
1113 PWINECRYPT_CERTSTORE hcs
= pCrlContext
->hCertStore
;
1115 if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1118 ret
= hcs
->crls
.deleteContext(hcs
, (void *)pCrlContext
);
1119 CertFreeCRLContext(pCrlContext
);
1124 PCCRL_CONTEXT WINAPI
CertEnumCRLsInStore(HCERTSTORE hCertStore
,
1125 PCCRL_CONTEXT pPrev
)
1127 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1130 TRACE("(%p, %p)\n", hCertStore
, pPrev
);
1133 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1136 ret
= (PCCRL_CONTEXT
)hcs
->crls
.enumContext(hcs
, (void *)pPrev
);
1140 HCERTSTORE WINAPI
CertDuplicateStore(HCERTSTORE hCertStore
)
1142 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1144 TRACE("(%p)\n", hCertStore
);
1146 if (hcs
&& hcs
->dwMagic
== WINE_CRYPTCERTSTORE_MAGIC
)
1147 InterlockedIncrement(&hcs
->ref
);
1151 BOOL WINAPI
CertCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
1153 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1155 TRACE("(%p, %08x)\n", hCertStore
, dwFlags
);
1160 if ( hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1163 if (InterlockedDecrement(&hcs
->ref
) == 0)
1165 TRACE("%p's ref count is 0, freeing\n", hcs
);
1167 hcs
->closeStore(hcs
, dwFlags
);
1170 TRACE("%p's ref count is %d\n", hcs
, hcs
->ref
);
1174 BOOL WINAPI
CertControlStore(HCERTSTORE hCertStore
, DWORD dwFlags
,
1175 DWORD dwCtrlType
, void const *pvCtrlPara
)
1177 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1180 TRACE("(%p, %08x, %d, %p)\n", hCertStore
, dwFlags
, dwCtrlType
,
1185 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1190 ret
= hcs
->control(hCertStore
, dwFlags
, dwCtrlType
, pvCtrlPara
);
1197 BOOL WINAPI
CertGetStoreProperty(HCERTSTORE hCertStore
, DWORD dwPropId
,
1198 void *pvData
, DWORD
*pcbData
)
1200 PWINECRYPT_CERTSTORE store
= hCertStore
;
1203 TRACE("(%p, %d, %p, %p)\n", hCertStore
, dwPropId
, pvData
, pcbData
);
1207 case CERT_ACCESS_STATE_PROP_ID
:
1210 *pcbData
= sizeof(DWORD
);
1213 else if (*pcbData
< sizeof(DWORD
))
1215 SetLastError(ERROR_MORE_DATA
);
1216 *pcbData
= sizeof(DWORD
);
1222 if (store
->type
!= StoreTypeMem
&&
1223 !(store
->dwOpenFlags
& CERT_STORE_READONLY_FLAG
))
1224 state
|= CERT_ACCESS_STATE_WRITE_PERSIST_FLAG
;
1225 *(DWORD
*)pvData
= state
;
1230 if (store
->properties
)
1232 CRYPT_DATA_BLOB blob
;
1234 ret
= ContextPropertyList_FindProperty(store
->properties
, dwPropId
,
1239 *pcbData
= blob
.cbData
;
1240 else if (*pcbData
< blob
.cbData
)
1242 SetLastError(ERROR_MORE_DATA
);
1243 *pcbData
= blob
.cbData
;
1248 memcpy(pvData
, blob
.pbData
, blob
.cbData
);
1249 *pcbData
= blob
.cbData
;
1253 SetLastError(CRYPT_E_NOT_FOUND
);
1256 SetLastError(CRYPT_E_NOT_FOUND
);
1261 BOOL WINAPI
CertSetStoreProperty(HCERTSTORE hCertStore
, DWORD dwPropId
,
1262 DWORD dwFlags
, const void *pvData
)
1264 PWINECRYPT_CERTSTORE store
= hCertStore
;
1267 TRACE("(%p, %d, %08x, %p)\n", hCertStore
, dwPropId
, dwFlags
, pvData
);
1269 if (!store
->properties
)
1270 store
->properties
= ContextPropertyList_Create();
1273 case CERT_ACCESS_STATE_PROP_ID
:
1274 SetLastError(E_INVALIDARG
);
1279 const CRYPT_DATA_BLOB
*blob
= pvData
;
1281 ret
= ContextPropertyList_SetProperty(store
->properties
, dwPropId
,
1282 blob
->pbData
, blob
->cbData
);
1286 ContextPropertyList_RemoveProperty(store
->properties
, dwPropId
);
1293 static LONG
CRYPT_OpenParentStore(DWORD dwFlags
,
1294 void *pvSystemStoreLocationPara
, HKEY
*key
)
1299 TRACE("(%08x, %p)\n", dwFlags
, pvSystemStoreLocationPara
);
1301 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
1303 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
1304 root
= HKEY_LOCAL_MACHINE
;
1305 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
1307 case CERT_SYSTEM_STORE_CURRENT_USER
:
1308 root
= HKEY_CURRENT_USER
;
1309 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
1311 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
1312 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
1313 * SystemCertificates
1315 FIXME("CERT_SYSTEM_STORE_CURRENT_SERVICE\n");
1316 return ERROR_FILE_NOT_FOUND
;
1317 case CERT_SYSTEM_STORE_SERVICES
:
1318 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
1319 * SystemCertificates
1321 FIXME("CERT_SYSTEM_STORE_SERVICES\n");
1322 return ERROR_FILE_NOT_FOUND
;
1323 case CERT_SYSTEM_STORE_USERS
:
1324 /* hku\user sid\Software\Microsoft\SystemCertificates */
1325 FIXME("CERT_SYSTEM_STORE_USERS\n");
1326 return ERROR_FILE_NOT_FOUND
;
1327 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
1328 root
= HKEY_CURRENT_USER
;
1329 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
1331 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
1332 root
= HKEY_LOCAL_MACHINE
;
1333 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
1335 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
1336 /* hklm\Software\Microsoft\EnterpriseCertificates */
1337 FIXME("CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE\n");
1338 return ERROR_FILE_NOT_FOUND
;
1340 return ERROR_FILE_NOT_FOUND
;
1343 return RegOpenKeyExW(root
, base
, 0, KEY_READ
, key
);
1346 BOOL WINAPI
CertEnumSystemStore(DWORD dwFlags
, void *pvSystemStoreLocationPara
,
1347 void *pvArg
, PFN_CERT_ENUM_SYSTEM_STORE pfnEnum
)
1352 CERT_SYSTEM_STORE_INFO info
= { sizeof(info
) };
1354 TRACE("(%08x, %p, %p, %p)\n", dwFlags
, pvSystemStoreLocationPara
, pvArg
,
1357 rc
= CRYPT_OpenParentStore(dwFlags
, pvArg
, &key
);
1364 WCHAR name
[MAX_PATH
];
1365 DWORD size
= sizeof(name
) / sizeof(name
[0]);
1367 rc
= RegEnumKeyExW(key
, index
++, name
, &size
, NULL
, NULL
, NULL
,
1370 ret
= pfnEnum(name
, dwFlags
, &info
, NULL
, pvArg
);
1371 } while (ret
&& !rc
);
1372 if (ret
&& rc
!= ERROR_NO_MORE_ITEMS
)
1377 /* Include root store for the local machine location (it isn't in the
1380 if (ret
&& (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
) ==
1381 CERT_SYSTEM_STORE_LOCAL_MACHINE
)
1382 ret
= pfnEnum(rootW
, dwFlags
, &info
, NULL
, pvArg
);
1386 BOOL WINAPI
CertEnumPhysicalStore(const void *pvSystemStore
, DWORD dwFlags
,
1387 void *pvArg
, PFN_CERT_ENUM_PHYSICAL_STORE pfnEnum
)
1389 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
1390 FIXME("(%p, %08x, %p, %p): stub\n", pvSystemStore
, dwFlags
, pvArg
,
1393 FIXME("(%s, %08x, %p, %p): stub\n", debugstr_w(pvSystemStore
),