ReactOS 0.4.17-dev-444-g71ee754
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)
 
void CRYPT_RegReadSerializedFromReg (HKEY key, DWORD contextType, HCERTSTORE store, DWORD disposition)
 
static void CRYPT_RegReadFromReg (HKEY key, HCERTSTORE store, DWORD disposition)
 
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 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 DWORD i;
51
52 assert(hash);
53 assert(asciiHash);
54
55 for (i = 0; i < 20; i++)
56 wsprintfW(asciiHash + i * 2, L"%02X", hash[i]);
57}
#define assert(_expr)
Definition: assert.h:32
#define L(x)
Definition: resources.c:13
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: _hash_fun.h:40
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

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

◆ CRYPT_RegCloseStore()

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

Definition at line 314 of file regstore.c.

315{
316 WINE_REGSTOREINFO *store = hCertStore;
317
318 TRACE("(%p, %08lx)\n", store, dwFlags);
319 if (dwFlags)
320 FIXME("Unimplemented flags: %08lx\n", dwFlags);
321
323 RegCloseKey(store->key);
324 store->cs.DebugInfo->Spare[0] = 0;
325 DeleteCriticalSection(&store->cs);
326 CryptMemFree(store);
327}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define RegCloseKey(hKey)
Definition: registry.h:49
#define FALSE
Definition: types.h:117
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:146
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
static BOOL CRYPT_RegFlushStore(WINE_REGSTOREINFO *store, BOOL force)
Definition: regstore.c:297
#define TRACE(s)
Definition: solgame.cpp:4
PRTL_CRITICAL_SECTION_DEBUG DebugInfo
Definition: rtltypes.h:1450
CRITICAL_SECTION cs
Definition: regstore.c:42
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

◆ CRYPT_RegControl()

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

Definition at line 448 of file regstore.c.

450{
451 WINE_REGSTOREINFO *store = hCertStore;
452 BOOL ret = TRUE;
453
454 TRACE("(%p, %08lx, %ld, %p)\n", hCertStore, dwFlags, dwCtrlType,
455 pvCtrlPara);
456
457 switch (dwCtrlType)
458 {
460 {
463
466 I_CertUpdateStore(store->memStore, memStore, 0, 0);
467 CertCloseStore(memStore, 0);
468 break;
469 }
471 ret = CRYPT_RegFlushStore(store,
473 break;
475 FIXME("CERT_STORE_CTRL_AUTO_RESYNC: stub\n");
476 break;
478 FIXME("CERT_STORE_CTRL_NOTIFY_CHANGE: stub\n");
479 break;
480 default:
481 FIXME("%lu: stub\n", dwCtrlType);
482 ret = FALSE;
483 }
484 return ret;
485}
BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0, DWORD unk1)
Definition: store.c:106
#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:809
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1121
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
static void CRYPT_RegReadFromReg(HKEY key, HCERTSTORE store, DWORD disposition)
Definition: regstore.c:151
HCERTSTORE memStore
Definition: regstore.c:39
#define CERT_STORE_CTRL_COMMIT_FORCE_FLAG
Definition: wincrypt.h:2973
#define CERT_STORE_ADD_REPLACE_EXISTING
Definition: wincrypt.h:2653
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2633
#define CERT_STORE_CTRL_RESYNC
Definition: wincrypt.h:2967
#define CERT_STORE_PROV_MEMORY
Definition: wincrypt.h:2455
#define CERT_STORE_CTRL_NOTIFY_CHANGE
Definition: wincrypt.h:2968
#define CERT_STORE_CTRL_AUTO_RESYNC
Definition: wincrypt.h:2970
#define CERT_STORE_CTRL_COMMIT
Definition: wincrypt.h:2969

◆ CRYPT_RegDeleteCert()

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

Definition at line 395 of file regstore.c.

