ReactOS 0.4.15-dev-7918-g2a2556c
regstore.c File Reference
#include <assert.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "winreg.h"
#include "winuser.h"
#include "wine/debug.h"
#include "crypt32_private.h"
Include dependency graph for regstore.c:

Go to the source code of this file.

Classes

struct  _WINE_HASH_TO_DELETE
 
struct  _WINE_REGSTOREINFO
 

Typedefs

typedef struct _WINE_HASH_TO_DELETE WINE_HASH_TO_DELETE
 
typedef struct _WINE_REGSTOREINFO WINE_REGSTOREINFO
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (crypt)
 
static void CRYPT_HashToStr (const BYTE *hash, LPWSTR asciiHash)
 
static void CRYPT_RegReadSerializedFromReg (HKEY key, DWORD contextType, HCERTSTORE store)
 
static void CRYPT_RegReadFromReg (HKEY key, HCERTSTORE store)
 
static BOOL CRYPT_WriteSerializedToReg (HKEY key, DWORD flags, const BYTE *hash, const BYTE *buf, DWORD len)
 
BOOL CRYPT_SerializeContextsToReg (HKEY key, DWORD flags, const WINE_CONTEXT_INTERFACE *contextInterface, HCERTSTORE memStore)
 
static BOOL CRYPT_RegWriteToReg (WINE_REGSTOREINFO *store)
 
static BOOL CRYPT_RegFlushStore (WINE_REGSTOREINFO *store, BOOL force)
 
static void WINAPI CRYPT_RegCloseStore (HCERTSTORE hCertStore, DWORD dwFlags)
 
static BOOL CRYPT_RegWriteContext (WINE_REGSTOREINFO *store, const void *context, DWORD dwFlags)
 
static BOOL CRYPT_RegDeleteContext (WINE_REGSTOREINFO *store, struct list *deleteList, const void *context, const WINE_CONTEXT_INTERFACE *contextInterface)
 
