ReactOS  0.4.13-dev-257-gfabbd7c
context.c File Reference
#include <assert.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "wine/debug.h"
#include "crypt32_private.h"
Include dependency graph for context.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (context)
 
context_tContext_CreateDataContext (size_t contextSize, const context_vtbl_t *vtbl, WINECRYPT_CERTSTORE *store)
 
context_tContext_CreateLinkContext (unsigned int contextSize, context_t *linked, WINECRYPT_CERTSTORE *store)
 
void Context_AddRef (context_t *context)
 
void Context_Free (context_t *context)
 
void Context_Release (context_t *context)
 
void Context_CopyProperties (const void *to, const void *from)
 

Function Documentation

◆ Context_AddRef()

void Context_AddRef ( context_t context)

Definition at line 78 of file context.c.

79 {
81 
82  TRACE("(%p) ref=%d\n", context, context->ref);
83 
84  if(ref == 1) {
85  /* This is the first external (non-store) reference. Increase store ref cnt. */
86  context->store->vtbl->addref(context->store);
87  }
88 }
Definition: http.c:6587
Definition: send.c:47
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by CertDuplicateCertificateContext(), CertDuplicateCRLContext(), CertDuplicateCTLContext(), Context_CreateLinkContext(), CRYPT_CollectionAdvanceEnum(), CRYPT_QuerySerializedContextObject(), EmptyStore_add(), and MemStore_enumContext().

◆ Context_CopyProperties()

void Context_CopyProperties ( const void to,
const void from 
)

Definition at line 123 of file context.c.

124 {
125  CONTEXT_PROPERTY_LIST *toProperties, *fromProperties;
126 
127  toProperties = context_from_ptr(to)->properties;
128  fromProperties = context_from_ptr(from)->properties;
129  assert(toProperties && fromProperties);
130  ContextPropertyList_Copy(toProperties, fromProperties);
131 }
static context_t * context_from_ptr(const void *ptr)
#define assert(x)
Definition: debug.h:53
CONTEXT_PROPERTY_LIST * properties
void ContextPropertyList_Copy(CONTEXT_PROPERTY_LIST *to, CONTEXT_PROPERTY_LIST *from) DECLSPEC_HIDDEN
Definition: proplist.c:207
CardRegion * from
Definition: spigame.cpp:19

Referenced by add_cert_to_store(), Cert_clone(), CertAddCRLContextToStore(), CertAddCTLContextToStore(), and CRL_clone().

◆ Context_CreateDataContext()

context_t* Context_CreateDataContext ( size_t  contextSize,
const context_vtbl_t vtbl,
struct WINE_CRYPTCERTSTORE  
)

Context functions

Definition at line 28 of file context.c.

29 {
31 
32  context = CryptMemAlloc(sizeof(context_t) + contextSize);
33  if (!context)
34  return NULL;
35 
36  context->properties = ContextPropertyList_Create();
37  if (!context->properties)
38  {
40  return NULL;
41  }
42 
43  context->vtbl = vtbl;
44  context->ref = 1;
45  context->linked = NULL;
46 
47  store->vtbl->addref(store);
48  context->store = store;
49 
50  TRACE("returning %p\n", context);
51  return context;
52 }
Definition: http.c:6587
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
void(* addref)(struct WINE_CRYPTCERTSTORE *)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
const store_vtbl_t * vtbl
CONTEXT_PROPERTY_LIST * ContextPropertyList_Create(void) DECLSPEC_HIDDEN
Definition: proplist.c:43
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141

Referenced by Cert_clone(), CertCreateCertificateContext(), CertCreateCRLContext(), CertCreateCTLContext(), and CRL_clone().

◆ Context_CreateLinkContext()

context_t* Context_CreateLinkContext ( unsigned int  contextSize,
context_t linked,
WINECRYPT_CERTSTORE store 
)

Definition at line 54 of file context.c.

55 {
57 
58  TRACE("(%d, %p)\n", contextSize, linked);
59 
60  context = CryptMemAlloc(sizeof(context_t) + contextSize);
61  if (!context)
62  return NULL;
63 
64  memcpy(context_ptr(context), context_ptr(linked), contextSize);
65  context->vtbl = linked->vtbl;
66  context->ref = 1;
67  context->linked = linked;
68  context->properties = linked->properties;
69  Context_AddRef(linked);
70 
71  store->vtbl->addref(store);
72  context->store = store;
73 
74  TRACE("returning %p\n", context);
75  return context;
76 }
Definition: http.c:6587
const context_vtbl_t * vtbl
void Context_AddRef(context_t *context)
Definition: context.c:78
static void * context_ptr(context_t *context)
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
void(* addref)(struct WINE_CRYPTCERTSTORE *)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
const store_vtbl_t * vtbl
CONTEXT_PROPERTY_LIST * properties
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by Cert_clone(), CRL_clone(), and CTL_clone().

◆ Context_Free()

void Context_Free ( context_t context)

Definition at line 90 of file context.c.

91 {
92  TRACE("(%p)\n", context);
93 
94  assert(!context->ref);
95 
96  if (!context->linked) {
97  ContextPropertyList_Free(context->properties);
98  context->vtbl->free(context);
99  }else {
100  Context_Release(context->linked);
101  }
102 
104 }
Definition: http.c:6587
#define assert(x)
Definition: debug.h:53
void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN
Definition: proplist.c:56
void Context_Release(context_t *context)
Definition: context.c:106
#define TRACE(s)
Definition: solgame.cpp:4
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141

Referenced by Collection_releaseContext(), EmptyStore_releaseContext(), free_contexts(), MemStore_deleteContext(), and MemStore_releaseContext().

◆ Context_Release()

void Context_Release ( context_t context)

Definition at line 106 of file context.c.

107 {
109 
110  TRACE("(%p) ref=%d\n", context, ref);
111  assert(ref >= 0);
112 
113  if (!ref) {
114  WINECRYPT_CERTSTORE *store = context->store;
115 
116  /* This is the last reference, but the context still may be in a store.
117  * We release our store reference, but leave it up to store to free or keep the context. */
118  store->vtbl->releaseContext(store, context);
119  store->vtbl->release(store, 0);
120  }
121 }
Definition: http.c:6587
#define assert(x)
Definition: debug.h:53
Definition: send.c:47
long LONG
Definition: pedump.c:60
DWORD(* release)(struct WINE_CRYPTCERTSTORE *, DWORD)
#define TRACE(s)
Definition: solgame.cpp:4
const store_vtbl_t * vtbl
#define InterlockedDecrement
Definition: armddk.h:52
void(* releaseContext)(struct WINE_CRYPTCERTSTORE *, context_t *)

Referenced by add_cert_to_store(), CertAddSerializedElementToStore(), CertCreateCertificateContext(), CertCreateCRLContext(), CertCreateCTLContext(), CertFreeCertificateContext(), CertFreeCRLContext(), CertFreeCTLContext(), Collection_addCert(), Collection_addCRL(), Collection_addCTL(), Context_Free(), CRYPT_CollectionAdvanceEnum(), CRYPT_QuerySerializedContextObject(), CRYPT_ReadSerializedElement(), CRYPT_ReadSerializedStore(), CRYPT_RegReadSerializedFromReg(), CRYPT_SerializeContextsToReg(), CRYPT_SerializeContextsToStream(), MemStore_addContext(), and MemStore_enumContext().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( context  )