397{
398 WINE_REGSTOREINFO *store = hCertStore;
399
400 TRACE("(%p, %p, %08lx)\n", store, pCertContext, dwFlags);
401
402 return CRYPT_RegDeleteContext(store, &store->certsToDelete, pCertContext,
404}
const WINE_CONTEXT_INTERFACE * pCertInterface
Definition: store.c:51
static BOOL CRYPT_RegDeleteContext(WINE_REGSTOREINFO *store, struct list *deleteList, const void *context, const WINE_CONTEXT_INTERFACE *contextInterface)
Definition: regstore.c:344
struct list certsToDelete
Definition: regstore.c:43

◆ CRYPT_RegDeleteContext()

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

Definition at line 344 of file regstore.c.

347{
348 BOOL ret;
349
351 {
353 ret = FALSE;
354 }
355 else
356 {
358
359 if (toDelete)
360 {
361 DWORD size = sizeof(toDelete->hash);
362
363 ret = contextInterface->getProp(context, CERT_HASH_PROP_ID,
364 toDelete->hash, &size);
365 if (ret)
366 {
367 EnterCriticalSection(&store->cs);
368 list_add_tail(deleteList, &toDelete->entry);
369 LeaveCriticalSection(&store->cs);
370 }
371 else
372 {
373 CryptMemFree(toDelete);
374 ret = FALSE;
375 }
376 }
377 else
378 ret = FALSE;
379 if (ret)
380 store->dirty = TRUE;
381 }
382 return ret;
383}
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:136
#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:2835
#define CERT_STORE_READONLY_FLAG
Definition: wincrypt.h:2635

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 416 of file regstore.c.

418{
419 WINE_REGSTOREINFO *store = hCertStore;
420
421 TRACE("(%p, %p, %08lx)\n", store, pCrlContext, dwFlags);
422
423 return CRYPT_RegDeleteContext(store, &store->crlsToDelete, pCrlContext,
425}
const WINE_CONTEXT_INTERFACE * pCRLInterface
Definition: store.c:64
struct list crlsToDelete
Definition: regstore.c:44

◆ CRYPT_RegDeleteCTL()

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

Definition at line 437 of file regstore.c.

439{
440 WINE_REGSTOREINFO *store = hCertStore;
441
442 TRACE("(%p, %p, %08lx)\n", store, pCtlContext, dwFlags);
443
444 return CRYPT_RegDeleteContext(store, &store->ctlsToDelete, pCtlContext,
446}
const WINE_CONTEXT_INTERFACE * pCTLInterface
Definition: store.c:77
struct list ctlsToDelete
Definition: regstore.c:45

◆ CRYPT_RegFlushStore()

static BOOL CRYPT_RegFlushStore ( WINE_REGSTOREINFO store,
BOOL  force 
)
static

Definition at line 297 of file regstore.c.

298{
299 BOOL ret;
300
301 TRACE("(%p, %d)\n", store, force);
302
303 if (store->dirty || force)
304 {
305 ret = CRYPT_RegWriteToReg(store);
306 if (ret)
307 store->dirty = FALSE;
308 }
309 else
310 ret = TRUE;
311 return ret;
312}
BOOL force
Definition: metahost.c:100
static BOOL CRYPT_RegWriteToReg(WINE_REGSTOREINFO *store)
Definition: regstore.c:240

Referenced by CRYPT_RegCloseStore(), and CRYPT_RegControl().

◆ CRYPT_RegOpenStore()

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

Definition at line 504 of file regstore.c.

506{
507 WINECRYPT_CERTSTORE *store = NULL;
508
509 TRACE("(%Id, %08lx, %p)\n", hCryptProv, dwFlags, pvPara);
510
512 {
513 DWORD rc = RegDeleteTreeW((HKEY)pvPara, L"Certificates");
514
515 if (rc == ERROR_SUCCESS || rc == ERROR_NO_MORE_ITEMS)
516 rc = RegDeleteTreeW((HKEY)pvPara, L"CRLs");
517 if (rc == ERROR_SUCCESS || rc == ERROR_NO_MORE_ITEMS)
518 rc = RegDeleteTreeW((HKEY)pvPara, L"CTLs");
519 if (rc == ERROR_NO_MORE_ITEMS)
520 rc = ERROR_SUCCESS;
521 SetLastError(rc);
522 }
523 else
524 {
525 HKEY key;
526
530 TRUE, 0))
531 {
532 WINECRYPT_CERTSTORE *memStore;
533
534 memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, hCryptProv,
536 if (memStore)
537 {
539 sizeof(WINE_REGSTOREINFO));
540
541 if (regInfo)
542 {
543 CERT_STORE_PROV_INFO provInfo = { 0 };
544
545 regInfo->dwOpenFlags = dwFlags;
546 regInfo->memStore = memStore;
547 regInfo->key = key;
549 regInfo->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PWINE_REGSTOREINFO->cs");
550 list_init(&regInfo->certsToDelete);
551 list_init(&regInfo->crlsToDelete);
552 list_init(&regInfo->ctlsToDelete);
554 regInfo->dirty = FALSE;
555 provInfo.cbSize = sizeof(provInfo);
558 provInfo.hStoreProv = regInfo;
559 store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
560 /* Reg store doesn't need crypto provider, so close it */
561 if (hCryptProv &&
563 CryptReleaseContext(hCryptProv, 0);
564 }
565 }
566 }
567 }
568 TRACE("returning %p\n", store);
569 return store;
570}
#define ARRAY_SIZE(A)
Definition: main.h:20
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)
Definition: provstore.c:307
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:641
#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
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
Definition: sync.c:107
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define KEY_READ
Definition: nt_native.h:1026
static void * regProvFuncs[]
Definition: regstore.c:487
void ** rgpvStoreProvFunc
Definition: wincrypt.h:1275
HCERTSTOREPROV hStoreProv
Definition: wincrypt.h:1276
Definition: copy.c:22
#define DWORD_PTR
Definition: treelist.c:76
#define CERT_STORE_ADD_ALWAYS
Definition: wincrypt.h:2654
#define CERT_STORE_NO_CRYPT_RELEASE_FLAG
Definition: wincrypt.h:2621
#define CERT_STORE_DELETE_FLAG
Definition: wincrypt.h:2624
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1156