static BOOL WINAPI CRYPT_RegWriteCert (HCERTSTORE hCertStore, PCCERT_CONTEXT cert, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_RegDeleteCert (HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_RegWriteCRL (HCERTSTORE hCertStore, PCCRL_CONTEXT crl, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_RegDeleteCRL (HCERTSTORE hCertStore, PCCRL_CONTEXT pCrlContext, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_RegWriteCTL (HCERTSTORE hCertStore, PCCTL_CONTEXT ctl, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_RegDeleteCTL (HCERTSTORE hCertStore, PCCTL_CONTEXT pCtlContext, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_RegControl (HCERTSTORE hCertStore, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
 
WINECRYPT_CERTSTORECRYPT_RegOpenStore (HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara)
 

Variables

static const WCHAR CertsW []
 
static const WCHAR CRLsW [] = { 'C','R','L','s',0 }
 
static const WCHAR CTLsW [] = { 'C','T','L','s',0 }
 
static const WCHAR BlobW [] = { 'B','l','o','b',0 }
 
static voidregProvFuncs []
 

Typedef Documentation

◆ WINE_HASH_TO_DELETE

◆ WINE_REGSTOREINFO

Function Documentation

◆ CRYPT_HashToStr()

static void CRYPT_HashToStr ( const BYTE hash,
LPWSTR  asciiHash 
)
static

Definition at line 48 of file regstore.c.

49{
50 static const WCHAR fmt[] = { '%','0','2','X',0 };
51 DWORD i;
52
53 assert(hash);
54 assert(asciiHash);
55
56 for (i = 0; i < 20; i++)
57 wsprintfW(asciiHash + i * 2, fmt, hash[i]);
58}
#define assert(x)
Definition: debug.h:53
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: dsound.c:943
Definition: _hash_fun.h:40
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CRYPT_RegReadSerializedFromReg(), CRYPT_RegWriteToReg(), and CRYPT_WriteSerializedToReg().

◆ CRYPT_RegCloseStore()

static void WINAPI CRYPT_RegCloseStore ( HCERTSTORE  hCertStore,
DWORD  dwFlags 
)
static

Definition at line 322 of file regstore.c.

323{
324 WINE_REGSTOREINFO *store = hCertStore;
325
326 TRACE("(%p, %08x)\n", store, dwFlags);
327 if (dwFlags)
328 FIXME("Unimplemented flags: %08x\n", dwFlags);
329
331 RegCloseKey(store->key);
332 store->cs.DebugInfo->Spare[0] = 0;
333 DeleteCriticalSection(&store->cs);
334 CryptMemFree(store);
335}
#define FIXME(fmt,...)
Definition: debug.h:111
#define RegCloseKey(hKey)
Definition: registry.h:49
#define FALSE
Definition: types.h:117
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
static BOOL CRYPT_RegFlushStore(WINE_REGSTOREINFO *store, BOOL force)
Definition: regstore.c:305
#define TRACE(s)
Definition: solgame.cpp:4
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
Definition: winbase.h:887
PCRITICAL_SECTION_DEBUG DebugInfo
Definition: winbase.h:894
CRITICAL_SECTION cs
Definition: regstore.c:42
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ CRYPT_RegControl()

static BOOL WINAPI CRYPT_RegControl ( HCERTSTORE  hCertStore,
DWORD  dwFlags,
DWORD  dwCtrlType,
void const pvCtrlPara 
)
static

Definition at line 456 of file regstore.c.

458{
459 WINE_REGSTOREINFO *store = hCertStore;
460 BOOL ret = TRUE;
461
462 TRACE("(%p, %08x, %d, %p)\n", hCertStore, dwFlags, dwCtrlType,
463 pvCtrlPara);
464
465 switch (dwCtrlType)
466 {
468 {
471
473 CRYPT_RegReadFromReg(store->key, memStore);
474 I_CertUpdateStore(store->memStore, memStore, 0, 0);
475 CertCloseStore(memStore, 0);
476 break;
477 }
479 ret = CRYPT_RegFlushStore(store,
481 break;
483 FIXME("CERT_STORE_CTRL_AUTO_RESYNC: stub\n");
484 break;
486 FIXME("CERT_STORE_CTRL_NOTIFY_CHANGE: stub\n");
487 break;
488 default:
489 FIXME("%u: stub\n", dwCtrlType);
490 ret = FALSE;
491 }
492 return ret;
493}
BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0, DWORD unk1) DECLSPEC_HIDDEN
Definition: store.c:109
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
unsigned int BOOL
Definition: ntddk_ex.h:94
static void CRYPT_RegReadFromReg(HKEY key, HCERTSTORE store)
Definition: regstore.c:159
HCERTSTORE memStore
Definition: regstore.c:39
int ret
#define CERT_STORE_CTRL_COMMIT_FORCE_FLAG
Definition: wincrypt.h:2826
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2464
#define CERT_STORE_CTRL_RESYNC
Definition: wincrypt.h:2820
#define CERT_STORE_PROV_MEMORY
Definition: wincrypt.h:2251
#define CERT_STORE_CTRL_NOTIFY_CHANGE
Definition: wincrypt.h:2821
#define CERT_STORE_CTRL_AUTO_RESYNC
Definition: wincrypt.h:2823
#define CERT_STORE_CTRL_COMMIT
Definition: wincrypt.h:2822

◆ CRYPT_RegDeleteCert()

static BOOL WINAPI CRYPT_RegDeleteCert ( HCERTSTORE  hCertStore,
PCCERT_CONTEXT  pCertContext,
DWORD  dwFlags 
)
static

Definition at line 403 of file regstore.c.

405{
406 WINE_REGSTOREINFO *store = hCertStore;
407
408 TRACE("(%p, %p, %08x)\n", store, pCertContext, dwFlags);
409
412}
const WINE_CONTEXT_INTERFACE * pCertInterface
Definition: store.c:54
static BOOL CRYPT_RegDeleteContext(WINE_REGSTOREINFO *store, struct list *deleteList, const void *context, const WINE_CONTEXT_INTERFACE *contextInterface)
Definition: regstore.c:352
struct list certsToDelete
Definition: regstore.c:43
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4836

◆ CRYPT_RegDeleteContext()

static BOOL CRYPT_RegDeleteContext ( WINE_REGSTOREINFO store,
struct list deleteList,
const void context,
const WINE_CONTEXT_INTERFACE contextInterface 
)
static

Definition at line 352 of file regstore.c.

355{
356 BOOL ret;
357
359 {
361 ret = FALSE;
362 }
363 else
364 {
366
367 if (toDelete)
368 {
369 DWORD size = sizeof(toDelete->hash);
370
371 ret = contextInterface->getProp(context, CERT_HASH_PROP_ID,
372 toDelete->hash, &size);
373 if (ret)
374 {
375 EnterCriticalSection(&store->cs);
376 list_add_tail(deleteList, &toDelete->entry);
377 LeaveCriticalSection(&store->cs);
378 }
379 else
380 {
381 CryptMemFree(toDelete);
382 ret = FALSE;
383 }
384 }
385 else
386 ret = FALSE;
387 if (ret)
388 store->dirty = TRUE;
389 }
390 return ret;
391}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
GLsizeiptr size
Definition: glext.h:5919
GetContextPropertyFunc getProp
struct list entry
Definition: regstore.c:33
Definition: http.c:7252
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define CERT_HASH_PROP_ID
Definition: wincrypt.h:2688
#define CERT_STORE_READONLY_FLAG
Definition: wincrypt.h:2466

Referenced by CRYPT_RegDeleteCert(), CRYPT_RegDeleteCRL(), and CRYPT_RegDeleteCTL().

◆ CRYPT_RegDeleteCRL()

static BOOL WINAPI CRYPT_RegDeleteCRL ( HCERTSTORE  hCertStore,
PCCRL_CONTEXT  pCrlContext,
DWORD  dwFlags 
)
static

Definition at line 424 of file regstore.c.

426{
427 WINE_REGSTOREINFO *store = hCertStore;
428
429 TRACE("(%p, %p, %08x)\n", store, pCrlContext, dwFlags);
430
431 return CRYPT_RegDeleteContext(store, &store->crlsToDelete, pCrlContext,
433}
const WINE_CONTEXT_INTERFACE * pCRLInterface
Definition: store.c:67
struct list crlsToDelete
Definition: regstore.c:44
_In_ PCCRL_CONTEXT pCrlContext
Definition: wincrypt.h:4992

◆ CRYPT_RegDeleteCTL()

static BOOL WINAPI CRYPT_RegDeleteCTL ( HCERTSTORE  hCertStore,
PCCTL_CONTEXT  pCtlContext,
DWORD  dwFlags 
)
static

Definition at line 445 of file regstore.c.

447{
448 WINE_REGSTOREINFO *store = hCertStore;
449
450 TRACE("(%p, %p, %08x)\n", store, pCtlContext, dwFlags);
451
452 return CRYPT_RegDeleteContext(store, &store->ctlsToDelete, pCtlContext,
454}
const WINE_CONTEXT_INTERFACE * pCTLInterface
Definition: store.c:80
struct list ctlsToDelete
Definition: regstore.c:45
_In_ PCCTL_CONTEXT pCtlContext
Definition: wincrypt.h:5001

◆ CRYPT_RegFlushStore()

static BOOL CRYPT_RegFlushStore ( WINE_REGSTOREINFO store,
BOOL  force 
)
static

Definition at line 305 of file regstore.c.

306{
307 BOOL ret;
308
309 TRACE("(%p, %d)\n", store, force);
310
311 if (store->dirty || force)
312 {
313 ret = CRYPT_RegWriteToReg(store);
314 if (ret)
315 store->dirty = FALSE;
316 }
317 else
318 ret = TRUE;
319 return ret;
320}
static BOOL CRYPT_RegWriteToReg(WINE_REGSTOREINFO *store)
Definition: regstore.c:248

Referenced by CRYPT_RegCloseStore(), and CRYPT_RegControl().

◆ CRYPT_RegOpenStore()

WINECRYPT_CERTSTORE * CRYPT_RegOpenStore ( HCRYPTPROV  hCryptProv,
DWORD  dwFlags,
const void pvPara 
)

Definition at line 512 of file regstore.c.

514{
515 WINECRYPT_CERTSTORE *store = NULL;
516
517 TRACE("(%ld, %08x, %p)\n", hCryptProv, dwFlags, pvPara);
518
520 {
522
523 if (rc == ERROR_SUCCESS || rc == ERROR_NO_MORE_ITEMS)
525 if (rc == ERROR_SUCCESS || rc == ERROR_NO_MORE_ITEMS)
527 if (rc == ERROR_NO_MORE_ITEMS)
528 rc = ERROR_SUCCESS;
529 SetLastError(rc);
530 }
531 else
532 {
533 HKEY key;
534
538 TRUE, 0))
539 {
540 WINECRYPT_CERTSTORE *memStore;
541
542 memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, hCryptProv,
544 if (memStore)
545 {
547 sizeof(WINE_REGSTOREINFO));
548
549 if (regInfo)
550 {
551 CERT_STORE_PROV_INFO provInfo = { 0 };
552
553 regInfo->dwOpenFlags = dwFlags;
554 regInfo->memStore = memStore;
555 regInfo->key = key;
556 InitializeCriticalSection(&regInfo->cs);
557 regInfo->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PWINE_REGSTOREINFO->cs");
558 list_init(&regInfo->certsToDelete);
559 list_init(&regInfo->crlsToDelete);
560 list_init(&regInfo->ctlsToDelete);
561 CRYPT_RegReadFromReg(regInfo->key, regInfo->memStore);
562 regInfo->dirty = FALSE;
563 provInfo.cbSize = sizeof(provInfo);
566 provInfo.hStoreProv = regInfo;
567 store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
568 /* Reg store doesn't need crypto provider, so close it */
569 if (hCryptProv &&
571 CryptReleaseContext(hCryptProv, 0);
572 }
573 }
574 }
575 }
576 TRACE("returning %p\n", store);
577 return store;
578}
#define ARRAY_SIZE(A)
Definition: main.h:33
static void list_init(struct list_entry *head)
Definition: list.h:51
LSTATUS WINAPI RegDeleteTreeW(_In_ HKEY, _In_opt_ LPCWSTR)
WINECRYPT_CERTSTORE * CRYPT_ProvCreateStore(DWORD dwFlags, WINECRYPT_CERTSTORE *memStore, const CERT_STORE_PROV_INFO *pProvInfo) DECLSPEC_HIDDEN
Definition: provstore.c:307
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
#define GetCurrentProcess()
Definition: compat.h:759
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_READ
Definition: nt_native.h:1023
static void * regProvFuncs[]
Definition: regstore.c:495
static const WCHAR CertsW[]
Definition: regstore.c:60
static const WCHAR CTLsW[]
Definition: regstore.c:63
static const WCHAR CRLsW[]
Definition: regstore.c:62
void ** rgpvStoreProvFunc
Definition: wincrypt.h:1149
HCERTSTOREPROV hStoreProv
Definition: wincrypt.h:1150
Definition: copy.c:22
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define DWORD_PTR
Definition: treelist.c:76
_In_ void * pvPara
Definition: wincrypt.h:6077
#define CERT_STORE_NO_CRYPT_RELEASE_FLAG
Definition: wincrypt.h:2452
#define CERT_STORE_DELETE_FLAG
Definition: wincrypt.h:2455

Referenced by CertOpenStore(), and CRYPT_SysRegOpenStoreW().

◆ CRYPT_RegReadFromReg()

static void CRYPT_RegReadFromReg ( HKEY  key,
HCERTSTORE  store 
)
static

Definition at line 159 of file regstore.c.

160{
161 static const WCHAR * const subKeys[] = { CertsW, CRLsW, CTLsW };
162 static const DWORD contextFlags[] = { CERT_STORE_CERTIFICATE_CONTEXT_FLAG,
164 DWORD i;
165
166 for (i = 0; i < ARRAY_SIZE(subKeys); i++)
167 {
168 HKEY hKey;
169 LONG rc;
170
171 rc = RegCreateKeyExW(key, subKeys[i], 0, NULL, 0, KEY_READ, NULL,
172 &hKey, NULL);
173 if (!rc)
174 {
175 CRYPT_RegReadSerializedFromReg(hKey, contextFlags[i], store);
177 }
178 }
179}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
FxAutoRegKey hKey
long LONG
Definition: pedump.c:60
static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType, HCERTSTORE store)
Definition: regstore.c:66
#define CERT_STORE_CTL_CONTEXT_FLAG
Definition: wincrypt.h:2981
#define CERT_STORE_CRL_CONTEXT_FLAG
Definition: wincrypt.h:2980
#define CERT_STORE_CERTIFICATE_CONTEXT_FLAG
Definition: wincrypt.h:2978

Referenced by CRYPT_RegControl(), and CRYPT_RegOpenStore().

◆ CRYPT_RegReadSerializedFromReg()

static void CRYPT_RegReadSerializedFromReg ( HKEY  key,
DWORD  contextType,
HCERTSTORE  store 
)
static

Definition at line 66 of file regstore.c.

68{
69 LONG rc;
70 DWORD index = 0;
71 WCHAR subKeyName[MAX_PATH];
72
73 do {
74 DWORD size = ARRAY_SIZE(subKeyName);
75
76 rc = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL, NULL,
77 NULL);
78 if (!rc)
79 {
80 HKEY subKey;
81
82 rc = RegOpenKeyExW(key, subKeyName, 0, KEY_READ, &subKey);
83 if (!rc)
84 {
85 LPBYTE buf = NULL;
86
87 size = 0;
88 rc = RegQueryValueExW(subKey, BlobW, NULL, NULL, NULL, &size);
89 if (!rc)
91 if (buf)
92 {
93 rc = RegQueryValueExW(subKey, BlobW, NULL, NULL, buf,
94 &size);
95 if (!rc)
96 {
97 const void *context;
98 DWORD addedType;
99
100 TRACE("Adding cert with hash %s\n",
101 debugstr_w(subKeyName));
103 contextType, &addedType);
104 if (context)
105 {
106 const WINE_CONTEXT_INTERFACE *contextInterface;
107 BYTE hash[20];
108
109 switch (addedType)
110 {
112 contextInterface = pCertInterface;
113 break;
115 contextInterface = pCRLInterface;
116 break;
118 contextInterface = pCTLInterface;
119 break;
120 default:
121 contextInterface = NULL;
122 }
123 if (contextInterface)
124 {
125 size = sizeof(hash);
126 if (contextInterface->getProp(context,
128 {
129 WCHAR asciiHash[20 * 2 + 1];
130
131 CRYPT_HashToStr(hash, asciiHash);
132 TRACE("comparing %s\n",
133 debugstr_w(asciiHash));
134 TRACE("with %s\n", debugstr_w(subKeyName));
135 if (!lstrcmpW(asciiHash, subKeyName))
136 {
137 TRACE("hash matches, adding\n");
138 contextInterface->addContextToStore(
139 store, context,
141 }
142 else
143 TRACE("hash doesn't match, ignoring\n");
144 }
146 }
147 }
148 }
150 }
151 RegCloseKey(subKey);
152 }
153 /* Ignore intermediate errors, continue enumerating */
154 rc = ERROR_SUCCESS;
155 }
156 } while (!rc);
157}
const void * CRYPT_ReadSerializedElement(const BYTE *pbElement, DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType) DECLSPEC_HIDDEN
Definition: serialize.c:295
static context_t * context_from_ptr(const void *ptr)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
void Context_Release(context_t *context)
Definition: context.c:106
#define MAX_PATH
Definition: compat.h:34
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define debugstr_w
Definition: kernel32.h:32
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
static const WCHAR BlobW[]
Definition: regstore.c:64
static void CRYPT_HashToStr(const BYTE *hash, LPWSTR asciiHash)
Definition: regstore.c:48
AddContextToStoreFunc addContextToStore
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CERT_STORE_ADD_REPLACE_EXISTING
Definition: wincrypt.h:2484
#define CERT_STORE_CERTIFICATE_CONTEXT
Definition: wincrypt.h:2974
#define CERT_STORE_CTL_CONTEXT
Definition: wincrypt.h:2976
#define CERT_STORE_CRL_CONTEXT
Definition: wincrypt.h:2975
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CRYPT_RegReadFromReg().

◆ CRYPT_RegWriteCert()

static BOOL WINAPI CRYPT_RegWriteCert ( HCERTSTORE  hCertStore,
PCCERT_CONTEXT  cert,
DWORD  dwFlags 
)
static

Definition at line 393 of file regstore.c.

395{
396 WINE_REGSTOREINFO *store = hCertStore;
397
398 TRACE("(%p, %p, %d)\n", hCertStore, cert, dwFlags);
399
400 return CRYPT_RegWriteContext(store, cert, dwFlags);
401}
static BYTE cert[]
Definition: msg.c:1437
static BOOL CRYPT_RegWriteContext(WINE_REGSTOREINFO *store, const void *context, DWORD dwFlags)
Definition: regstore.c:337

◆ CRYPT_RegWriteContext()

static BOOL CRYPT_RegWriteContext ( WINE_REGSTOREINFO store,
const void context,
DWORD  dwFlags 
)
static

Definition at line 337 of file regstore.c.

339{
340 BOOL ret;
341
343 {
344 store->dirty = TRUE;
345 ret = TRUE;
346 }
347 else
348 ret = FALSE;
349 return ret;
350}
#define CERT_STORE_PROV_WRITE_ADD_FLAG
Definition: wincrypt.h:2971

Referenced by CRYPT_RegWriteCert(), CRYPT_RegWriteCRL(), and CRYPT_RegWriteCTL().

◆ CRYPT_RegWriteCRL()

static BOOL WINAPI CRYPT_RegWriteCRL ( HCERTSTORE  hCertStore,
PCCRL_CONTEXT  crl,
DWORD  dwFlags 
)
static

Definition at line 414 of file regstore.c.

416{
417 WINE_REGSTOREINFO *store = hCertStore;
418
419 TRACE("(%p, %p, %d)\n", hCertStore, crl, dwFlags);
420
421 return CRYPT_RegWriteContext(store, crl, dwFlags);
422}
static const BYTE crl[]
Definition: message.c:864

◆ CRYPT_RegWriteCTL()

static BOOL WINAPI CRYPT_RegWriteCTL ( HCERTSTORE  hCertStore,
PCCTL_CONTEXT  ctl,
DWORD  dwFlags 
)
static

Definition at line 435 of file regstore.c.

437{
438 WINE_REGSTOREINFO *store = hCertStore;
439
440 TRACE("(%p, %p, %d)\n", hCertStore, ctl, dwFlags);
441
442 return CRYPT_RegWriteContext(store, ctl, dwFlags);
443}

◆ CRYPT_RegWriteToReg()

static BOOL CRYPT_RegWriteToReg ( WINE_REGSTOREINFO store)
static

Definition at line 248 of file regstore.c.

249{
250 static const WCHAR * const subKeys[] = { CertsW, CRLsW, CTLsW };
251 const WINE_CONTEXT_INTERFACE * const interfaces[] = { pCertInterface,
253 struct list *listToDelete[] = { &store->certsToDelete, &store->crlsToDelete,
254 &store->ctlsToDelete };
255 BOOL ret = TRUE;
256 DWORD i;
257
258 for (i = 0; ret && i < ARRAY_SIZE(subKeys); i++)
259 {
260 HKEY key;
261 LONG rc = RegCreateKeyExW(store->key, subKeys[i], 0, NULL, 0,
263
264 if (!rc)
265 {
266 if (listToDelete[i])
267 {
268 WINE_HASH_TO_DELETE *toDelete, *next;
269 WCHAR asciiHash[20 * 2 + 1];
270
271 EnterCriticalSection(&store->cs);
272 LIST_FOR_EACH_ENTRY_SAFE(toDelete, next, listToDelete[i],
274 {
275 LONG rc;
276
277 CRYPT_HashToStr(toDelete->hash, asciiHash);
278 TRACE("Removing %s\n", debugstr_w(asciiHash));
279 rc = RegDeleteKeyW(key, asciiHash);
280 if (rc != ERROR_SUCCESS && rc != ERROR_FILE_NOT_FOUND)
281 {
282 SetLastError(rc);
283 ret = FALSE;
284 }
285 list_remove(&toDelete->entry);
286 CryptMemFree(toDelete);
287 }
288 LeaveCriticalSection(&store->cs);
289 }
290 ret = CRYPT_SerializeContextsToReg(key, 0, interfaces[i], store->memStore);
292 }
293 else
294 {
295 SetLastError(rc);
296 ret = FALSE;
297 }
298 }
299 return ret;
300}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
Definition: list.h:37
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
uint32_t entry
Definition: isohybrid.c:63
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static unsigned __int64 next
Definition: rand_nt.c:6
BOOL CRYPT_SerializeContextsToReg(HKEY key, DWORD flags, const WINE_CONTEXT_INTERFACE *contextInterface, HCERTSTORE memStore)
Definition: regstore.c:208
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204

Referenced by CRYPT_RegFlushStore().

◆ CRYPT_SerializeContextsToReg()

BOOL CRYPT_SerializeContextsToReg ( HKEY  key,
DWORD  flags,
const WINE_CONTEXT_INTERFACE contextInterface,
HCERTSTORE  memStore 
)

Definition at line 208 of file regstore.c.

210{
211 const void *context = NULL;
212 BOOL ret;
213
214 do {
215 context = contextInterface->enumContextsInStore(memStore, context);
216 if (context)
217 {
218 BYTE hash[20];
219 DWORD hashSize = sizeof(hash);
220
221 ret = contextInterface->getProp(context, CERT_HASH_PROP_ID, hash,
222 &hashSize);
223 if (ret)
224 {
225 DWORD size = 0;
226 LPBYTE buf = NULL;
227
228 ret = contextInterface->serialize(context, 0, NULL, &size);
229 if (size)
231 if (buf)
232 {
233 ret = contextInterface->serialize(context, 0, buf, &size);
234 if (ret)
236 }
238 }
239 }
240 else
241 ret = TRUE;
242 } while (ret && context != NULL);
243 if (context)
245 return ret;
246}
GLbitfield flags
Definition: glext.h:7161
static BOOL CRYPT_WriteSerializedToReg(HKEY key, DWORD flags, const BYTE *hash, const BYTE *buf, DWORD len)
Definition: regstore.c:182
SerializeElementFunc serialize
EnumContextsInStoreFunc enumContextsInStore

Referenced by CRYPT_ImportSystemRootCertsToReg(), and CRYPT_RegWriteToReg().

◆ CRYPT_WriteSerializedToReg()

static BOOL CRYPT_WriteSerializedToReg ( HKEY  key,
DWORD  flags,
const BYTE hash,
const BYTE buf,
DWORD  len 
)
static

Definition at line 182 of file regstore.c.

184{
185 WCHAR asciiHash[20 * 2 + 1];
186 LONG rc;
187 HKEY subKey;
188 BOOL ret;
189
190 CRYPT_HashToStr(hash, asciiHash);
191 rc = RegCreateKeyExW(key, asciiHash, 0, NULL, flags, KEY_ALL_ACCESS, NULL,
192 &subKey, NULL);
193 if (!rc)
194 {
195 rc = RegSetValueExW(subKey, BlobW, 0, REG_BINARY, buf, len);
196 RegCloseKey(subKey);
197 }
198 if (!rc)
199 ret = TRUE;
200 else
201 {
202 SetLastError(rc);
203 ret = FALSE;
204 }
205 return ret;
206}
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
GLenum GLsizei len
Definition: glext.h:6722
#define REG_BINARY
Definition: nt_native.h:1496

Referenced by CRYPT_SerializeContextsToReg().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( crypt  )

Variable Documentation

◆ BlobW

const WCHAR BlobW[] = { 'B','l','o','b',0 }
static

Definition at line 64 of file regstore.c.

Referenced by CRYPT_RegReadSerializedFromReg(), and CRYPT_WriteSerializedToReg().

◆ CertsW

const WCHAR CertsW[]
static
Initial value:
= { 'C','e','r','t','i','f','i','c','a','t','e','s',
0 }

Definition at line 60 of file regstore.c.

Referenced by CRYPT_RegOpenStore(), CRYPT_RegReadFromReg(), and CRYPT_RegWriteToReg().

◆ CRLsW

const WCHAR CRLsW[] = { 'C','R','L','s',0 }
static

Definition at line 62 of file regstore.c.

Referenced by CRYPT_RegOpenStore(), CRYPT_RegReadFromReg(), and CRYPT_RegWriteToReg().

◆ CTLsW

const WCHAR CTLsW[] = { 'C','T','L','s',0 }
static

Definition at line 63 of file regstore.c.

Referenced by CRYPT_RegOpenStore(), CRYPT_RegReadFromReg(), and CRYPT_RegWriteToReg().

◆ regProvFuncs

void* regProvFuncs[]
static
Initial value:
= {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}
static BOOL WINAPI CRYPT_RegDeleteCTL(HCERTSTORE hCertStore, PCCTL_CONTEXT pCtlContext, DWORD dwFlags)
Definition: regstore.c:445
static BOOL WINAPI CRYPT_RegWriteCert(HCERTSTORE hCertStore, PCCERT_CONTEXT cert, DWORD dwFlags)
Definition: regstore.c:393
static BOOL WINAPI CRYPT_RegWriteCRL(HCERTSTORE hCertStore, PCCRL_CONTEXT crl, DWORD dwFlags)
Definition: regstore.c:414
static BOOL WINAPI CRYPT_RegWriteCTL(HCERTSTORE hCertStore, PCCTL_CONTEXT ctl, DWORD dwFlags)
Definition: regstore.c:435
static BOOL WINAPI CRYPT_RegDeleteCRL(HCERTSTORE hCertStore, PCCRL_CONTEXT pCrlContext, DWORD dwFlags)
Definition: regstore.c:424
static BOOL WINAPI CRYPT_RegControl(HCERTSTORE hCertStore, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
Definition: regstore.c:456
static void WINAPI CRYPT_RegCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: regstore.c:322
static BOOL WINAPI CRYPT_RegDeleteCert(HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwFlags)
Definition: regstore.c:403

Definition at line 495 of file regstore.c.

Referenced by CRYPT_RegOpenStore().