2 * Copyright 2005 Juan Lang
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.
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.
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
19 #ifndef __CRYPT32_PRIVATE_H__
20 #define __CRYPT32_PRIVATE_H__
23 #include <wine/port.h>
30 #define COM_NO_WINDOWS_H
32 #define NONAMELESSUNION
40 #define CERT_CHAIN_PARA_HAS_EXTRA_FIELDS
41 #define CERT_REVOCATION_PARA_HAS_EXTRA_FIELDS
46 #include <wine/unicode.h>
47 #include <wine/list.h>
48 #include <wine/exception.h>
49 #include <wine/debug.h>
51 /* a few asn.1 tags we need */
52 #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
53 #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
54 #define ASN_ENUMERATED (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0a)
55 #define ASN_UTF8STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0c)
56 #define ASN_SETOF (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11)
57 #define ASN_NUMERICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12)
58 #define ASN_PRINTABLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x13)
59 #define ASN_T61STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x14)
60 #define ASN_VIDEOTEXSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x15)
61 #define ASN_IA5STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x16)
62 #define ASN_UTCTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x17)
63 #define ASN_GENERALTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x18)
64 #define ASN_GRAPHICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x19)
65 #define ASN_VISIBLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1a)
66 #define ASN_GENERALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1b)
67 #define ASN_UNIVERSALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1c)
68 #define ASN_BMPSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1e)
70 BOOL
CRYPT_EncodeLen(DWORD len
, BYTE
*pbEncoded
, DWORD
*pcbEncoded
) DECLSPEC_HIDDEN
;
72 typedef BOOL (WINAPI
*CryptEncodeObjectExFunc
)(DWORD
, LPCSTR
, const void *,
73 DWORD
, PCRYPT_ENCODE_PARA
, BYTE
*, DWORD
*);
75 struct AsnEncodeSequenceItem
77 const void *pvStructInfo
;
78 CryptEncodeObjectExFunc encodeFunc
;
79 DWORD size
; /* used during encoding, not for your use */
82 BOOL WINAPI
CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType
,
83 struct AsnEncodeSequenceItem items
[], DWORD cItem
, DWORD dwFlags
,
84 PCRYPT_ENCODE_PARA pEncodePara
, BYTE
*pbEncoded
, DWORD
*pcbEncoded
) DECLSPEC_HIDDEN
;
86 struct AsnConstructedItem
89 const void *pvStructInfo
;
90 CryptEncodeObjectExFunc encodeFunc
;
93 BOOL WINAPI
CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType
,
94 LPCSTR lpszStructType
, const void *pvStructInfo
, DWORD dwFlags
,
95 PCRYPT_ENCODE_PARA pEncodePara
, BYTE
*pbEncoded
, DWORD
*pcbEncoded
) DECLSPEC_HIDDEN
;
96 BOOL WINAPI
CRYPT_AsnEncodeOid(DWORD dwCertEncodingType
,
97 LPCSTR lpszStructType
, const void *pvStructInfo
, DWORD dwFlags
,
98 PCRYPT_ENCODE_PARA pEncodePara
, BYTE
*pbEncoded
, DWORD
*pcbEncoded
) DECLSPEC_HIDDEN
;
99 BOOL WINAPI
CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType
,
100 LPCSTR lpszStructType
, const void *pvStructInfo
, DWORD dwFlags
,
101 PCRYPT_ENCODE_PARA pEncodePara
, BYTE
*pbEncoded
, DWORD
*pcbEncoded
) DECLSPEC_HIDDEN
;
103 typedef struct _CRYPT_DIGESTED_DATA
106 CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm
;
107 CRYPT_CONTENT_INFO ContentInfo
;
108 CRYPT_HASH_BLOB hash
;
109 } CRYPT_DIGESTED_DATA
;
111 BOOL
CRYPT_AsnEncodePKCSDigestedData(const CRYPT_DIGESTED_DATA
*digestedData
,
112 void *pvData
, DWORD
*pcbData
) DECLSPEC_HIDDEN
;
114 typedef struct _CRYPT_ENCRYPTED_CONTENT_INFO
117 CRYPT_ALGORITHM_IDENTIFIER contentEncryptionAlgorithm
;
118 CRYPT_DATA_BLOB encryptedContent
;
119 } CRYPT_ENCRYPTED_CONTENT_INFO
;
121 typedef struct _CRYPT_ENVELOPED_DATA
124 DWORD cRecipientInfo
;
125 PCMSG_KEY_TRANS_RECIPIENT_INFO rgRecipientInfo
;
126 CRYPT_ENCRYPTED_CONTENT_INFO encryptedContentInfo
;
127 } CRYPT_ENVELOPED_DATA
;
129 BOOL
CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA
*envelopedData
,
130 void *pvData
, DWORD
*pcbData
) DECLSPEC_HIDDEN
;
132 BOOL
CRYPT_AsnDecodePKCSEnvelopedData(const BYTE
*pbEncoded
, DWORD cbEncoded
,
133 DWORD dwFlags
, PCRYPT_DECODE_PARA pDecodePara
,
134 CRYPT_ENVELOPED_DATA
*envelopedData
, DWORD
*pcbEnvelopedData
) DECLSPEC_HIDDEN
;
136 typedef struct _CRYPT_SIGNED_INFO
140 PCERT_BLOB rgCertEncoded
;
142 PCRL_BLOB rgCrlEncoded
;
143 CRYPT_CONTENT_INFO content
;
145 PCMSG_CMS_SIGNER_INFO rgSignerInfo
;
148 BOOL
CRYPT_AsnEncodeCMSSignedInfo(CRYPT_SIGNED_INFO
*, void *pvData
,
149 DWORD
*pcbData
) DECLSPEC_HIDDEN
;
151 BOOL
CRYPT_AsnDecodeCMSSignedInfo(const BYTE
*pbEncoded
, DWORD cbEncoded
,
152 DWORD dwFlags
, PCRYPT_DECODE_PARA pDecodePara
,
153 CRYPT_SIGNED_INFO
*signedInfo
, DWORD
*pcbSignedInfo
) DECLSPEC_HIDDEN
;
155 /* Helper function to check *pcbEncoded, set it to the required size, and
156 * optionally to allocate memory. Assumes pbEncoded is not NULL.
157 * If CRYPT_ENCODE_ALLOC_FLAG is set in dwFlags, *pbEncoded will be set to a
158 * pointer to the newly allocated memory.
160 BOOL
CRYPT_EncodeEnsureSpace(DWORD dwFlags
, const CRYPT_ENCODE_PARA
*pEncodePara
,
161 BYTE
*pbEncoded
, DWORD
*pcbEncoded
, DWORD bytesNeeded
) DECLSPEC_HIDDEN
;
163 BOOL
CRYPT_AsnDecodePKCSDigestedData(const BYTE
*pbEncoded
, DWORD cbEncoded
,
164 DWORD dwFlags
, PCRYPT_DECODE_PARA pDecodePara
,
165 CRYPT_DIGESTED_DATA
*digestedData
, DWORD
*pcbDigestedData
) DECLSPEC_HIDDEN
;
167 BOOL WINAPI
CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType
,
168 LPCSTR lpszStructType
, const void *pvStructInfo
, DWORD dwFlags
,
169 PCRYPT_ENCODE_PARA pEncodePara
, BYTE
*pbEncoded
, DWORD
*pcbEncoded
) DECLSPEC_HIDDEN
;
171 /* The following aren't defined in wincrypt.h, as they're "reserved" */
172 #define CERT_CERT_PROP_ID 32
173 #define CERT_CRL_PROP_ID 33
174 #define CERT_CTL_PROP_ID 34
176 /* Returns a handle to the default crypto provider; loads it if necessary.
177 * Returns NULL on failure.
179 HCRYPTPROV
CRYPT_GetDefaultProvider(void) DECLSPEC_HIDDEN
;
181 HINSTANCE hInstance DECLSPEC_HIDDEN
;
183 void crypt_oid_init(void) DECLSPEC_HIDDEN
;
184 void crypt_oid_free(void) DECLSPEC_HIDDEN
;
185 void crypt_sip_free(void) DECLSPEC_HIDDEN
;
186 void root_store_free(void) DECLSPEC_HIDDEN
;
187 void default_chain_engine_free(void) DECLSPEC_HIDDEN
;
189 /* Some typedefs that make it easier to abstract which type of context we're
192 typedef const void *(WINAPI
*CreateContextFunc
)(DWORD dwCertEncodingType
,
193 const BYTE
*pbCertEncoded
, DWORD cbCertEncoded
);
194 typedef BOOL (WINAPI
*AddContextToStoreFunc
)(HCERTSTORE hCertStore
,
195 const void *context
, DWORD dwAddDisposition
, const void **ppStoreContext
);
196 typedef BOOL (WINAPI
*AddEncodedContextToStoreFunc
)(HCERTSTORE hCertStore
,
197 DWORD dwCertEncodingType
, const BYTE
*pbEncoded
, DWORD cbEncoded
,
198 DWORD dwAddDisposition
, const void **ppContext
);
199 typedef const void *(WINAPI
*DuplicateContextFunc
)(const void *context
);
200 typedef const void *(WINAPI
*EnumContextsInStoreFunc
)(HCERTSTORE hCertStore
,
201 const void *pPrevContext
);
202 typedef DWORD (WINAPI
*EnumPropertiesFunc
)(const void *context
, DWORD dwPropId
);
203 typedef BOOL (WINAPI
*GetContextPropertyFunc
)(const void *context
,
204 DWORD dwPropID
, void *pvData
, DWORD
*pcbData
);
205 typedef BOOL (WINAPI
*SetContextPropertyFunc
)(const void *context
,
206 DWORD dwPropID
, DWORD dwFlags
, const void *pvData
);
207 typedef BOOL (WINAPI
*SerializeElementFunc
)(const void *context
, DWORD dwFlags
,
208 BYTE
*pbElement
, DWORD
*pcbElement
);
209 typedef BOOL (WINAPI
*FreeContextFunc
)(const void *context
);
210 typedef BOOL (WINAPI
*DeleteContextFunc
)(const void *contex
);
212 /* An abstract context (certificate, CRL, or CTL) interface */
213 typedef struct _WINE_CONTEXT_INTERFACE
215 CreateContextFunc create
;
216 AddContextToStoreFunc addContextToStore
;
217 AddEncodedContextToStoreFunc addEncodedToStore
;
218 DuplicateContextFunc duplicate
;
219 EnumContextsInStoreFunc enumContextsInStore
;
220 EnumPropertiesFunc enumProps
;
221 GetContextPropertyFunc getProp
;
222 SetContextPropertyFunc setProp
;
223 SerializeElementFunc serialize
;
224 FreeContextFunc free
;
225 DeleteContextFunc deleteFromStore
;
226 } WINE_CONTEXT_INTERFACE
, *PWINE_CONTEXT_INTERFACE
;
227 typedef const WINE_CONTEXT_INTERFACE
*PCWINE_CONTEXT_INTERFACE
;
229 extern PCWINE_CONTEXT_INTERFACE pCertInterface DECLSPEC_HIDDEN
;
230 extern PCWINE_CONTEXT_INTERFACE pCRLInterface DECLSPEC_HIDDEN
;
231 extern PCWINE_CONTEXT_INTERFACE pCTLInterface DECLSPEC_HIDDEN
;
233 /* (Internal) certificate store types and functions */
234 struct WINE_CRYPTCERTSTORE
;
236 typedef struct WINE_CRYPTCERTSTORE
* (*StoreOpenFunc
)(HCRYPTPROV hCryptProv
,
237 DWORD dwFlags
, const void *pvPara
);
239 /* Called to enumerate the next context in a store. */
240 typedef void * (*EnumFunc
)(struct WINE_CRYPTCERTSTORE
*store
, void *pPrev
);
242 /* Called to add a context to a store. If toReplace is not NULL,
243 * context replaces toReplace in the store, and access checks should not be
244 * performed. Otherwise context is a new context, and it should only be
245 * added if the store allows it. If ppStoreContext is not NULL, the added
246 * context should be returned in *ppStoreContext.
248 typedef BOOL (*AddFunc
)(struct WINE_CRYPTCERTSTORE
*store
, void *context
,
249 void *toReplace
, const void **ppStoreContext
);
251 typedef BOOL (*DeleteFunc
)(struct WINE_CRYPTCERTSTORE
*store
, void *context
);
253 typedef struct _CONTEXT_FUNCS
256 EnumFunc enumContext
;
257 DeleteFunc deleteContext
;
258 } CONTEXT_FUNCS
, *PCONTEXT_FUNCS
;
260 typedef enum _CertStoreType
{
266 struct _CONTEXT_PROPERTY_LIST
;
267 typedef struct _CONTEXT_PROPERTY_LIST
*PCONTEXT_PROPERTY_LIST
;
269 #define WINE_CRYPTCERTSTORE_MAGIC 0x74726563
271 /* A cert store is polymorphic through the use of function pointers. A type
272 * is still needed to distinguish collection stores from other types.
273 * On the function pointers:
274 * - closeStore is called when the store's ref count becomes 0
275 * - control is optional, but should be implemented by any store that supports
278 typedef struct WINE_CRYPTCERTSTORE
284 PFN_CERT_STORE_PROV_CLOSE closeStore
;
288 PFN_CERT_STORE_PROV_CONTROL control
; /* optional */
289 PCONTEXT_PROPERTY_LIST properties
;
290 } WINECRYPT_CERTSTORE
, *PWINECRYPT_CERTSTORE
;
292 void CRYPT_InitStore(WINECRYPT_CERTSTORE
*store
, DWORD dwFlags
,
293 CertStoreType type
) DECLSPEC_HIDDEN
;
294 void CRYPT_FreeStore(PWINECRYPT_CERTSTORE store
) DECLSPEC_HIDDEN
;
295 BOOL WINAPI
I_CertUpdateStore(HCERTSTORE store1
, HCERTSTORE store2
, DWORD unk0
,
296 DWORD unk1
) DECLSPEC_HIDDEN
;
298 PWINECRYPT_CERTSTORE
CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv
,
299 DWORD dwFlags
, const void *pvPara
) DECLSPEC_HIDDEN
;
300 PWINECRYPT_CERTSTORE
CRYPT_ProvCreateStore(DWORD dwFlags
,
301 PWINECRYPT_CERTSTORE memStore
, const CERT_STORE_PROV_INFO
*pProvInfo
) DECLSPEC_HIDDEN
;
302 PWINECRYPT_CERTSTORE
CRYPT_ProvOpenStore(LPCSTR lpszStoreProvider
,
303 DWORD dwEncodingType
, HCRYPTPROV hCryptProv
, DWORD dwFlags
,
304 const void *pvPara
) DECLSPEC_HIDDEN
;
305 PWINECRYPT_CERTSTORE
CRYPT_RegOpenStore(HCRYPTPROV hCryptProv
, DWORD dwFlags
,
306 const void *pvPara
) DECLSPEC_HIDDEN
;
307 PWINECRYPT_CERTSTORE
CRYPT_FileOpenStore(HCRYPTPROV hCryptProv
, DWORD dwFlags
,
308 const void *pvPara
) DECLSPEC_HIDDEN
;
309 PWINECRYPT_CERTSTORE
CRYPT_FileNameOpenStoreA(HCRYPTPROV hCryptProv
,
310 DWORD dwFlags
, const void *pvPara
) DECLSPEC_HIDDEN
;
311 PWINECRYPT_CERTSTORE
CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv
,
312 DWORD dwFlags
, const void *pvPara
) DECLSPEC_HIDDEN
;
313 PWINECRYPT_CERTSTORE
CRYPT_RootOpenStore(HCRYPTPROV hCryptProv
, DWORD dwFlags
) DECLSPEC_HIDDEN
;
315 /* Allocates and initializes a certificate chain engine, but without creating
316 * the root store. Instead, it uses root, and assumes the caller has done any
317 * checking necessary.
319 HCERTCHAINENGINE
CRYPT_CreateChainEngine(HCERTSTORE root
,
320 PCERT_CHAIN_ENGINE_CONFIG pConfig
) DECLSPEC_HIDDEN
;
322 /* Helper function for store reading functions and
323 * CertAddSerializedElementToStore. Returns a context of the appropriate type
324 * if it can, or NULL otherwise. Doesn't validate any of the properties in
325 * the serialized context (for example, bad hashes are retained.)
326 * *pdwContentType is set to the type of the returned context.
328 const void *CRYPT_ReadSerializedElement(const BYTE
*pbElement
,
329 DWORD cbElement
, DWORD dwContextTypeFlags
, DWORD
*pdwContentType
) DECLSPEC_HIDDEN
;
331 /* Reads contexts serialized in the file into the memory store. Returns FALSE
332 * if the file is not of the expected format.
334 BOOL
CRYPT_ReadSerializedStoreFromFile(HANDLE file
, HCERTSTORE store
) DECLSPEC_HIDDEN
;
336 /* Reads contexts serialized in the blob into the memory store. Returns FALSE
337 * if the file is not of the expected format.
339 BOOL
CRYPT_ReadSerializedStoreFromBlob(const CRYPT_DATA_BLOB
*blob
,
340 HCERTSTORE store
) DECLSPEC_HIDDEN
;
342 /* Fixes up the pointers in info, where info is assumed to be a
343 * CRYPT_KEY_PROV_INFO, followed by its container name, provider name, and any
344 * provider parameters, in a contiguous buffer, but where info's pointers are
345 * assumed to be invalid. Upon return, info's pointers point to the
346 * appropriate memory locations.
348 void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info
) DECLSPEC_HIDDEN
;
354 DWORD
cert_name_to_str_with_indent(DWORD dwCertEncodingType
, DWORD indent
,
355 const CERT_NAME_BLOB
*pName
, DWORD dwStrType
, LPWSTR psz
, DWORD csz
) DECLSPEC_HIDDEN
;
361 /* Allocates a new data context, a context which owns properties directly.
362 * contextSize is the size of the public data type associated with context,
363 * which should be one of CERT_CONTEXT, CRL_CONTEXT, or CTL_CONTEXT.
364 * Free with Context_Release.
366 void *Context_CreateDataContext(size_t contextSize
) DECLSPEC_HIDDEN
;
368 /* Creates a new link context with extra bytes. The context refers to linked
369 * rather than owning its own properties. If addRef is TRUE (which ordinarily
370 * it should be) linked is addref'd.
371 * Free with Context_Release.
373 void *Context_CreateLinkContext(unsigned int contextSize
, void *linked
, unsigned int extra
,
374 BOOL addRef
) DECLSPEC_HIDDEN
;
376 /* Returns a pointer to the extra bytes allocated with context, which must be
379 void *Context_GetExtra(const void *context
, size_t contextSize
) DECLSPEC_HIDDEN
;
381 /* Gets the context linked to by context, which must be a link context. */
382 void *Context_GetLinkedContext(void *context
, size_t contextSize
) DECLSPEC_HIDDEN
;
384 /* Copies properties from fromContext to toContext. */
385 void Context_CopyProperties(const void *to
, const void *from
,
386 size_t contextSize
) DECLSPEC_HIDDEN
;
388 /* Returns context's properties, or the linked context's properties if context
391 PCONTEXT_PROPERTY_LIST
Context_GetProperties(const void *context
, size_t contextSize
) DECLSPEC_HIDDEN
;
393 void Context_AddRef(void *context
, size_t contextSize
) DECLSPEC_HIDDEN
;
395 typedef void (*ContextFreeFunc
)(void *context
);
397 /* Decrements context's ref count. If context is a link context, releases its
398 * linked context as well.
399 * If a data context has its ref count reach 0, calls dataContextFree on it.
400 * Returns FALSE if the reference count is <= 0 when called.
402 BOOL
Context_Release(void *context
, size_t contextSize
,
403 ContextFreeFunc dataContextFree
) DECLSPEC_HIDDEN
;
406 * Context property list functions
409 PCONTEXT_PROPERTY_LIST
ContextPropertyList_Create(void) DECLSPEC_HIDDEN
;
411 /* Searches for the property with ID id in the context. Returns TRUE if found,
412 * and copies the property's length and a pointer to its data to blob.
413 * Otherwise returns FALSE.
415 BOOL
ContextPropertyList_FindProperty(PCONTEXT_PROPERTY_LIST list
, DWORD id
,
416 PCRYPT_DATA_BLOB blob
) DECLSPEC_HIDDEN
;
418 BOOL
ContextPropertyList_SetProperty(PCONTEXT_PROPERTY_LIST list
, DWORD id
,
419 const BYTE
*pbData
, size_t cbData
) DECLSPEC_HIDDEN
;
421 void ContextPropertyList_RemoveProperty(PCONTEXT_PROPERTY_LIST list
, DWORD id
) DECLSPEC_HIDDEN
;
423 DWORD
ContextPropertyList_EnumPropIDs(PCONTEXT_PROPERTY_LIST list
, DWORD id
) DECLSPEC_HIDDEN
;
425 void ContextPropertyList_Copy(PCONTEXT_PROPERTY_LIST to
,
426 PCONTEXT_PROPERTY_LIST from
) DECLSPEC_HIDDEN
;
428 void ContextPropertyList_Free(PCONTEXT_PROPERTY_LIST list
) DECLSPEC_HIDDEN
;
431 * Context list functions. A context list is a simple list of link contexts.
435 struct ContextList
*ContextList_Create(
436 PCWINE_CONTEXT_INTERFACE contextInterface
, size_t contextSize
) DECLSPEC_HIDDEN
;
438 void *ContextList_Add(struct ContextList
*list
, void *toLink
, void *toReplace
) DECLSPEC_HIDDEN
;
440 void *ContextList_Enum(struct ContextList
*list
, void *pPrev
) DECLSPEC_HIDDEN
;
442 /* Removes a context from the list. Returns TRUE if the context was removed,
443 * or FALSE if not. (The context may have been duplicated, so subsequent
444 * removes have no effect.)
446 BOOL
ContextList_Remove(struct ContextList
*list
, void *context
) DECLSPEC_HIDDEN
;
448 void ContextList_Free(struct ContextList
*list
) DECLSPEC_HIDDEN
;
454 /* Align up to a DWORD_PTR boundary
456 #define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1))
457 #define POINTER_ALIGN_DWORD_PTR(p) ((LPVOID)ALIGN_DWORD_PTR((DWORD_PTR)(p)))
459 /* Check if the OID is a small int
461 #define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0)