Referenced by CertOpenStore(), and CRYPT_SysRegOpenStoreW().

◆ CRYPT_RegReadFromReg()

static void CRYPT_RegReadFromReg ( HKEY  key,
HCERTSTORE  store,
DWORD  disposition 
)
static

Definition at line 151 of file regstore.c.

152{
153 static const WCHAR * const subKeys[] = { L"Certificates", L"CRLs", L"CTLs" };
154 static const DWORD contextFlags[] = { CERT_STORE_CERTIFICATE_CONTEXT_FLAG,
156 DWORD i;
157
158 for (i = 0; i < ARRAY_SIZE(subKeys); i++)
159 {
160 HKEY hKey;
161 LONG rc;
162
163 rc = RegCreateKeyExW(key, subKeys[i], 0, NULL, 0, KEY_READ, NULL,
164 &hKey, NULL);
165 if (!rc)
166 {
167 CRYPT_RegReadSerializedFromReg(hKey, contextFlags[i], store, disposition);
169 }
170 }
171}
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
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType, HCERTSTORE store, DWORD disposition)
Definition: regstore.c:59
#define CERT_STORE_CTL_CONTEXT_FLAG
Definition: wincrypt.h:3128
#define CERT_STORE_CRL_CONTEXT_FLAG
Definition: wincrypt.h:3127
#define CERT_STORE_CERTIFICATE_CONTEXT_FLAG
Definition: wincrypt.h:3125

Referenced by CRYPT_RegControl(), and CRYPT_RegOpenStore().

◆ CRYPT_RegReadSerializedFromReg()

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

Definition at line 59 of file regstore.c.

