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