netstat: Initial implementation.
[wine] / dlls / crypt32 / crypt32_private.h
1 /*
2  * Copyright 2005 Juan Lang
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #ifndef __CRYPT32_PRIVATE_H__
20 #define __CRYPT32_PRIVATE_H__
21
22 /* a few asn.1 tags we need */
23 #define ASN_BOOL            (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
24 #define ASN_BITSTRING       (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
25 #define ASN_ENUMERATED      (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0a)
26 #define ASN_UTF8STRING      (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0c)
27 #define ASN_SETOF           (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11)
28 #define ASN_NUMERICSTRING   (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12)
29 #define ASN_PRINTABLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x13)
30 #define ASN_T61STRING       (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x14)
31 #define ASN_VIDEOTEXSTRING  (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x15)
32 #define ASN_IA5STRING       (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x16)
33 #define ASN_UTCTIME         (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x17)
34 #define ASN_GENERALTIME     (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x18)
35 #define ASN_GRAPHICSTRING   (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x19)
36 #define ASN_VISIBLESTRING   (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1a)
37 #define ASN_GENERALSTRING   (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1b)
38 #define ASN_UNIVERSALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1c)
39 #define ASN_BMPSTRING       (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1e)
40
41 BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
42
43 typedef BOOL (WINAPI *CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *,
44  DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *);
45
46 struct AsnEncodeSequenceItem
47 {
48     const void             *pvStructInfo;
49     CryptEncodeObjectExFunc encodeFunc;
50     DWORD                   size; /* used during encoding, not for your use */
51 };
52
53 BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType,
54  struct AsnEncodeSequenceItem items[], DWORD cItem, DWORD dwFlags,
55  PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
56
57 struct AsnConstructedItem
58 {
59     BYTE                    tag;
60     const void             *pvStructInfo;
61     CryptEncodeObjectExFunc encodeFunc;
62 };
63
64 BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType,
65  LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
66  PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
67 BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
68  LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
69  PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
70 BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType,
71  LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
72  PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
73
74 typedef struct _CRYPT_DIGESTED_DATA
75 {
76     DWORD                      version;
77     CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm;
78     CRYPT_CONTENT_INFO         ContentInfo;
79     CRYPT_HASH_BLOB            hash;
80 } CRYPT_DIGESTED_DATA;
81
82 BOOL CRYPT_AsnEncodePKCSDigestedData(const CRYPT_DIGESTED_DATA *digestedData,
83  void *pvData, DWORD *pcbData) DECLSPEC_HIDDEN;
84
85 typedef struct _CRYPT_ENCRYPTED_CONTENT_INFO
86 {
87     LPSTR                      contentType;
88     CRYPT_ALGORITHM_IDENTIFIER contentEncryptionAlgorithm;
89     CRYPT_DATA_BLOB            encryptedContent;
90 } CRYPT_ENCRYPTED_CONTENT_INFO;
91
92 typedef struct _CRYPT_ENVELOPED_DATA
93 {
94     DWORD                          version;
95     DWORD                          cRecipientInfo;
96     PCMSG_KEY_TRANS_RECIPIENT_INFO rgRecipientInfo;
97     CRYPT_ENCRYPTED_CONTENT_INFO   encryptedContentInfo;
98 } CRYPT_ENVELOPED_DATA;
99
100 BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData,
101  void *pvData, DWORD *pcbData) DECLSPEC_HIDDEN;
102
103 BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded,
104  DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
105  CRYPT_ENVELOPED_DATA *envelopedData, DWORD *pcbEnvelopedData) DECLSPEC_HIDDEN;
106
107 typedef struct _CRYPT_SIGNED_INFO
108 {
109     DWORD                 version;
110     DWORD                 cCertEncoded;
111     PCERT_BLOB            rgCertEncoded;
112     DWORD                 cCrlEncoded;
113     PCRL_BLOB             rgCrlEncoded;
114     CRYPT_CONTENT_INFO    content;
115     DWORD                 cSignerInfo;
116     PCMSG_CMS_SIGNER_INFO rgSignerInfo;
117 } CRYPT_SIGNED_INFO;
118
119 BOOL CRYPT_AsnEncodeCMSSignedInfo(CRYPT_SIGNED_INFO *, void *pvData,
120  DWORD *pcbData) DECLSPEC_HIDDEN;
121
122 BOOL CRYPT_AsnDecodeCMSSignedInfo(const BYTE *pbEncoded, DWORD cbEncoded,
123  DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
124  CRYPT_SIGNED_INFO *signedInfo, DWORD *pcbSignedInfo) DECLSPEC_HIDDEN;
125
126 /* Helper function to check *pcbEncoded, set it to the required size, and
127  * optionally to allocate memory.  Assumes pbEncoded is not NULL.
128  * If CRYPT_ENCODE_ALLOC_FLAG is set in dwFlags, *pbEncoded will be set to a
129  * pointer to the newly allocated memory.
130  */
131 BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara,
132  BYTE *pbEncoded, DWORD *pcbEncoded, DWORD bytesNeeded) DECLSPEC_HIDDEN;
133
134 BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded,
135  DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
136  CRYPT_DIGESTED_DATA *digestedData, DWORD *pcbDigestedData) DECLSPEC_HIDDEN;
137
138 BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType,
139  LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
140  PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
141
142 /* The following aren't defined in wincrypt.h, as they're "reserved" */
143 #define CERT_CERT_PROP_ID 32
144 #define CERT_CRL_PROP_ID  33
145 #define CERT_CTL_PROP_ID  34
146
147 /* Returns a handle to the default crypto provider; loads it if necessary.
148  * Returns NULL on failure.
149  */
150 HCRYPTPROV CRYPT_GetDefaultProvider(void) DECLSPEC_HIDDEN;
151
152 HINSTANCE hInstance DECLSPEC_HIDDEN;
153
154 void crypt_oid_init(void) DECLSPEC_HIDDEN;
155 void crypt_oid_free(void) DECLSPEC_HIDDEN;
156 void crypt_sip_free(void) DECLSPEC_HIDDEN;
157 void root_store_free(void) DECLSPEC_HIDDEN;
158 void default_chain_engine_free(void) DECLSPEC_HIDDEN;
159
160 /* Some typedefs that make it easier to abstract which type of context we're
161  * working with.
162  */
163 typedef const void *(WINAPI *CreateContextFunc)(DWORD dwCertEncodingType,
164  const BYTE *pbCertEncoded, DWORD cbCertEncoded);
165 typedef BOOL (WINAPI *AddContextToStoreFunc)(HCERTSTORE hCertStore,
166  const void *context, DWORD dwAddDisposition, const void **ppStoreContext);
167 typedef BOOL (WINAPI *AddEncodedContextToStoreFunc)(HCERTSTORE hCertStore,
168  DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded,
169  DWORD dwAddDisposition, const void **ppContext);
170 typedef const void *(WINAPI *DuplicateContextFunc)(const void *context);
171 typedef const void *(WINAPI *EnumContextsInStoreFunc)(HCERTSTORE hCertStore,
172  const void *pPrevContext);
173 typedef DWORD (WINAPI *EnumPropertiesFunc)(const void *context, DWORD dwPropId);
174 typedef BOOL (WINAPI *GetContextPropertyFunc)(const void *context,
175  DWORD dwPropID, void *pvData, DWORD *pcbData);
176 typedef BOOL (WINAPI *SetContextPropertyFunc)(const void *context,
177  DWORD dwPropID, DWORD dwFlags, const void *pvData);
178 typedef BOOL (WINAPI *SerializeElementFunc)(const void *context, DWORD dwFlags,
179  BYTE *pbElement, DWORD *pcbElement);
180 typedef BOOL (WINAPI *FreeContextFunc)(const void *context);
181 typedef BOOL (WINAPI *DeleteContextFunc)(const void *contex);
182
183 /* An abstract context (certificate, CRL, or CTL) interface */
184 typedef struct _WINE_CONTEXT_INTERFACE
185 {
186     CreateContextFunc            create;
187     AddContextToStoreFunc        addContextToStore;
188     AddEncodedContextToStoreFunc addEncodedToStore;
189     DuplicateContextFunc         duplicate;
190     EnumContextsInStoreFunc      enumContextsInStore;
191     EnumPropertiesFunc           enumProps;
192     GetContextPropertyFunc       getProp;
193     SetContextPropertyFunc       setProp;
194     SerializeElementFunc         serialize;
195     FreeContextFunc              free;
196     DeleteContextFunc            deleteFromStore;
197 } WINE_CONTEXT_INTERFACE, *PWINE_CONTEXT_INTERFACE;
198 typedef const WINE_CONTEXT_INTERFACE *PCWINE_CONTEXT_INTERFACE;
199
200 extern PCWINE_CONTEXT_INTERFACE pCertInterface DECLSPEC_HIDDEN;
201 extern PCWINE_CONTEXT_INTERFACE pCRLInterface DECLSPEC_HIDDEN;
202 extern PCWINE_CONTEXT_INTERFACE pCTLInterface DECLSPEC_HIDDEN;
203
204 /* (Internal) certificate store types and functions */
205 struct WINE_CRYPTCERTSTORE;
206
207 typedef struct WINE_CRYPTCERTSTORE * (*StoreOpenFunc)(HCRYPTPROV hCryptProv,
208  DWORD dwFlags, const void *pvPara);
209
210 /* Called to enumerate the next context in a store. */
211 typedef void * (*EnumFunc)(struct WINE_CRYPTCERTSTORE *store, void *pPrev);
212
213 /* Called to add a context to a store.  If toReplace is not NULL,
214  * context replaces toReplace in the store, and access checks should not be
215  * performed.  Otherwise context is a new context, and it should only be
216  * added if the store allows it.  If ppStoreContext is not NULL, the added
217  * context should be returned in *ppStoreContext.
218  */
219 typedef BOOL (*AddFunc)(struct WINE_CRYPTCERTSTORE *store, void *context,
220  void *toReplace, const void **ppStoreContext);
221
222 typedef BOOL (*DeleteFunc)(struct WINE_CRYPTCERTSTORE *store, void *context);
223
224 typedef struct _CONTEXT_FUNCS
225 {
226     AddFunc    addContext;
227     EnumFunc   enumContext;
228     DeleteFunc deleteContext;
229 } CONTEXT_FUNCS, *PCONTEXT_FUNCS;
230
231 typedef enum _CertStoreType {
232     StoreTypeMem,
233     StoreTypeCollection,
234     StoreTypeProvider,
235 } CertStoreType;
236
237 struct _CONTEXT_PROPERTY_LIST;
238 typedef struct _CONTEXT_PROPERTY_LIST *PCONTEXT_PROPERTY_LIST;
239
240 #define WINE_CRYPTCERTSTORE_MAGIC 0x74726563
241
242 /* A cert store is polymorphic through the use of function pointers.  A type
243  * is still needed to distinguish collection stores from other types.
244  * On the function pointers:
245  * - closeStore is called when the store's ref count becomes 0
246  * - control is optional, but should be implemented by any store that supports
247  *   persistence
248  */
249 typedef struct WINE_CRYPTCERTSTORE
250 {
251     DWORD                       dwMagic;
252     LONG                        ref;
253     DWORD                       dwOpenFlags;
254     CertStoreType               type;
255     PFN_CERT_STORE_PROV_CLOSE   closeStore;
256     CONTEXT_FUNCS               certs;
257     CONTEXT_FUNCS               crls;
258     CONTEXT_FUNCS               ctls;
259     PFN_CERT_STORE_PROV_CONTROL control; /* optional */
260     PCONTEXT_PROPERTY_LIST      properties;
261 } WINECRYPT_CERTSTORE, *PWINECRYPT_CERTSTORE;
262
263 void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
264  CertStoreType type) DECLSPEC_HIDDEN;
265 void CRYPT_FreeStore(PWINECRYPT_CERTSTORE store) DECLSPEC_HIDDEN;
266 BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
267  DWORD unk1) DECLSPEC_HIDDEN;
268
269 PWINECRYPT_CERTSTORE CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
270  DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
271 PWINECRYPT_CERTSTORE CRYPT_ProvCreateStore(DWORD dwFlags,
272  PWINECRYPT_CERTSTORE memStore, const CERT_STORE_PROV_INFO *pProvInfo) DECLSPEC_HIDDEN;
273 PWINECRYPT_CERTSTORE CRYPT_ProvOpenStore(LPCSTR lpszStoreProvider,
274  DWORD dwEncodingType, HCRYPTPROV hCryptProv, DWORD dwFlags,
275  const void *pvPara) DECLSPEC_HIDDEN;
276 PWINECRYPT_CERTSTORE CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
277  const void *pvPara) DECLSPEC_HIDDEN;
278 PWINECRYPT_CERTSTORE CRYPT_FileOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
279  const void *pvPara) DECLSPEC_HIDDEN;
280 PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreA(HCRYPTPROV hCryptProv,
281  DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
282 PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
283  DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
284 PWINECRYPT_CERTSTORE CRYPT_RootOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags) DECLSPEC_HIDDEN;
285
286 /* Allocates and initializes a certificate chain engine, but without creating
287  * the root store.  Instead, it uses root, and assumes the caller has done any
288  * checking necessary.
289  */
290 HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root,
291  PCERT_CHAIN_ENGINE_CONFIG pConfig) DECLSPEC_HIDDEN;
292
293 /* Helper function for store reading functions and
294  * CertAddSerializedElementToStore.  Returns a context of the appropriate type
295  * if it can, or NULL otherwise.  Doesn't validate any of the properties in
296  * the serialized context (for example, bad hashes are retained.)
297  * *pdwContentType is set to the type of the returned context.
298  */
299 const void *CRYPT_ReadSerializedElement(const BYTE *pbElement,
300  DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType) DECLSPEC_HIDDEN;
301
302 /* Reads contexts serialized in the file into the memory store.  Returns FALSE
303  * if the file is not of the expected format.
304  */
305 BOOL CRYPT_ReadSerializedStoreFromFile(HANDLE file, HCERTSTORE store) DECLSPEC_HIDDEN;
306
307 /* Reads contexts serialized in the blob into the memory store.  Returns FALSE
308  * if the file is not of the expected format.
309  */
310 BOOL CRYPT_ReadSerializedStoreFromBlob(const CRYPT_DATA_BLOB *blob,
311  HCERTSTORE store) DECLSPEC_HIDDEN;
312
313 /* Fixes up the pointers in info, where info is assumed to be a
314  * CRYPT_KEY_PROV_INFO, followed by its container name, provider name, and any
315  * provider parameters, in a contiguous buffer, but where info's pointers are
316  * assumed to be invalid.  Upon return, info's pointers point to the
317  * appropriate memory locations.
318  */
319 void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info) DECLSPEC_HIDDEN;
320
321 /**
322  *  String functions
323  */
324
325 DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indent,
326  const CERT_NAME_BLOB *pName, DWORD dwStrType, LPWSTR psz, DWORD csz) DECLSPEC_HIDDEN;
327
328 /**
329  *  Context functions
330  */
331
332 /* Allocates a new data context, a context which owns properties directly.
333  * contextSize is the size of the public data type associated with context,
334  * which should be one of CERT_CONTEXT, CRL_CONTEXT, or CTL_CONTEXT.
335  * Free with Context_Release.
336  */
337 void *Context_CreateDataContext(size_t contextSize) DECLSPEC_HIDDEN;
338
339 /* Creates a new link context with extra bytes.  The context refers to linked
340  * rather than owning its own properties.  If addRef is TRUE (which ordinarily
341  * it should be) linked is addref'd.
342  * Free with Context_Release.
343  */
344 void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned int extra,
345  BOOL addRef) DECLSPEC_HIDDEN;
346
347 /* Returns a pointer to the extra bytes allocated with context, which must be
348  * a link context.
349  */
350 void *Context_GetExtra(const void *context, size_t contextSize) DECLSPEC_HIDDEN;
351
352 /* Gets the context linked to by context, which must be a link context. */
353 void *Context_GetLinkedContext(void *context, size_t contextSize) DECLSPEC_HIDDEN;
354
355 /* Copies properties from fromContext to toContext. */
356 void Context_CopyProperties(const void *to, const void *from,
357  size_t contextSize) DECLSPEC_HIDDEN;
358
359 /* Returns context's properties, or the linked context's properties if context
360  * is a link context.
361  */
362 PCONTEXT_PROPERTY_LIST Context_GetProperties(const void *context, size_t contextSize) DECLSPEC_HIDDEN;
363
364 void Context_AddRef(void *context, size_t contextSize) DECLSPEC_HIDDEN;
365
366 typedef void (*ContextFreeFunc)(void *context);
367
368 /* Decrements context's ref count.  If context is a link context, releases its
369  * linked context as well.
370  * If a data context has its ref count reach 0, calls dataContextFree on it.
371  * Returns FALSE if the reference count is <= 0 when called.
372  */
373 BOOL Context_Release(void *context, size_t contextSize,
374  ContextFreeFunc dataContextFree) DECLSPEC_HIDDEN;
375
376 /**
377  *  Context property list functions
378  */
379
380 PCONTEXT_PROPERTY_LIST ContextPropertyList_Create(void) DECLSPEC_HIDDEN;
381
382 /* Searches for the property with ID id in the context.  Returns TRUE if found,
383  * and copies the property's length and a pointer to its data to blob.
384  * Otherwise returns FALSE.
385  */
386 BOOL ContextPropertyList_FindProperty(PCONTEXT_PROPERTY_LIST list, DWORD id,
387  PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN;
388
389 BOOL ContextPropertyList_SetProperty(PCONTEXT_PROPERTY_LIST list, DWORD id,
390  const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN;
391
392 void ContextPropertyList_RemoveProperty(PCONTEXT_PROPERTY_LIST list, DWORD id) DECLSPEC_HIDDEN;
393
394 DWORD ContextPropertyList_EnumPropIDs(PCONTEXT_PROPERTY_LIST list, DWORD id) DECLSPEC_HIDDEN;
395
396 void ContextPropertyList_Copy(PCONTEXT_PROPERTY_LIST to,
397  PCONTEXT_PROPERTY_LIST from) DECLSPEC_HIDDEN;
398
399 void ContextPropertyList_Free(PCONTEXT_PROPERTY_LIST list) DECLSPEC_HIDDEN;
400
401 /**
402  *  Context list functions.  A context list is a simple list of link contexts.
403  */
404 struct ContextList;
405
406 struct ContextList *ContextList_Create(
407  PCWINE_CONTEXT_INTERFACE contextInterface, size_t contextSize) DECLSPEC_HIDDEN;
408
409 void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) DECLSPEC_HIDDEN;
410
411 void *ContextList_Enum(struct ContextList *list, void *pPrev) DECLSPEC_HIDDEN;
412
413 /* Removes a context from the list.  Returns TRUE if the context was removed,
414  * or FALSE if not.  (The context may have been duplicated, so subsequent
415  * removes have no effect.)
416  */
417 BOOL ContextList_Remove(struct ContextList *list, void *context) DECLSPEC_HIDDEN;
418
419 void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN;
420
421 /**
422  *  Utilities.
423  */
424
425 /* Align up to a DWORD_PTR boundary
426  */
427 #define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1))
428 #define POINTER_ALIGN_DWORD_PTR(p) ((LPVOID)ALIGN_DWORD_PTR((DWORD_PTR)(p)))
429
430 /* Check if the OID is a small int
431  */
432 #define IS_INTOID(x)    (((ULONG_PTR)(x) >> 16) == 0)
433
434 #endif