60{
61 LONG rc;
62 DWORD index = 0;
63 WCHAR subKeyName[MAX_PATH];
64
65 do {
66 DWORD size = ARRAY_SIZE(subKeyName);
67
68 rc = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL, NULL,
69 NULL);
70 if (!rc)
71 {
72 HKEY subKey;
73
74 rc = RegOpenKeyExW(key, subKeyName, 0, KEY_READ, &subKey);
75 if (!rc)
76 {
77 LPBYTE buf = NULL;
78
79 size = 0;
80 rc = RegQueryValueExW(subKey, L"Blob", NULL, NULL, NULL, &size);
81 if (!rc)
83 if (buf)
84 {
85 rc = RegQueryValueExW(subKey, L"Blob", NULL, NULL, buf,
86 &size);
87 if (!rc)
88 {
89 const void *context;
90 DWORD addedType;
91
92 TRACE("Adding cert with hash %s\n",
93 debugstr_w(subKeyName));
95 contextType, &addedType);
96 if (context)
97 {
98 const WINE_CONTEXT_INTERFACE *contextInterface;
99 BYTE hash[20];
100
101 switch (addedType)
102 {
104 contextInterface = pCertInterface;
105 break;
107 contextInterface = pCRLInterface;
108 break;
110 contextInterface = pCTLInterface;
111 break;
112 default:
113 contextInterface = NULL;
114 }
115 if (contextInterface)
116 {
117 size = sizeof(hash);
118 if (contextInterface->getProp(context,
120 {
121 WCHAR asciiHash[20 * 2 + 1];
122
123 CRYPT_HashToStr(hash, asciiHash);
124 TRACE("comparing %s\n",
125 debugstr_w(asciiHash));
126 TRACE("with %s\n", debugstr_w(subKeyName));
127 if (!wcscmp(asciiHash, subKeyName))
128 {
129 TRACE("hash matches, adding\n");
130 contextInterface->addContextToStore(
131 store, context,
132 disposition, NULL);
133 }
134 else
135 TRACE("hash doesn't match, ignoring\n");
136 }
138 }
139 }
140 }
142 }
143 RegCloseKey(subKey);
144 }
145 /* Ignore intermediate errors, continue enumerating */
146 rc = ERROR_SUCCESS;
147 }
148 } while (!rc);
149}
const void * CRYPT_ReadSerializedElement(const BYTE *pbElement, DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType)
Definition: serialize.c:482
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
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define debugstr_w
Definition: kernel32.h:32
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_CERTIFICATE_CONTEXT
Definition: wincrypt.h:3121
#define CERT_STORE_CTL_CONTEXT
Definition: wincrypt.h:3123
#define CERT_STORE_CRL_CONTEXT
Definition: wincrypt.h:3122
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CRYPT_ImportSystemRootCertsToReg(), and CRYPT_RegReadFromReg().

◆ CRYPT_RegWriteCert()

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

Definition at line 385 of file regstore.c.

387{
388 WINE_REGSTOREINFO *store = hCertStore;
389
390 TRACE("(%p, %p, %ld)\n", hCertStore, cert, dwFlags);
391
392 return CRYPT_RegWriteContext(store, cert, dwFlags);
393}
static BYTE cert[]
Definition: msg.c:1374
static BOOL CRYPT_RegWriteContext(WINE_REGSTOREINFO *store, const void *context, DWORD dwFlags)
Definition: regstore.c:329

◆ CRYPT_RegWriteContext()

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

Definition at line 329 of file regstore.c.

331{
332 BOOL ret;
333
335 {
336 store->dirty = TRUE;
337 ret = TRUE;
338 }
339 else
340 ret = FALSE;
341 return ret;
342}
#define CERT_STORE_PROV_WRITE_ADD_FLAG
Definition: wincrypt.h:3118

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 406 of file regstore.c.

408{
409 WINE_REGSTOREINFO *store = hCertStore;
410
411 TRACE("(%p, %p, %ld)\n", hCertStore, crl, dwFlags);
412
413 return CRYPT_RegWriteContext(store, crl, dwFlags);
414}
static const BYTE crl[]
Definition: message.c:817

◆ CRYPT_RegWriteCTL()

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

Definition at line 427 of file regstore.c.

429{
430 WINE_REGSTOREINFO *store = hCertStore;
431
432 TRACE("(%p, %p, %ld)\n", hCertStore, ctl, dwFlags);
433
434 return CRYPT_RegWriteContext(store, ctl, dwFlags);
435}

◆ CRYPT_RegWriteToReg()

static BOOL CRYPT_RegWriteToReg ( WINE_REGSTOREINFO store)
static

Definition at line 240 of file regstore.c.

241{
242 static const WCHAR * const subKeys[] = { L"Certificates", L"CRLs", L"CTLs" };
243 const WINE_CONTEXT_INTERFACE * const interfaces[] = { pCertInterface,
245 struct list *listToDelete[] = { &store->certsToDelete, &store->crlsToDelete,
246 &store->ctlsToDelete };
247 BOOL ret = TRUE;
248 DWORD i;
249
250 for (i = 0; ret && i < ARRAY_SIZE(subKeys); i++)
251 {
252 HKEY key;
253 LONG rc = RegCreateKeyExW(store->key, subKeys[i], 0, NULL, 0,
255
256 if (!rc)
257 {
258 if (listToDelete[i])
259 {
260 WINE_HASH_TO_DELETE *toDelete, *next;
261 WCHAR asciiHash[20 * 2 + 1];
262
263 EnterCriticalSection(&store->cs);
264 LIST_FOR_EACH_ENTRY_SAFE(toDelete, next, listToDelete[i],
266 {
267 LONG rc;
268
269 CRYPT_HashToStr(toDelete->hash, asciiHash);
270 TRACE("Removing %s\n", debugstr_w(asciiHash));
271 rc = RegDeleteKeyW(key, asciiHash);
272 if (rc != ERROR_SUCCESS && rc != ERROR_FILE_NOT_FOUND)
273 {
274 SetLastError(rc);
275 ret = FALSE;
276 }
277 list_remove(&toDelete->entry);
278 CryptMemFree(toDelete);
279 }
280 LeaveCriticalSection(&store->cs);
281 }
282 ret = CRYPT_SerializeContextsToReg(key, 0, interfaces[i], store->memStore);
284 }
285 else
286 {
287 SetLastError(rc);
288 ret = FALSE;
289 }
290 }
291 return ret;
292}
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:200
#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 200 of file regstore.c.

202{
203 const void *context = NULL;
204 BOOL ret;
205
206 do {
207 context = contextInterface->enumContextsInStore(memStore, context);
208 if (context)
209 {
210 BYTE hash[20];
211 DWORD hashSize = sizeof(hash);
212
213 ret = contextInterface->getProp(context, CERT_HASH_PROP_ID, hash,
214 &hashSize);
215 if (ret)
216 {
217 DWORD size = 0;
218 LPBYTE buf = NULL;
219
220 ret = contextInterface->serialize(context, 0, NULL, &size);
221 if (size)
223 if (buf)
224 {
225 ret = contextInterface->serialize(context, 0, buf, &size);
226 if (ret)
228 }
230 }
231 }
232 else
233 ret = TRUE;
234 } while (ret && context != NULL);
235 if (context)
237 return ret;
238}
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:174
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 174 of file regstore.c.

176{
177 WCHAR asciiHash[20 * 2 + 1];
178 LONG rc;
179 HKEY subKey;
180 BOOL ret;
181
182 CRYPT_HashToStr(hash, asciiHash);
183 rc = RegCreateKeyExW(key, asciiHash, 0, NULL, flags, KEY_ALL_ACCESS, NULL,
184 &subKey, NULL);
185 if (!rc)
186 {
187 rc = RegSetValueExW(subKey, L"Blob", 0, REG_BINARY, buf, len);
188 RegCloseKey(subKey);
189 }
190 if (!rc)
191 ret = TRUE;
192 else
193 {
194 SetLastError(rc);
195 ret = FALSE;
196 }
197 return ret;
198}
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:1499

Referenced by CRYPT_SerializeContextsToReg().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( crypt  )

Variable Documentation

◆ 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:437
static BOOL WINAPI CRYPT_RegWriteCert(HCERTSTORE hCertStore, PCCERT_CONTEXT cert, DWORD dwFlags)
Definition: regstore.c:385
static BOOL WINAPI CRYPT_RegWriteCRL(HCERTSTORE hCertStore, PCCRL_CONTEXT crl, DWORD dwFlags)
Definition: regstore.c:406
static BOOL WINAPI CRYPT_RegWriteCTL(HCERTSTORE hCertStore, PCCTL_CONTEXT ctl, DWORD dwFlags)
Definition: regstore.c:427
static BOOL WINAPI CRYPT_RegDeleteCRL(HCERTSTORE hCertStore, PCCRL_CONTEXT pCrlContext, DWORD dwFlags)
Definition: regstore.c:416
static BOOL WINAPI CRYPT_RegControl(HCERTSTORE hCertStore, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
Definition: regstore.c:448
static void WINAPI CRYPT_RegCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: regstore.c:314
static BOOL WINAPI CRYPT_RegDeleteCert(HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwFlags)
Definition: regstore.c:395

Definition at line 487 of file regstore.c.

Referenced by CRYPT_RegOpenStore().