| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | //**************************************************************************** |
| 5 | // File: metadata.h |
| 6 | // |
| 7 | |
| 8 | // |
| 9 | // Notes: |
| 10 | // Common includes for EE & metadata internal. This file contains |
| 11 | // definition of CorMetaDataScope |
| 12 | //**************************************************************************** |
| 13 | |
| 14 | #ifndef _METADATA_H_ |
| 15 | #define _METADATA_H_ |
| 16 | |
| 17 | #include "../md/inc/metamodelro.h" |
| 18 | #include "../md/inc/liteweightstgdb.h" |
| 19 | |
| 20 | class UTSemReadWrite; |
| 21 | |
| 22 | inline int IsGlobalMethodParentTk(mdTypeDef td) |
| 23 | { |
| 24 | LIMITED_METHOD_CONTRACT; |
| 25 | |
| 26 | return (td == mdTypeDefNil || td == mdTokenNil); |
| 27 | } |
| 28 | |
| 29 | typedef enum CorInternalStates |
| 30 | { |
| 31 | tdNoTypes = 0x00000000, |
| 32 | tdAllAssemblies = 0x00000001, |
| 33 | tdAllTypes = 0xffffffff, |
| 34 | } CorInternalStates; |
| 35 | |
| 36 | // |
| 37 | // MetaData custom value names. |
| 38 | // |
| 39 | enum CorIfaceAttr |
| 40 | { |
| 41 | ifDual = 0, // Interface derives from IDispatch. |
| 42 | ifVtable = 1, // Interface derives from IUnknown. |
| 43 | ifDispatch = 2, // Interface is a dispinterface. |
| 44 | ifInspectable = 3, // Interface derives from IInspectable. |
| 45 | ifLast = 4, // The last member of the enum. |
| 46 | }; |
| 47 | |
| 48 | inline BOOL IsDispatchBasedItf(CorIfaceAttr ifaceAttr) |
| 49 | { |
| 50 | return (ifaceAttr == ifDual || ifaceAttr == ifDispatch); |
| 51 | } |
| 52 | |
| 53 | enum CorClassIfaceAttr |
| 54 | { |
| 55 | clsIfNone = 0, // No class interface is generated. |
| 56 | clsIfAutoDisp = 1, // A dispatch only class interface is generated. |
| 57 | clsIfAutoDual = 2, // A dual class interface is generated. |
| 58 | clsIfLast = 3, // The last member of the enum. |
| 59 | }; |
| 60 | |
| 61 | // |
| 62 | // The default values for the COM interface and class interface types. |
| 63 | // |
| 64 | #define DEFAULT_COM_INTERFACE_TYPE ifDual |
| 65 | #define DEFAULT_CLASS_INTERFACE_TYPE clsIfAutoDisp |
| 66 | |
| 67 | #define HANDLE_UNCOMPRESSED(func) (E_FAIL) |
| 68 | #define HANDLE_UNCOMPRESSED_BOOL(func) (false) |
| 69 | |
| 70 | class TOKENLIST : public CDynArray<mdToken> |
| 71 | { |
| 72 | }; |
| 73 | |
| 74 | |
| 75 | typedef enum tagEnumType |
| 76 | { |
| 77 | MDSimpleEnum = 0x0, // simple enumerator that doesn't allocate memory |
| 78 | |
| 79 | // You could get this kind of enum if you perform a non-simple query (such as EnumMethodWithName). |
| 80 | // |
| 81 | MDDynamicArrayEnum = 0x2, // dynamic array that holds tokens |
| 82 | |
| 83 | = 0x3, // Custom enumerator that doesnt work with the enum functions |
| 84 | } EnumType; |
| 85 | |
| 86 | //***************************************** |
| 87 | // Enumerator used by MetaDataInternal |
| 88 | //***************************************** |
| 89 | struct HENUMInternal |
| 90 | { |
| 91 | DWORD m_tkKind; // kind of tables that the enum is holding the result |
| 92 | ULONG m_ulCount; // count of total entries holding by the enumerator |
| 93 | |
| 94 | EnumType m_EnumType; |
| 95 | |
| 96 | struct { |
| 97 | ULONG m_ulStart; |
| 98 | ULONG m_ulEnd; |
| 99 | ULONG m_ulCur; |
| 100 | } u; |
| 101 | |
| 102 | // m_cursor will go away when we no longer support running EE with uncompressed |
| 103 | // format. WHEN WE REMOVE THIS, REMOVE ITS VESTIAGES FROM ZeroEnum as well |
| 104 | // |
| 105 | union { |
| 106 | void* m_alignpad; // The first item is m_cursor[] is a pointer |
| 107 | char m_cursor[32]; // cursor holding query result for read/write mode |
| 108 | }; |
| 109 | |
| 110 | // TOKENLIST daTKList; // dynamic arrays of token list |
| 111 | HENUMInternal() : m_EnumType(MDSimpleEnum) { LIMITED_METHOD_DAC_CONTRACT; } |
| 112 | |
| 113 | // in-place initialization |
| 114 | static void InitDynamicArrayEnum( |
| 115 | HENUMInternal *pEnum); // HENUMInternal to be initialized |
| 116 | |
| 117 | static void InitSimpleEnum( |
| 118 | DWORD tkKind, // kind of token that we are iterating |
| 119 | ULONG ridStart, // starting rid |
| 120 | ULONG ridEnd, // end rid |
| 121 | HENUMInternal *pEnum); // HENUMInternal to be initialized |
| 122 | |
| 123 | // Specialized helper which should be better than always calling memset |
| 124 | inline |
| 125 | static void ZeroEnum( |
| 126 | HENUMInternal *pEnum) |
| 127 | { |
| 128 | // we use this to avoid the memset that will happen otherwise. |
| 129 | // this should be inlined in its caller. we are seeing a large |
| 130 | // number of calls to memset from MDInternalRO::EnumPermissionSetsInit |
| 131 | // on x64 which we can eliminate with this code. |
| 132 | pEnum->m_tkKind = 0; |
| 133 | pEnum->m_ulCount = 0; |
| 134 | pEnum->m_EnumType = MDSimpleEnum; |
| 135 | pEnum->u.m_ulStart = 0; |
| 136 | pEnum->u.m_ulEnd = 0; |
| 137 | pEnum->u.m_ulCur = 0; |
| 138 | |
| 139 | // TODO: remove this when we remove m_cursor from the HENUMInternal structure |
| 140 | _ASSERTE(IS_ALIGNED(pEnum->m_cursor, sizeof(DWORD))); |
| 141 | _ASSERTE((sizeof(HENUMInternal) - offsetof(HENUMInternal, m_cursor)) == (8 * sizeof(DWORD))); |
| 142 | |
| 143 | DWORD* pBuffer = (DWORD*)pEnum->m_cursor; |
| 144 | pBuffer[0] = 0; |
| 145 | pBuffer[1] = 0; |
| 146 | pBuffer[2] = 0; |
| 147 | pBuffer[3] = 0; |
| 148 | pBuffer[4] = 0; |
| 149 | pBuffer[5] = 0; |
| 150 | pBuffer[6] = 0; |
| 151 | pBuffer[7] = 0; |
| 152 | } |
| 153 | |
| 154 | // This will only clear the content of enum and will not free the memory of enum |
| 155 | static void ClearEnum( |
| 156 | HENUMInternal *pmdEnum); |
| 157 | |
| 158 | // create a HENUMInternal. This will allocate the memory |
| 159 | __checkReturn |
| 160 | static HRESULT CreateSimpleEnum( |
| 161 | DWORD tkKind, // kind of token that we are iterating |
| 162 | ULONG ridStart, // starting rid |
| 163 | ULONG ridEnd, // end rid |
| 164 | HENUMInternal **ppEnum); // return the created HENUMInternal |
| 165 | |
| 166 | __checkReturn |
| 167 | static HRESULT CreateDynamicArrayEnum( |
| 168 | DWORD tkKind, // kind of token that we are iterating |
| 169 | HENUMInternal **ppEnum); // return the created HENUMInternal |
| 170 | |
| 171 | // Destory Enum. This will free the memory |
| 172 | static void DestroyEnum( |
| 173 | HENUMInternal *pmdEnum); |
| 174 | |
| 175 | static void DestroyEnumIfEmpty( |
| 176 | HENUMInternal **ppEnum); // reset the enumerator pointer to NULL if empty |
| 177 | |
| 178 | __checkReturn |
| 179 | static HRESULT EnumWithCount( |
| 180 | HENUMInternal *pEnum, // enumerator |
| 181 | ULONG cMax, // max tokens that caller wants |
| 182 | mdToken rTokens[], // output buffer to fill the tokens |
| 183 | ULONG *pcTokens); // number of tokens fill to the buffer upon return |
| 184 | |
| 185 | __checkReturn |
| 186 | static HRESULT EnumWithCount( |
| 187 | HENUMInternal *pEnum, // enumerator |
| 188 | ULONG cMax, // max tokens that caller wants |
| 189 | mdToken rTokens1[], // first output buffer to fill the tokens |
| 190 | mdToken rTokens2[], // second output buffer to fill the tokens |
| 191 | ULONG *pcTokens); // number of tokens fill to the buffer upon return |
| 192 | |
| 193 | __checkReturn |
| 194 | static HRESULT AddElementToEnum( |
| 195 | HENUMInternal *pEnum, // return the created HENUMInternal |
| 196 | mdToken tk); // token to fill |
| 197 | |
| 198 | //***************************************** |
| 199 | // Get next value contained in the enumerator |
| 200 | //***************************************** |
| 201 | static bool EnumNext( |
| 202 | HENUMInternal *phEnum, // [IN] the enumerator to retrieve information |
| 203 | mdToken *ptk); // [OUT] token to scope the search |
| 204 | |
| 205 | __checkReturn |
| 206 | static HRESULT GetCount( |
| 207 | HENUMInternal *phEnum, // [IN] the enumerator to retrieve information |
| 208 | ULONG *pCount); // ]OUT] the index of the desired item |
| 209 | |
| 210 | __checkReturn |
| 211 | static HRESULT GetElement( |
| 212 | HENUMInternal *phEnum, // [IN] the enumerator to retrieve information |
| 213 | ULONG ix, // ]IN] the index of the desired item |
| 214 | mdToken *ptk); // [OUT] token to fill |
| 215 | |
| 216 | }; |
| 217 | |
| 218 | |
| 219 | |
| 220 | //***************************************** |
| 221 | // Default Value for field, param or property. Returned by GetDefaultValue |
| 222 | //***************************************** |
| 223 | typedef struct _MDDefaultValue |
| 224 | { |
| 225 | #if BIGENDIAN |
| 226 | _MDDefaultValue(void) |
| 227 | { |
| 228 | m_bType = ELEMENT_TYPE_END; |
| 229 | } |
| 230 | ~_MDDefaultValue(void) |
| 231 | { |
| 232 | if (m_bType == ELEMENT_TYPE_STRING) |
| 233 | { |
| 234 | delete[] m_wzValue; |
| 235 | } |
| 236 | } |
| 237 | #endif |
| 238 | |
| 239 | // type of default value |
| 240 | BYTE m_bType; // CorElementType for the default value |
| 241 | |
| 242 | // the default value |
| 243 | union |
| 244 | { |
| 245 | BOOL m_bValue; // ELEMENT_TYPE_BOOLEAN |
| 246 | CHAR m_cValue; // ELEMENT_TYPE_I1 |
| 247 | BYTE m_byteValue; // ELEMENT_TYPE_UI1 |
| 248 | SHORT m_sValue; // ELEMENT_TYPE_I2 |
| 249 | USHORT m_usValue; // ELEMENT_TYPE_UI2 |
| 250 | LONG m_lValue; // ELEMENT_TYPE_I4 |
| 251 | ULONG m_ulValue; // ELEMENT_TYPE_UI4 |
| 252 | LONGLONG m_llValue; // ELEMENT_TYPE_I8 |
| 253 | ULONGLONG m_ullValue; // ELEMENT_TYPE_UI8 |
| 254 | FLOAT m_fltValue; // ELEMENT_TYPE_R4 |
| 255 | DOUBLE m_dblValue; // ELEMENT_TYPE_R8 |
| 256 | LPCWSTR m_wzValue; // ELEMENT_TYPE_STRING |
| 257 | IUnknown *m_unkValue; // ELEMENT_TYPE_CLASS |
| 258 | }; |
| 259 | ULONG m_cbSize; // default value size (for blob) |
| 260 | |
| 261 | } MDDefaultValue; |
| 262 | |
| 263 | |
| 264 | |
| 265 | //***************************************** |
| 266 | // structure use to in GetAllEventAssociates and GetAllPropertyAssociates |
| 267 | //***************************************** |
| 268 | typedef struct |
| 269 | { |
| 270 | mdMethodDef m_memberdef; |
| 271 | DWORD m_dwSemantics; |
| 272 | } ASSOCIATE_RECORD; |
| 273 | |
| 274 | |
| 275 | // |
| 276 | // structure use to retrieve class layout informaiton |
| 277 | // |
| 278 | typedef struct |
| 279 | { |
| 280 | RID m_ridFieldCur; // indexing to the field table |
| 281 | RID m_ridFieldEnd; // end index to field table |
| 282 | } MD_CLASS_LAYOUT; |
| 283 | |
| 284 | |
| 285 | // Structure for describing the Assembly MetaData. |
| 286 | typedef struct |
| 287 | { |
| 288 | USHORT usMajorVersion; // Major Version. |
| 289 | USHORT usMinorVersion; // Minor Version. |
| 290 | USHORT usBuildNumber; // Build Number. |
| 291 | USHORT usRevisionNumber; // Revision Number. |
| 292 | LPCSTR szLocale; // Locale. |
| 293 | DWORD *rProcessor; // Processor array. |
| 294 | ULONG ulProcessor; // [IN/OUT] Size of the processor array/Actual # of entries filled in. |
| 295 | OSINFO *rOS; // OSINFO array. |
| 296 | ULONG ulOS; // [IN/OUT]Size of the OSINFO array/Actual # of entries filled in. |
| 297 | } AssemblyMetaDataInternal; |
| 298 | |
| 299 | |
| 300 | |
| 301 | // Callback definition for comparing signatures. |
| 302 | // (*PSIGCOMPARE) (BYTE ScopeSignature[], DWORD ScopeSignatureLength, |
| 303 | // BYTE ExternalSignature[], DWORD ExternalSignatureLength, |
| 304 | // void* SignatureData); |
| 305 | typedef BOOL (*PSIGCOMPARE)(PCCOR_SIGNATURE, DWORD, PCCOR_SIGNATURE, DWORD, void*); |
| 306 | |
| 307 | |
| 308 | |
| 309 | // {CE0F34ED-BBC6-11d2-941E-0000F8083460} |
| 310 | EXTERN_GUID(IID_IMDInternalImport, 0xce0f34ed, 0xbbc6, 0x11d2, 0x94, 0x1e, 0x0, 0x0, 0xf8, 0x8, 0x34, 0x60); |
| 311 | |
| 312 | #undef INTERFACE |
| 313 | #define INTERFACE IMDInternalImport |
| 314 | DECLARE_INTERFACE_(IMDInternalImport, IUnknown) |
| 315 | { |
| 316 | //---------------------------------------------------------------------------------------- |
| 317 | // !!! READ THIS !!! |
| 318 | // |
| 319 | // New methods have to be added at the end. The order and signatures of the existing methods |
| 320 | // have to be preserved. We need to maintain a backward compatibility for this interface to |
| 321 | // allow ildasm to work on SingleCLR. |
| 322 | // |
| 323 | //---------------------------------------------------------------------------------------- |
| 324 | |
| 325 | //***************************************************************************** |
| 326 | // return the count of entries of a given kind in a scope |
| 327 | // For example, pass in mdtMethodDef will tell you how many MethodDef |
| 328 | // contained in a scope |
| 329 | //***************************************************************************** |
| 330 | STDMETHOD_(ULONG, GetCountWithTokenKind)(// return hresult |
| 331 | DWORD tkKind) PURE; // [IN] pass in the kind of token. |
| 332 | |
| 333 | //***************************************************************************** |
| 334 | // enumerator for typedef |
| 335 | //***************************************************************************** |
| 336 | __checkReturn |
| 337 | STDMETHOD(EnumTypeDefInit)( // return hresult |
| 338 | HENUMInternal *phEnum) PURE; // [OUT] buffer to fill for enumerator data |
| 339 | |
| 340 | STDMETHOD_(ULONG, EnumTypeDefGetCount)( |
| 341 | HENUMInternal *phEnum) PURE; // [IN] the enumerator to retrieve information |
| 342 | |
| 343 | STDMETHOD_(void, EnumTypeDefReset)( |
| 344 | HENUMInternal *phEnum) PURE; // [IN] the enumerator to retrieve information |
| 345 | |
| 346 | STDMETHOD_(bool, EnumTypeDefNext)( // return hresult |
| 347 | HENUMInternal *phEnum, // [IN] input enum |
| 348 | mdTypeDef *ptd) PURE; // [OUT] return token |
| 349 | |
| 350 | STDMETHOD_(void, EnumTypeDefClose)( |
| 351 | HENUMInternal *phEnum) PURE; // [IN] the enumerator to retrieve information |
| 352 | |
| 353 | //***************************************************************************** |
| 354 | // enumerator for MethodImpl |
| 355 | //***************************************************************************** |
| 356 | __checkReturn |
| 357 | STDMETHOD(EnumMethodImplInit)( // return hresult |
| 358 | mdTypeDef td, // [IN] TypeDef over which to scope the enumeration. |
| 359 | HENUMInternal *phEnumBody, // [OUT] buffer to fill for enumerator data for MethodBody tokens. |
| 360 | HENUMInternal *phEnumDecl) PURE; // [OUT] buffer to fill for enumerator data for MethodDecl tokens. |
| 361 | |
| 362 | STDMETHOD_(ULONG, EnumMethodImplGetCount)( |
| 363 | HENUMInternal *phEnumBody, // [IN] MethodBody enumerator. |
| 364 | HENUMInternal *phEnumDecl) PURE; // [IN] MethodDecl enumerator. |
| 365 | |
| 366 | STDMETHOD_(void, EnumMethodImplReset)( |
| 367 | HENUMInternal *phEnumBody, // [IN] MethodBody enumerator. |
| 368 | HENUMInternal *phEnumDecl) PURE; // [IN] MethodDecl enumerator. |
| 369 | |
| 370 | __checkReturn |
| 371 | STDMETHOD(EnumMethodImplNext)( // return hresult (S_OK = TRUE, S_FALSE = FALSE or error code) |
| 372 | HENUMInternal *phEnumBody, // [IN] input enum for MethodBody |
| 373 | HENUMInternal *phEnumDecl, // [IN] input enum for MethodDecl |
| 374 | mdToken *ptkBody, // [OUT] return token for MethodBody |
| 375 | mdToken *ptkDecl) PURE; // [OUT] return token for MethodDecl |
| 376 | |
| 377 | STDMETHOD_(void, EnumMethodImplClose)( |
| 378 | HENUMInternal *phEnumBody, // [IN] MethodBody enumerator. |
| 379 | HENUMInternal *phEnumDecl) PURE; // [IN] MethodDecl enumerator. |
| 380 | |
| 381 | //***************************************** |
| 382 | // Enumerator helpers for memberdef, memberref, interfaceimp, |
| 383 | // event, property, exception, param |
| 384 | //***************************************** |
| 385 | |
| 386 | __checkReturn |
| 387 | STDMETHOD(EnumGlobalFunctionsInit)( // return hresult |
| 388 | HENUMInternal *phEnum) PURE; // [OUT] buffer to fill for enumerator data |
| 389 | |
| 390 | __checkReturn |
| 391 | STDMETHOD(EnumGlobalFieldsInit)( // return hresult |
| 392 | HENUMInternal *phEnum) PURE; // [OUT] buffer to fill for enumerator data |
| 393 | |
| 394 | __checkReturn |
| 395 | STDMETHOD(EnumInit)( // return S_FALSE if record not found |
| 396 | DWORD tkKind, // [IN] which table to work on |
| 397 | mdToken tkParent, // [IN] token to scope the search |
| 398 | HENUMInternal *phEnum) PURE; // [OUT] the enumerator to fill |
| 399 | |
| 400 | __checkReturn |
| 401 | STDMETHOD(EnumAllInit)( // return S_FALSE if record not found |
| 402 | DWORD tkKind, // [IN] which table to work on |
| 403 | HENUMInternal *phEnum) PURE; // [OUT] the enumerator to fill |
| 404 | |
| 405 | STDMETHOD_(bool, EnumNext)( |
| 406 | HENUMInternal *phEnum, // [IN] the enumerator to retrieve information |
| 407 | mdToken *ptk) PURE; // [OUT] token to scope the search |
| 408 | |
| 409 | STDMETHOD_(ULONG, EnumGetCount)( |
| 410 | HENUMInternal *phEnum) PURE; // [IN] the enumerator to retrieve information |
| 411 | |
| 412 | STDMETHOD_(void, EnumReset)( |
| 413 | HENUMInternal *phEnum) PURE; // [IN] the enumerator to be reset |
| 414 | |
| 415 | STDMETHOD_(void, EnumClose)( |
| 416 | HENUMInternal *phEnum) PURE; // [IN] the enumerator to be closed |
| 417 | |
| 418 | //***************************************** |
| 419 | // Enumerator helpers for declsecurity. |
| 420 | //***************************************** |
| 421 | __checkReturn |
| 422 | STDMETHOD(EnumPermissionSetsInit)( // return S_FALSE if record not found |
| 423 | mdToken tkParent, // [IN] token to scope the search |
| 424 | CorDeclSecurity Action, // [IN] Action to scope the search |
| 425 | HENUMInternal *phEnum) PURE; // [OUT] the enumerator to fill |
| 426 | |
| 427 | //***************************************** |
| 428 | // Enumerator helpers for CustomAttribute |
| 429 | //***************************************** |
| 430 | __checkReturn |
| 431 | STDMETHOD(EnumCustomAttributeByNameInit)(// return S_FALSE if record not found |
| 432 | mdToken tkParent, // [IN] token to scope the search |
| 433 | LPCSTR szName, // [IN] CustomAttribute's name to scope the search |
| 434 | HENUMInternal *phEnum) PURE; // [OUT] the enumerator to fill |
| 435 | |
| 436 | //***************************************** |
| 437 | // Nagivator helper to navigate back to the parent token given a token. |
| 438 | // For example, given a memberdef token, it will return the containing typedef. |
| 439 | // |
| 440 | // the mapping is as following: |
| 441 | // ---given child type---------parent type |
| 442 | // mdMethodDef mdTypeDef |
| 443 | // mdFieldDef mdTypeDef |
| 444 | // mdInterfaceImpl mdTypeDef |
| 445 | // mdParam mdMethodDef |
| 446 | // mdProperty mdTypeDef |
| 447 | // mdEvent mdTypeDef |
| 448 | // |
| 449 | //***************************************** |
| 450 | __checkReturn |
| 451 | STDMETHOD(GetParentToken)( |
| 452 | mdToken tkChild, // [IN] given child token |
| 453 | mdToken *ptkParent) PURE; // [OUT] returning parent |
| 454 | |
| 455 | //***************************************** |
| 456 | // Custom value helpers |
| 457 | //***************************************** |
| 458 | __checkReturn |
| 459 | STDMETHOD(GetCustomAttributeProps)( // S_OK or error. |
| 460 | mdCustomAttribute at, // [IN] The attribute. |
| 461 | mdToken *ptkType) PURE; // [OUT] Put attribute type here. |
| 462 | |
| 463 | __checkReturn |
| 464 | STDMETHOD(GetCustomAttributeAsBlob)( |
| 465 | mdCustomAttribute cv, // [IN] given custom value token |
| 466 | void const **ppBlob, // [OUT] return the pointer to internal blob |
| 467 | ULONG *pcbSize) PURE; // [OUT] return the size of the blob |
| 468 | |
| 469 | // returned void in v1.0/v1.1 |
| 470 | __checkReturn |
| 471 | STDMETHOD (GetScopeProps)( |
| 472 | LPCSTR *pszName, // [OUT] scope name |
| 473 | GUID *pmvid) PURE; // [OUT] version id |
| 474 | |
| 475 | // finding a particular method |
| 476 | __checkReturn |
| 477 | STDMETHOD(FindMethodDef)( |
| 478 | mdTypeDef classdef, // [IN] given typedef |
| 479 | LPCSTR szName, // [IN] member name |
| 480 | PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature |
| 481 | ULONG cbSigBlob, // [IN] count of bytes in the signature blob |
| 482 | mdMethodDef *pmd) PURE; // [OUT] matching memberdef |
| 483 | |
| 484 | // return a iSeq's param given a MethodDef |
| 485 | __checkReturn |
| 486 | STDMETHOD(FindParamOfMethod)( // S_OK or error. |
| 487 | mdMethodDef md, // [IN] The owning method of the param. |
| 488 | ULONG iSeq, // [IN] The sequence # of the param. |
| 489 | mdParamDef *pparamdef) PURE; // [OUT] Put ParamDef token here. |
| 490 | |
| 491 | //***************************************** |
| 492 | // |
| 493 | // GetName* functions |
| 494 | // |
| 495 | //***************************************** |
| 496 | |
| 497 | // return the name and namespace of typedef |
| 498 | __checkReturn |
| 499 | STDMETHOD(GetNameOfTypeDef)( |
| 500 | mdTypeDef classdef, // given classdef |
| 501 | LPCSTR *pszname, // return class name(unqualified) |
| 502 | LPCSTR *psznamespace) PURE; // return the name space name |
| 503 | |
| 504 | __checkReturn |
| 505 | STDMETHOD(GetIsDualOfTypeDef)( |
| 506 | mdTypeDef classdef, // [IN] given classdef. |
| 507 | ULONG *pDual) PURE; // [OUT] return dual flag here. |
| 508 | |
| 509 | __checkReturn |
| 510 | STDMETHOD(GetIfaceTypeOfTypeDef)( |
| 511 | mdTypeDef classdef, // [IN] given classdef. |
| 512 | ULONG *pIface) PURE; // [OUT] 0=dual, 1=vtable, 2=dispinterface |
| 513 | |
| 514 | // get the name of either methoddef |
| 515 | __checkReturn |
| 516 | STDMETHOD(GetNameOfMethodDef)( // return the name of the memberdef in UTF8 |
| 517 | mdMethodDef md, // given memberdef |
| 518 | LPCSTR *pszName) PURE; |
| 519 | |
| 520 | __checkReturn |
| 521 | STDMETHOD(GetNameAndSigOfMethodDef)( |
| 522 | mdMethodDef methoddef, // [IN] given memberdef |
| 523 | PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to a blob value of CLR signature |
| 524 | ULONG *pcbSigBlob, // [OUT] count of bytes in the signature blob |
| 525 | LPCSTR *pszName) PURE; |
| 526 | |
| 527 | // return the name of a FieldDef |
| 528 | __checkReturn |
| 529 | STDMETHOD(GetNameOfFieldDef)( |
| 530 | mdFieldDef fd, // given memberdef |
| 531 | LPCSTR *pszName) PURE; |
| 532 | |
| 533 | // return the name of typeref |
| 534 | __checkReturn |
| 535 | STDMETHOD(GetNameOfTypeRef)( |
| 536 | mdTypeRef classref, // [IN] given typeref |
| 537 | LPCSTR *psznamespace, // [OUT] return typeref name |
| 538 | LPCSTR *pszname) PURE; // [OUT] return typeref namespace |
| 539 | |
| 540 | // return the resolutionscope of typeref |
| 541 | __checkReturn |
| 542 | STDMETHOD(GetResolutionScopeOfTypeRef)( |
| 543 | mdTypeRef classref, // given classref |
| 544 | mdToken *ptkResolutionScope) PURE; |
| 545 | |
| 546 | // Find the type token given the name. |
| 547 | __checkReturn |
| 548 | STDMETHOD(FindTypeRefByName)( |
| 549 | LPCSTR szNamespace, // [IN] Namespace for the TypeRef. |
| 550 | LPCSTR szName, // [IN] Name of the TypeRef. |
| 551 | mdToken tkResolutionScope, // [IN] Resolution Scope fo the TypeRef. |
| 552 | mdTypeRef *ptk) PURE; // [OUT] TypeRef token returned. |
| 553 | |
| 554 | // return the TypeDef properties |
| 555 | // returned void in v1.0/v1.1 |
| 556 | __checkReturn |
| 557 | STDMETHOD(GetTypeDefProps)( |
| 558 | mdTypeDef classdef, // given classdef |
| 559 | DWORD *pdwAttr, // return flags on class, tdPublic, tdAbstract |
| 560 | mdToken *ptkExtends) PURE; // [OUT] Put base class TypeDef/TypeRef here |
| 561 | |
| 562 | // return the item's guid |
| 563 | __checkReturn |
| 564 | STDMETHOD(GetItemGuid)( |
| 565 | mdToken tkObj, // [IN] given item. |
| 566 | CLSID *pGuid) PURE; // [out[ put guid here. |
| 567 | |
| 568 | // Get enclosing class of the NestedClass. |
| 569 | __checkReturn |
| 570 | STDMETHOD(GetNestedClassProps)( // S_OK or error |
| 571 | mdTypeDef tkNestedClass, // [IN] NestedClass token. |
| 572 | mdTypeDef *ptkEnclosingClass) PURE; // [OUT] EnclosingClass token. |
| 573 | |
| 574 | // Get count of Nested classes given the enclosing class. |
| 575 | __checkReturn |
| 576 | STDMETHOD(GetCountNestedClasses)( // return count of Nested classes. |
| 577 | mdTypeDef tkEnclosingClass, // Enclosing class. |
| 578 | ULONG *pcNestedClassesCount) PURE; |
| 579 | |
| 580 | // Return array of Nested classes given the enclosing class. |
| 581 | __checkReturn |
| 582 | STDMETHOD(GetNestedClasses)( // Return actual count. |
| 583 | mdTypeDef tkEnclosingClass, // [IN] Enclosing class. |
| 584 | mdTypeDef *rNestedClasses, // [OUT] Array of nested class tokens. |
| 585 | ULONG ulNestedClasses, // [IN] Size of array. |
| 586 | ULONG *pcNestedClasses) PURE; |
| 587 | |
| 588 | // return the ModuleRef properties |
| 589 | // returned void in v1.0/v1.1 |
| 590 | __checkReturn |
| 591 | STDMETHOD(GetModuleRefProps)( |
| 592 | mdModuleRef mur, // [IN] moduleref token |
| 593 | LPCSTR *pszName) PURE; // [OUT] buffer to fill with the moduleref name |
| 594 | |
| 595 | //***************************************** |
| 596 | // |
| 597 | // GetSig* functions |
| 598 | // |
| 599 | //***************************************** |
| 600 | __checkReturn |
| 601 | STDMETHOD(GetSigOfMethodDef)( |
| 602 | mdMethodDef tkMethodDef, // [IN] given MethodDef |
| 603 | ULONG * pcbSigBlob, // [OUT] count of bytes in the signature blob |
| 604 | PCCOR_SIGNATURE * ppSig) PURE; |
| 605 | |
| 606 | __checkReturn |
| 607 | STDMETHOD(GetSigOfFieldDef)( |
| 608 | mdFieldDef tkFieldDef, // [IN] given FieldDef |
| 609 | ULONG * pcbSigBlob, // [OUT] count of bytes in the signature blob |
| 610 | PCCOR_SIGNATURE * ppSig) PURE; |
| 611 | |
| 612 | __checkReturn |
| 613 | STDMETHOD(GetSigFromToken)( |
| 614 | mdToken tk, // FieldDef, MethodDef, Signature or TypeSpec token |
| 615 | ULONG * pcbSig, |
| 616 | PCCOR_SIGNATURE * ppSig) PURE; |
| 617 | |
| 618 | |
| 619 | |
| 620 | //***************************************** |
| 621 | // get method property |
| 622 | //***************************************** |
| 623 | __checkReturn |
| 624 | STDMETHOD(GetMethodDefProps)( |
| 625 | mdMethodDef md, // The method for which to get props. |
| 626 | DWORD *pdwFlags) PURE; |
| 627 | |
| 628 | //***************************************** |
| 629 | // return method implementation informaiton, like RVA and implflags |
| 630 | //***************************************** |
| 631 | // returned void in v1.0/v1.1 |
| 632 | __checkReturn |
| 633 | STDMETHOD(GetMethodImplProps)( |
| 634 | mdToken tk, // [IN] MethodDef |
| 635 | ULONG *pulCodeRVA, // [OUT] CodeRVA |
| 636 | DWORD *pdwImplFlags) PURE; // [OUT] Impl. Flags |
| 637 | |
| 638 | //***************************************** |
| 639 | // return method implementation informaiton, like RVA and implflags |
| 640 | //***************************************** |
| 641 | __checkReturn |
| 642 | STDMETHOD(GetFieldRVA)( |
| 643 | mdFieldDef fd, // [IN] fielddef |
| 644 | ULONG *pulCodeRVA) PURE; // [OUT] CodeRVA |
| 645 | |
| 646 | //***************************************** |
| 647 | // get field property |
| 648 | //***************************************** |
| 649 | __checkReturn |
| 650 | STDMETHOD(GetFieldDefProps)( |
| 651 | mdFieldDef fd, // [IN] given fielddef |
| 652 | DWORD *pdwFlags) PURE; // [OUT] return fdPublic, fdPrive, etc flags |
| 653 | |
| 654 | //***************************************************************************** |
| 655 | // return default value of a token(could be paramdef, fielddef, or property |
| 656 | //***************************************************************************** |
| 657 | __checkReturn |
| 658 | STDMETHOD(GetDefaultValue)( |
| 659 | mdToken tk, // [IN] given FieldDef, ParamDef, or Property |
| 660 | MDDefaultValue *pDefaultValue) PURE;// [OUT] default value to fill |
| 661 | |
| 662 | |
| 663 | //***************************************** |
| 664 | // get dispid of a MethodDef or a FieldDef |
| 665 | //***************************************** |
| 666 | __checkReturn |
| 667 | STDMETHOD(GetDispIdOfMemberDef)( // return hresult |
| 668 | mdToken tk, // [IN] given methoddef or fielddef |
| 669 | ULONG *pDispid) PURE; // [OUT] Put the dispid here. |
| 670 | |
| 671 | //***************************************** |
| 672 | // return TypeRef/TypeDef given an InterfaceImpl token |
| 673 | //***************************************** |
| 674 | __checkReturn |
| 675 | STDMETHOD(GetTypeOfInterfaceImpl)( // return the TypeRef/typedef token for the interfaceimpl |
| 676 | mdInterfaceImpl iiImpl, // given a interfaceimpl |
| 677 | mdToken *ptkType) PURE; |
| 678 | |
| 679 | //***************************************** |
| 680 | // look up function for TypeDef |
| 681 | //***************************************** |
| 682 | __checkReturn |
| 683 | STDMETHOD(FindTypeDef)( |
| 684 | LPCSTR szNamespace, // [IN] Namespace for the TypeDef. |
| 685 | LPCSTR szName, // [IN] Name of the TypeDef. |
| 686 | mdToken tkEnclosingClass, // [IN] TypeRef/TypeDef Token for the enclosing class. |
| 687 | mdTypeDef *ptypedef) PURE; // [IN] return typedef |
| 688 | |
| 689 | //***************************************** |
| 690 | // return name and sig of a memberref |
| 691 | //***************************************** |
| 692 | __checkReturn |
| 693 | STDMETHOD(GetNameAndSigOfMemberRef)( // return name here |
| 694 | mdMemberRef memberref, // given memberref |
| 695 | PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to a blob value of CLR signature |
| 696 | ULONG *pcbSigBlob, // [OUT] count of bytes in the signature blob |
| 697 | LPCSTR *pszName) PURE; |
| 698 | |
| 699 | //***************************************************************************** |
| 700 | // Given memberref, return the parent. It can be TypeRef, ModuleRef, MethodDef |
| 701 | //***************************************************************************** |
| 702 | __checkReturn |
| 703 | STDMETHOD(GetParentOfMemberRef)( |
| 704 | mdMemberRef memberref, // given memberref |
| 705 | mdToken *ptkParent) PURE; // return the parent token |
| 706 | |
| 707 | __checkReturn |
| 708 | STDMETHOD(GetParamDefProps)( |
| 709 | mdParamDef paramdef, // given a paramdef |
| 710 | USHORT *pusSequence, // [OUT] slot number for this parameter |
| 711 | DWORD *pdwAttr, // [OUT] flags |
| 712 | LPCSTR *pszName) PURE; // [OUT] return the name of the parameter |
| 713 | |
| 714 | __checkReturn |
| 715 | STDMETHOD(GetPropertyInfoForMethodDef)( // Result. |
| 716 | mdMethodDef md, // [IN] memberdef |
| 717 | mdProperty *ppd, // [OUT] put property token here |
| 718 | LPCSTR *pName, // [OUT] put pointer to name here |
| 719 | ULONG *pSemantic) PURE; // [OUT] put semantic here |
| 720 | |
| 721 | //***************************************** |
| 722 | // class layout/sequence information |
| 723 | //***************************************** |
| 724 | __checkReturn |
| 725 | STDMETHOD(GetClassPackSize)( // return error if class doesn't have packsize |
| 726 | mdTypeDef td, // [IN] give typedef |
| 727 | ULONG *pdwPackSize) PURE; // [OUT] 1, 2, 4, 8, or 16 |
| 728 | |
| 729 | __checkReturn |
| 730 | STDMETHOD(GetClassTotalSize)( // return error if class doesn't have total size info |
| 731 | mdTypeDef td, // [IN] give typedef |
| 732 | ULONG *pdwClassSize) PURE; // [OUT] return the total size of the class |
| 733 | |
| 734 | __checkReturn |
| 735 | STDMETHOD(GetClassLayoutInit)( |
| 736 | mdTypeDef td, // [IN] give typedef |
| 737 | MD_CLASS_LAYOUT *pLayout) PURE; // [OUT] set up the status of query here |
| 738 | |
| 739 | __checkReturn |
| 740 | STDMETHOD(GetClassLayoutNext)( |
| 741 | MD_CLASS_LAYOUT *pLayout, // [IN|OUT] set up the status of query here |
| 742 | mdFieldDef *pfd, // [OUT] return the fielddef |
| 743 | ULONG *pulOffset) PURE; // [OUT] return the offset/ulSequence associate with it |
| 744 | |
| 745 | //***************************************** |
| 746 | // marshal information of a field |
| 747 | //***************************************** |
| 748 | __checkReturn |
| 749 | STDMETHOD(GetFieldMarshal)( // return error if no native type associate with the token |
| 750 | mdFieldDef fd, // [IN] given fielddef |
| 751 | PCCOR_SIGNATURE *pSigNativeType, // [OUT] the native type signature |
| 752 | ULONG *pcbNativeType) PURE; // [OUT] the count of bytes of *ppvNativeType |
| 753 | |
| 754 | |
| 755 | //***************************************** |
| 756 | // property APIs |
| 757 | //***************************************** |
| 758 | // find a property by name |
| 759 | __checkReturn |
| 760 | STDMETHOD(FindProperty)( |
| 761 | mdTypeDef td, // [IN] given a typdef |
| 762 | LPCSTR szPropName, // [IN] property name |
| 763 | mdProperty *pProp) PURE; // [OUT] return property token |
| 764 | |
| 765 | // returned void in v1.0/v1.1 |
| 766 | __checkReturn |
| 767 | STDMETHOD(GetPropertyProps)( |
| 768 | mdProperty prop, // [IN] property token |
| 769 | LPCSTR *szProperty, // [OUT] property name |
| 770 | DWORD *pdwPropFlags, // [OUT] property flags. |
| 771 | PCCOR_SIGNATURE *ppvSig, // [OUT] property type. pointing to meta data internal blob |
| 772 | ULONG *pcbSig) PURE; // [OUT] count of bytes in *ppvSig |
| 773 | |
| 774 | //********************************** |
| 775 | // Event APIs |
| 776 | //********************************** |
| 777 | __checkReturn |
| 778 | STDMETHOD(FindEvent)( |
| 779 | mdTypeDef td, // [IN] given a typdef |
| 780 | LPCSTR szEventName, // [IN] event name |
| 781 | mdEvent *pEvent) PURE; // [OUT] return event token |
| 782 | |
| 783 | // returned void in v1.0/v1.1 |
| 784 | __checkReturn |
| 785 | STDMETHOD(GetEventProps)( |
| 786 | mdEvent ev, // [IN] event token |
| 787 | LPCSTR *pszEvent, // [OUT] Event name |
| 788 | DWORD *pdwEventFlags, // [OUT] Event flags. |
| 789 | mdToken *ptkEventType) PURE; // [OUT] EventType class |
| 790 | |
| 791 | |
| 792 | //********************************** |
| 793 | // find a particular associate of a property or an event |
| 794 | //********************************** |
| 795 | __checkReturn |
| 796 | STDMETHOD(FindAssociate)( |
| 797 | mdToken evprop, // [IN] given a property or event token |
| 798 | DWORD associate, // [IN] given a associate semantics(setter, getter, testdefault, reset, AddOn, RemoveOn, Fire) |
| 799 | mdMethodDef *pmd) PURE; // [OUT] return method def token |
| 800 | |
| 801 | // Note, void function in v1.0/v1.1 |
| 802 | __checkReturn |
| 803 | STDMETHOD(EnumAssociateInit)( |
| 804 | mdToken evprop, // [IN] given a property or an event token |
| 805 | HENUMInternal *phEnum) PURE; // [OUT] cursor to hold the query result |
| 806 | |
| 807 | // returned void in v1.0/v1.1 |
| 808 | __checkReturn |
| 809 | STDMETHOD(GetAllAssociates)( |
| 810 | HENUMInternal *phEnum, // [IN] query result form GetPropertyAssociateCounts |
| 811 | ASSOCIATE_RECORD *pAssociateRec, // [OUT] struct to fill for output |
| 812 | ULONG cAssociateRec) PURE; // [IN] size of the buffer |
| 813 | |
| 814 | |
| 815 | //********************************** |
| 816 | // Get info about a PermissionSet. |
| 817 | //********************************** |
| 818 | // returned void in v1.0/v1.1 |
| 819 | __checkReturn |
| 820 | STDMETHOD(GetPermissionSetProps)( |
| 821 | mdPermission pm, // [IN] the permission token. |
| 822 | DWORD *pdwAction, // [OUT] CorDeclSecurity. |
| 823 | void const **ppvPermission, // [OUT] permission blob. |
| 824 | ULONG *pcbPermission) PURE; // [OUT] count of bytes of pvPermission. |
| 825 | |
| 826 | //**************************************** |
| 827 | // Get the String given the String token. |
| 828 | // Returns a pointer to the string, or NULL in case of error. |
| 829 | //**************************************** |
| 830 | __checkReturn |
| 831 | STDMETHOD(GetUserString)( |
| 832 | mdString stk, // [IN] the string token. |
| 833 | ULONG *pchString, // [OUT] count of characters in the string. |
| 834 | BOOL *pbIs80Plus, // [OUT] specifies where there are extended characters >= 0x80. |
| 835 | LPCWSTR *pwszUserString) PURE; |
| 836 | |
| 837 | //***************************************************************************** |
| 838 | // p-invoke APIs. |
| 839 | //***************************************************************************** |
| 840 | __checkReturn |
| 841 | STDMETHOD(GetPinvokeMap)( |
| 842 | mdToken tk, // [IN] FieldDef, MethodDef. |
| 843 | DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. |
| 844 | LPCSTR *pszImportName, // [OUT] Import name. |
| 845 | mdModuleRef *pmrImportDLL) PURE; // [OUT] ModuleRef token for the target DLL. |
| 846 | |
| 847 | //***************************************************************************** |
| 848 | // helpers to convert a text signature to a com format |
| 849 | //***************************************************************************** |
| 850 | __checkReturn |
| 851 | STDMETHOD(ConvertTextSigToComSig)( // Return hresult. |
| 852 | BOOL fCreateTrIfNotFound, // [IN] create typeref if not found |
| 853 | LPCSTR pSignature, // [IN] class file format signature |
| 854 | CQuickBytes *pqbNewSig, // [OUT] place holder for CLR signature |
| 855 | ULONG *pcbCount) PURE; // [OUT] the result size of signature |
| 856 | |
| 857 | //***************************************************************************** |
| 858 | // Assembly MetaData APIs. |
| 859 | //***************************************************************************** |
| 860 | // returned void in v1.0/v1.1 |
| 861 | __checkReturn |
| 862 | STDMETHOD(GetAssemblyProps)( |
| 863 | mdAssembly mda, // [IN] The Assembly for which to get the properties. |
| 864 | const void **ppbPublicKey, // [OUT] Pointer to the public key. |
| 865 | ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key. |
| 866 | ULONG *pulHashAlgId, // [OUT] Hash Algorithm. |
| 867 | LPCSTR *pszName, // [OUT] Buffer to fill with name. |
| 868 | AssemblyMetaDataInternal *pMetaData,// [OUT] Assembly MetaData. |
| 869 | DWORD *pdwAssemblyFlags) PURE;// [OUT] Flags. |
| 870 | |
| 871 | // returned void in v1.0/v1.1 |
| 872 | __checkReturn |
| 873 | STDMETHOD(GetAssemblyRefProps)( |
| 874 | mdAssemblyRef mdar, // [IN] The AssemblyRef for which to get the properties. |
| 875 | const void **ppbPublicKeyOrToken, // [OUT] Pointer to the public key or token. |
| 876 | ULONG *pcbPublicKeyOrToken, // [OUT] Count of bytes in the public key or token. |
| 877 | LPCSTR *pszName, // [OUT] Buffer to fill with name. |
| 878 | AssemblyMetaDataInternal *pMetaData,// [OUT] Assembly MetaData. |
| 879 | const void **ppbHashValue, // [OUT] Hash blob. |
| 880 | ULONG *pcbHashValue, // [OUT] Count of bytes in the hash blob. |
| 881 | DWORD *pdwAssemblyRefFlags) PURE; // [OUT] Flags. |
| 882 | |
| 883 | // returned void in v1.0/v1.1 |
| 884 | __checkReturn |
| 885 | STDMETHOD(GetFileProps)( |
| 886 | mdFile mdf, // [IN] The File for which to get the properties. |
| 887 | LPCSTR *pszName, // [OUT] Buffer to fill with name. |
| 888 | const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob. |
| 889 | ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob. |
| 890 | DWORD *pdwFileFlags) PURE; // [OUT] Flags. |
| 891 | |
| 892 | // returned void in v1.0/v1.1 |
| 893 | __checkReturn |
| 894 | STDMETHOD(GetExportedTypeProps)( |
| 895 | mdExportedType mdct, // [IN] The ExportedType for which to get the properties. |
| 896 | LPCSTR *pszNamespace, // [OUT] Namespace. |
| 897 | LPCSTR *pszName, // [OUT] Name. |
| 898 | mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides the ExportedType. |
| 899 | mdTypeDef *ptkTypeDef, // [OUT] TypeDef token within the file. |
| 900 | DWORD *pdwExportedTypeFlags) PURE; // [OUT] Flags. |
| 901 | |
| 902 | // returned void in v1.0/v1.1 |
| 903 | __checkReturn |
| 904 | STDMETHOD(GetManifestResourceProps)( |
| 905 | mdManifestResource mdmr, // [IN] The ManifestResource for which to get the properties. |
| 906 | LPCSTR *pszName, // [OUT] Buffer to fill with name. |
| 907 | mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides the ExportedType. |
| 908 | DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within the file. |
| 909 | DWORD *pdwResourceFlags) PURE;// [OUT] Flags. |
| 910 | |
| 911 | __checkReturn |
| 912 | STDMETHOD(FindExportedTypeByName)( // S_OK or error |
| 913 | LPCSTR szNamespace, // [IN] Namespace of the ExportedType. |
| 914 | LPCSTR szName, // [IN] Name of the ExportedType. |
| 915 | mdExportedType tkEnclosingType, // [IN] ExportedType for the enclosing class. |
| 916 | mdExportedType *pmct) PURE; // [OUT] Put ExportedType token here. |
| 917 | |
| 918 | __checkReturn |
| 919 | STDMETHOD(FindManifestResourceByName)( // S_OK or error |
| 920 | LPCSTR szName, // [IN] Name of the ManifestResource. |
| 921 | mdManifestResource *pmmr) PURE; // [OUT] Put ManifestResource token here. |
| 922 | |
| 923 | __checkReturn |
| 924 | STDMETHOD(GetAssemblyFromScope)( // S_OK or error |
| 925 | mdAssembly *ptkAssembly) PURE; // [OUT] Put token here. |
| 926 | |
| 927 | __checkReturn |
| 928 | STDMETHOD(GetCustomAttributeByName)( // S_OK or error |
| 929 | mdToken tkObj, // [IN] Object with Custom Attribute. |
| 930 | LPCUTF8 szName, // [IN] Name of desired Custom Attribute. |
| 931 | const void **ppData, // [OUT] Put pointer to data here. |
| 932 | ULONG *pcbData) PURE; // [OUT] Put size of data here. |
| 933 | |
| 934 | // Note: The return type of this method was void in v1 |
| 935 | __checkReturn |
| 936 | STDMETHOD(GetTypeSpecFromToken)( // S_OK or error. |
| 937 | mdTypeSpec typespec, // [IN] Signature token. |
| 938 | PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. |
| 939 | ULONG *pcbSig) PURE; // [OUT] return size of signature. |
| 940 | |
| 941 | __checkReturn |
| 942 | STDMETHOD(SetUserContextData)( // S_OK or E_NOTIMPL |
| 943 | IUnknown *pIUnk) PURE; // The user context. |
| 944 | |
| 945 | __checkReturn |
| 946 | STDMETHOD_(BOOL, IsValidToken)( // True or False. |
| 947 | mdToken tk) PURE; // [IN] Given token. |
| 948 | |
| 949 | __checkReturn |
| 950 | STDMETHOD(TranslateSigWithScope)( |
| 951 | IMDInternalImport *pAssemImport, // [IN] import assembly scope. |
| 952 | const void *pbHashValue, // [IN] hash value for the import assembly. |
| 953 | ULONG cbHashValue, // [IN] count of bytes in the hash value. |
| 954 | PCCOR_SIGNATURE pbSigBlob, // [IN] signature in the importing scope |
| 955 | ULONG cbSigBlob, // [IN] count of bytes of signature |
| 956 | IMetaDataAssemblyEmit *pAssemEmit, // [IN] assembly emit scope. |
| 957 | IMetaDataEmit *emit, // [IN] emit interface |
| 958 | CQuickBytes *pqkSigEmit, // [OUT] buffer to hold translated signature |
| 959 | ULONG *pcbSig) PURE; // [OUT] count of bytes in the translated signature |
| 960 | |
| 961 | STDMETHOD_(IMetaModelCommon*, GetMetaModelCommon)( // Return MetaModelCommon interface. |
| 962 | ) PURE; |
| 963 | |
| 964 | STDMETHOD_(IUnknown *, GetCachedPublicInterface)(BOOL fWithLock) PURE; // return the cached public interface |
| 965 | __checkReturn |
| 966 | STDMETHOD(SetCachedPublicInterface)(IUnknown *pUnk) PURE; // no return value |
| 967 | STDMETHOD_(UTSemReadWrite*, GetReaderWriterLock)() PURE; // return the reader writer lock |
| 968 | __checkReturn |
| 969 | STDMETHOD(SetReaderWriterLock)(UTSemReadWrite * pSem) PURE; |
| 970 | |
| 971 | STDMETHOD_(mdModule, GetModuleFromScope)() PURE; // [OUT] Put mdModule token here. |
| 972 | |
| 973 | |
| 974 | //----------------------------------------------------------------- |
| 975 | // Additional custom methods |
| 976 | |
| 977 | // finding a particular method |
| 978 | __checkReturn |
| 979 | STDMETHOD(FindMethodDefUsingCompare)( |
| 980 | mdTypeDef classdef, // [IN] given typedef |
| 981 | LPCSTR szName, // [IN] member name |
| 982 | PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature |
| 983 | ULONG cbSigBlob, // [IN] count of bytes in the signature blob |
| 984 | PSIGCOMPARE pSignatureCompare, // [IN] Routine to compare signatures |
| 985 | void* pSignatureArgs, // [IN] Additional info to supply the compare function |
| 986 | mdMethodDef *pmd) PURE; // [OUT] matching memberdef |
| 987 | |
| 988 | // Additional v2 methods. |
| 989 | |
| 990 | //***************************************** |
| 991 | // return a field offset for a given field |
| 992 | //***************************************** |
| 993 | __checkReturn |
| 994 | STDMETHOD(GetFieldOffset)( |
| 995 | mdFieldDef fd, // [IN] fielddef |
| 996 | ULONG *pulOffset) PURE; // [OUT] FieldOffset |
| 997 | |
| 998 | __checkReturn |
| 999 | STDMETHOD(GetMethodSpecProps)( |
| 1000 | mdMethodSpec ms, // [IN] The method instantiation |
| 1001 | mdToken *tkParent, // [OUT] MethodDef or MemberRef |
| 1002 | PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data |
| 1003 | ULONG *pcbSigBlob) PURE; // [OUT] actual size of signature blob |
| 1004 | |
| 1005 | __checkReturn |
| 1006 | STDMETHOD(GetTableInfoWithIndex)( |
| 1007 | ULONG index, // [IN] pass in the table index |
| 1008 | void **pTable, // [OUT] pointer to table at index |
| 1009 | void **pTableSize) PURE; // [OUT] size of table at index |
| 1010 | |
| 1011 | __checkReturn |
| 1012 | STDMETHOD(ApplyEditAndContinue)( |
| 1013 | void *pDeltaMD, // [IN] the delta metadata |
| 1014 | ULONG cbDeltaMD, // [IN] length of pData |
| 1015 | IMDInternalImport **ppv) PURE; // [OUT] the resulting metadata interface |
| 1016 | |
| 1017 | //********************************** |
| 1018 | // Generics APIs |
| 1019 | //********************************** |
| 1020 | __checkReturn |
| 1021 | STDMETHOD(GetGenericParamProps)( // S_OK or error. |
| 1022 | mdGenericParam rd, // [IN] The type parameter |
| 1023 | ULONG* pulSequence, // [OUT] Parameter sequence number |
| 1024 | DWORD* pdwAttr, // [OUT] Type parameter flags (for future use) |
| 1025 | mdToken *ptOwner, // [OUT] The owner (TypeDef or MethodDef) |
| 1026 | DWORD *reserved, // [OUT] The kind (TypeDef/Ref/Spec, for future use) |
| 1027 | LPCSTR *szName) PURE; // [OUT] The name |
| 1028 | |
| 1029 | __checkReturn |
| 1030 | STDMETHOD(GetGenericParamConstraintProps)( // S_OK or error. |
| 1031 | mdGenericParamConstraint rd, // [IN] The constraint token |
| 1032 | mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained |
| 1033 | mdToken *ptkConstraintType) PURE; // [OUT] TypeDef/Ref/Spec constraint |
| 1034 | |
| 1035 | //***************************************************************************** |
| 1036 | // This function gets the "built for" version of a metadata scope. |
| 1037 | // NOTE: if the scope has never been saved, it will not have a built-for |
| 1038 | // version, and an empty string will be returned. |
| 1039 | //***************************************************************************** |
| 1040 | __checkReturn |
| 1041 | STDMETHOD(GetVersionString)( // S_OK or error. |
| 1042 | LPCSTR *pVer) PURE; // [OUT] Put version string here. |
| 1043 | |
| 1044 | |
| 1045 | __checkReturn |
| 1046 | STDMETHOD(SafeAndSlowEnumCustomAttributeByNameInit)(// return S_FALSE if record not found |
| 1047 | mdToken tkParent, // [IN] token to scope the search |
| 1048 | LPCSTR szName, // [IN] CustomAttribute's name to scope the search |
| 1049 | HENUMInternal *phEnum) PURE; // [OUT] The enumerator |
| 1050 | |
| 1051 | __checkReturn |
| 1052 | STDMETHOD(SafeAndSlowEnumCustomAttributeByNameNext)(// return S_FALSE if record not found |
| 1053 | mdToken tkParent, // [IN] token to scope the search |
| 1054 | LPCSTR szName, // [IN] CustomAttribute's name to scope the search |
| 1055 | HENUMInternal *phEnum, // [IN] The enumerator |
| 1056 | mdCustomAttribute *mdAttribute) PURE; // [OUT] The custom attribute that was found |
| 1057 | |
| 1058 | |
| 1059 | __checkReturn |
| 1060 | STDMETHOD(GetTypeDefRefTokenInTypeSpec)(// return S_FALSE if enclosing type does not have a token |
| 1061 | mdTypeSpec tkTypeSpec, // [IN] TypeSpec token to look at |
| 1062 | mdToken *tkEnclosedToken) PURE; // [OUT] The enclosed type token |
| 1063 | |
| 1064 | #define MD_STREAM_VER_1X 0x10000 |
| 1065 | #define MD_STREAM_VER_2_B1 0x10001 |
| 1066 | #define MD_STREAM_VER_2 0x20000 |
| 1067 | STDMETHOD_(DWORD, GetMetadataStreamVersion)() PURE; //returns DWORD with major version of |
| 1068 | // MD stream in senior word and minor version--in junior word |
| 1069 | |
| 1070 | __checkReturn |
| 1071 | STDMETHOD(GetNameOfCustomAttribute)(// S_OK or error |
| 1072 | mdCustomAttribute mdAttribute, // [IN] The Custom Attribute |
| 1073 | LPCUTF8 *pszNamespace, // [OUT] Namespace of Custom Attribute. |
| 1074 | LPCUTF8 *pszName) PURE; // [OUT] Name of Custom Attribute. |
| 1075 | |
| 1076 | STDMETHOD(SetOptimizeAccessForSpeed)(// S_OK or error |
| 1077 | BOOL fOptSpeed) PURE; |
| 1078 | |
| 1079 | STDMETHOD(SetVerifiedByTrustedSource)(// S_OK or error |
| 1080 | BOOL fVerified) PURE; |
| 1081 | |
| 1082 | STDMETHOD(GetRvaOffsetData)( |
| 1083 | DWORD *pFirstMethodRvaOffset, // [OUT] Offset (from start of metadata) to the first RVA field in MethodDef table. |
| 1084 | DWORD *pMethodDefRecordSize, // [OUT] Size of each record in MethodDef table. |
| 1085 | DWORD *pMethodDefCount, // [OUT] Number of records in MethodDef table. |
| 1086 | DWORD *pFirstFieldRvaOffset, // [OUT] Offset (from start of metadata) to the first RVA field in FieldRVA table. |
| 1087 | DWORD *pFieldRvaRecordSize, // [OUT] Size of each record in FieldRVA table. |
| 1088 | DWORD *pFieldRvaCount // [OUT] Number of records in FieldRVA table. |
| 1089 | ) PURE; |
| 1090 | |
| 1091 | //---------------------------------------------------------------------------------------- |
| 1092 | // !!! READ THIS !!! |
| 1093 | // |
| 1094 | // New methods have to be added at the end. The order and signatures of the existing methods |
| 1095 | // have to be preserved. We need to maintain a backward compatibility for this interface to |
| 1096 | // allow ildasm to work on SingleCLR. |
| 1097 | // |
| 1098 | //---------------------------------------------------------------------------------------- |
| 1099 | |
| 1100 | }; // IMDInternalImport |
| 1101 | |
| 1102 | |
| 1103 | // {E03D7730-D7E3-11d2-8C0D-00C04FF7431A} |
| 1104 | EXTERN_GUID(IID_IMDInternalImportENC, 0xe03d7730, 0xd7e3, 0x11d2, 0x8c, 0xd, 0x0, 0xc0, 0x4f, 0xf7, 0x43, 0x1a); |
| 1105 | |
| 1106 | #undef INTERFACE |
| 1107 | #define INTERFACE IMDInternalImportENC |
| 1108 | DECLARE_INTERFACE_(IMDInternalImportENC, IMDInternalImport) |
| 1109 | { |
| 1110 | private: |
| 1111 | using IMDInternalImport::ApplyEditAndContinue; |
| 1112 | public: |
| 1113 | // ENC only methods here. |
| 1114 | STDMETHOD(ApplyEditAndContinue)( // S_OK or error. |
| 1115 | MDInternalRW *pDelta) PURE; // Interface to MD with the ENC delta. |
| 1116 | |
| 1117 | STDMETHOD(EnumDeltaTokensInit)( // return hresult |
| 1118 | HENUMInternal *phEnum) PURE; // [OUT] buffer to fill for enumerator data |
| 1119 | |
| 1120 | }; // IMDInternalImportENC |
| 1121 | |
| 1122 | // {F102C526-38CB-49ed-9B5F-498816AE36E0} |
| 1123 | EXTERN_GUID(IID_IMDInternalEmit, 0xf102c526, 0x38cb, 0x49ed, 0x9b, 0x5f, 0x49, 0x88, 0x16, 0xae, 0x36, 0xe0); |
| 1124 | |
| 1125 | #undef INTERFACE |
| 1126 | #define INTERFACE IMDInternalEmit |
| 1127 | DECLARE_INTERFACE_(IMDInternalEmit, IUnknown) |
| 1128 | { |
| 1129 | STDMETHOD(ChangeMvid)( // S_OK or error. |
| 1130 | REFGUID newMvid) PURE; // GUID to use as the MVID |
| 1131 | |
| 1132 | STDMETHOD(SetMDUpdateMode)( |
| 1133 | ULONG updateMode, ULONG *pPreviousUpdateMode) PURE; |
| 1134 | |
| 1135 | }; // IMDInternalEmit |
| 1136 | |
| 1137 | #ifdef FEATURE_METADATA_CUSTOM_DATA_SOURCE |
| 1138 | |
| 1139 | struct IMDCustomDataSource; |
| 1140 | |
| 1141 | #include "../md/inc/metamodel.h" |
| 1142 | |
| 1143 | // {CC0C8F7A-A00B-493D-80B6-CE0C92491670} |
| 1144 | EXTERN_GUID(IID_IMDCustomDataSource, 0xcc0c8f7a, 0xa00b, 0x493d, 0x80, 0xb6, 0xce, 0xc, 0x92, 0x49, 0x16, 0x70); |
| 1145 | |
| 1146 | #undef INTERFACE |
| 1147 | #define INTERFACE IMDCustomDataSource |
| 1148 | DECLARE_INTERFACE_(IMDCustomDataSource, IUnknown) |
| 1149 | { |
| 1150 | STDMETHOD(GetSchema)(CMiniMdSchema* pSchema) PURE; |
| 1151 | STDMETHOD(GetTableDef)(ULONG32 tableIndex, CMiniTableDef* pTableDef) PURE; |
| 1152 | STDMETHOD(GetBlobHeap)(MetaData::DataBlob* pBlobHeapData) PURE; |
| 1153 | STDMETHOD(GetGuidHeap)(MetaData::DataBlob* pGuidHeapData) PURE; |
| 1154 | STDMETHOD(GetStringHeap)(MetaData::DataBlob* pStringHeapData) PURE; |
| 1155 | STDMETHOD(GetUserStringHeap)(MetaData::DataBlob* pUserStringHeapData) PURE; |
| 1156 | STDMETHOD(GetTableRecords)(ULONG32 tableIndex, MetaData::DataBlob* pTableRecordData) PURE; |
| 1157 | STDMETHOD(GetTableSortable)(ULONG32 tableIndex, BOOL* pSortable) PURE; |
| 1158 | STDMETHOD(GetStorageSignature)(MetaData::DataBlob* pStorageSignature) PURE; |
| 1159 | |
| 1160 | }; // IMDCustomDataSource |
| 1161 | |
| 1162 | // {503F79FB-7AAE-4364-BDA6-8E235D173AEC} |
| 1163 | EXTERN_GUID(IID_IMetaDataDispenserCustom, |
| 1164 | 0x503f79fb, 0x7aae, 0x4364, 0xbd, 0xa6, 0x8e, 0x23, 0x5d, 0x17, 0x3a, 0xec); |
| 1165 | |
| 1166 | #undef INTERFACE |
| 1167 | #define INTERFACE IMetaDataDispenserCustom |
| 1168 | DECLARE_INTERFACE_(IMetaDataDispenserCustom, IUnknown) |
| 1169 | { |
| 1170 | STDMETHOD(OpenScopeOnCustomDataSource)( // Return code. |
| 1171 | IMDCustomDataSource *pCustomSource, // [in] The scope to open. |
| 1172 | DWORD dwOpenFlags, // [in] Open mode flags. |
| 1173 | REFIID riid, // [in] The interface desired. |
| 1174 | IUnknown **ppIUnk) PURE; // [out] Return interface on success. |
| 1175 | |
| 1176 | }; // IMetaDataDispenserCustom |
| 1177 | |
| 1178 | #endif // FEATURE_METADATA_CUSTOM_DATA_SOURCE |
| 1179 | |
| 1180 | #ifdef FEATURE_METADATA_DEBUGGEE_DATA_SOURCE |
| 1181 | struct ICorDebugDataTarget; |
| 1182 | HRESULT CreateRemoteMDInternalRWSource(TADDR mdInternalRWRemoteAddress, ICorDebugDataTarget* pDataTarget, DWORD defines, DWORD dataStructureVersion, IMDCustomDataSource** ppDataSource); |
| 1183 | #endif |
| 1184 | |
| 1185 | #ifdef __HOLDER_H_ |
| 1186 | |
| 1187 | void DECLSPEC_NORETURN ThrowHR(HRESULT hr); |
| 1188 | |
| 1189 | // This wrapper class ensures that the HENUMInternal is EnumTypeDefClose'd no matter how the scope is exited. |
| 1190 | class HENUMTypeDefInternalHolder |
| 1191 | { |
| 1192 | public: |
| 1193 | FORCEINLINE HENUMTypeDefInternalHolder(IMDInternalImport *pInternalImport) |
| 1194 | { |
| 1195 | WRAPPER_NO_CONTRACT; |
| 1196 | |
| 1197 | m_pInternalImport = pInternalImport; |
| 1198 | m_fAcquired = FALSE; |
| 1199 | } |
| 1200 | |
| 1201 | FORCEINLINE VOID EnumTypeDefInit() |
| 1202 | { |
| 1203 | CONTRACTL { |
| 1204 | THROWS; |
| 1205 | } CONTRACTL_END; |
| 1206 | |
| 1207 | _ASSERTE(!m_fAcquired); |
| 1208 | HRESULT hr = m_pInternalImport->EnumTypeDefInit(&m_hEnum); |
| 1209 | if (FAILED(hr)) |
| 1210 | { |
| 1211 | ThrowHR(hr); |
| 1212 | } |
| 1213 | m_fAcquired = TRUE; |
| 1214 | |
| 1215 | } |
| 1216 | |
| 1217 | FORCEINLINE HRESULT EnumTypeDefInitNoThrow() |
| 1218 | { |
| 1219 | WRAPPER_NO_CONTRACT; |
| 1220 | |
| 1221 | _ASSERTE(!m_fAcquired); |
| 1222 | HRESULT hr = m_pInternalImport->EnumTypeDefInit(&m_hEnum); |
| 1223 | if (FAILED(hr)) |
| 1224 | { |
| 1225 | return hr; |
| 1226 | } |
| 1227 | m_fAcquired = TRUE; |
| 1228 | |
| 1229 | return hr; |
| 1230 | } |
| 1231 | |
| 1232 | FORCEINLINE ~HENUMTypeDefInternalHolder() |
| 1233 | { |
| 1234 | WRAPPER_NO_CONTRACT; |
| 1235 | |
| 1236 | if (m_fAcquired) |
| 1237 | { |
| 1238 | m_pInternalImport->EnumTypeDefClose(&m_hEnum); |
| 1239 | } |
| 1240 | } |
| 1241 | |
| 1242 | FORCEINLINE HENUMInternal* operator& () |
| 1243 | { |
| 1244 | LIMITED_METHOD_CONTRACT; |
| 1245 | |
| 1246 | _ASSERTE(m_fAcquired); |
| 1247 | return &m_hEnum; |
| 1248 | } |
| 1249 | |
| 1250 | private: |
| 1251 | FORCEINLINE HENUMTypeDefInternalHolder(const HENUMTypeDefInternalHolder &) |
| 1252 | { |
| 1253 | LIMITED_METHOD_CONTRACT; |
| 1254 | |
| 1255 | _ASSERTE(!"Don't try to assign this class." ); |
| 1256 | } |
| 1257 | |
| 1258 | private: |
| 1259 | IMDInternalImport *m_pInternalImport; |
| 1260 | HENUMInternal m_hEnum; |
| 1261 | BOOL m_fAcquired; |
| 1262 | }; |
| 1263 | |
| 1264 | |
| 1265 | // This wrapper class ensures that the HENUMInternal is EnumClose'd no matter how the scope is exited. |
| 1266 | class HENUMInternalHolder |
| 1267 | { |
| 1268 | public: |
| 1269 | FORCEINLINE HENUMInternalHolder(IMDInternalImport *pInternalImport) |
| 1270 | { |
| 1271 | WRAPPER_NO_CONTRACT; |
| 1272 | |
| 1273 | m_pInternalImport = pInternalImport; |
| 1274 | m_fAcquired = FALSE; |
| 1275 | } |
| 1276 | |
| 1277 | FORCEINLINE BOOL EnumPermissionSetsInit(mdToken tkToken, CorDeclSecurity action) |
| 1278 | { |
| 1279 | CONTRACTL { |
| 1280 | THROWS; |
| 1281 | } CONTRACTL_END; |
| 1282 | |
| 1283 | _ASSERTE(!m_fAcquired); |
| 1284 | HRESULT hr = m_pInternalImport->EnumPermissionSetsInit(tkToken, action, &m_hEnum); |
| 1285 | |
| 1286 | if (hr == CLDB_E_RECORD_NOTFOUND) |
| 1287 | return FALSE; |
| 1288 | |
| 1289 | if (FAILED(hr) ) |
| 1290 | { |
| 1291 | ThrowHR(hr); |
| 1292 | } |
| 1293 | |
| 1294 | m_fAcquired = TRUE; |
| 1295 | |
| 1296 | return TRUE; |
| 1297 | } |
| 1298 | |
| 1299 | FORCEINLINE VOID EnumGlobalFunctionsInit() |
| 1300 | { |
| 1301 | CONTRACTL { |
| 1302 | THROWS; |
| 1303 | } CONTRACTL_END; |
| 1304 | |
| 1305 | _ASSERTE(!m_fAcquired); |
| 1306 | HRESULT hr = m_pInternalImport->EnumGlobalFunctionsInit(&m_hEnum); |
| 1307 | if (FAILED(hr)) |
| 1308 | { |
| 1309 | ThrowHR(hr); |
| 1310 | } |
| 1311 | m_fAcquired = TRUE; |
| 1312 | |
| 1313 | } |
| 1314 | |
| 1315 | |
| 1316 | FORCEINLINE VOID EnumGlobalFieldsInit() |
| 1317 | { |
| 1318 | CONTRACTL { |
| 1319 | THROWS; |
| 1320 | } CONTRACTL_END; |
| 1321 | |
| 1322 | _ASSERTE(!m_fAcquired); |
| 1323 | HRESULT hr = m_pInternalImport->EnumGlobalFieldsInit(&m_hEnum); |
| 1324 | if (FAILED(hr)) |
| 1325 | { |
| 1326 | ThrowHR(hr); |
| 1327 | } |
| 1328 | m_fAcquired = TRUE; |
| 1329 | |
| 1330 | } |
| 1331 | |
| 1332 | FORCEINLINE VOID EnumTypeDefInit() |
| 1333 | { |
| 1334 | CONTRACTL { |
| 1335 | THROWS; |
| 1336 | } CONTRACTL_END; |
| 1337 | |
| 1338 | _ASSERTE(!m_fAcquired); |
| 1339 | HRESULT hr = m_pInternalImport->EnumTypeDefInit(&m_hEnum); |
| 1340 | if (FAILED(hr)) |
| 1341 | { |
| 1342 | ThrowHR(hr); |
| 1343 | } |
| 1344 | m_fAcquired = TRUE; |
| 1345 | } |
| 1346 | |
| 1347 | FORCEINLINE VOID EnumAssociateInit(mdToken tkParent) // [IN] token to scope the search |
| 1348 | { |
| 1349 | CONTRACTL { |
| 1350 | THROWS; |
| 1351 | } CONTRACTL_END; |
| 1352 | |
| 1353 | _ASSERTE(!m_fAcquired); |
| 1354 | IfFailThrow(m_pInternalImport->EnumAssociateInit(tkParent, &m_hEnum)); |
| 1355 | m_fAcquired = TRUE; |
| 1356 | } |
| 1357 | |
| 1358 | FORCEINLINE VOID EnumInit(DWORD tkKind, // [IN] which table to work on |
| 1359 | mdToken tkParent // [IN] token to scope the search |
| 1360 | ) |
| 1361 | { |
| 1362 | CONTRACTL { |
| 1363 | THROWS; |
| 1364 | } CONTRACTL_END; |
| 1365 | |
| 1366 | HRESULT hr = EnumInitNoThrow(tkKind, tkParent); |
| 1367 | if (FAILED(hr)) |
| 1368 | { |
| 1369 | ThrowHR(hr); |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | __checkReturn |
| 1374 | FORCEINLINE HRESULT EnumInitNoThrow(DWORD tkKind, // [IN] which table to work on |
| 1375 | mdToken tkParent // [IN] token to scope the search |
| 1376 | ) |
| 1377 | { |
| 1378 | CONTRACTL { |
| 1379 | NOTHROW; |
| 1380 | } CONTRACTL_END; |
| 1381 | |
| 1382 | _ASSERTE(!m_fAcquired); |
| 1383 | HRESULT hr = m_pInternalImport->EnumInit(tkKind, tkParent, &m_hEnum); |
| 1384 | if (SUCCEEDED(hr)) |
| 1385 | { |
| 1386 | m_fAcquired = TRUE; |
| 1387 | } |
| 1388 | return hr; |
| 1389 | } |
| 1390 | |
| 1391 | FORCEINLINE VOID EnumAllInit(DWORD tkKind // [IN] which table to work on |
| 1392 | ) |
| 1393 | { |
| 1394 | CONTRACTL { |
| 1395 | THROWS; |
| 1396 | } CONTRACTL_END; |
| 1397 | |
| 1398 | _ASSERTE(!m_fAcquired); |
| 1399 | HRESULT hr = m_pInternalImport->EnumAllInit(tkKind, &m_hEnum); |
| 1400 | if (FAILED(hr)) |
| 1401 | { |
| 1402 | ThrowHR(hr); |
| 1403 | } |
| 1404 | m_fAcquired = TRUE; |
| 1405 | |
| 1406 | } |
| 1407 | |
| 1408 | FORCEINLINE ULONG EnumGetCount() |
| 1409 | { |
| 1410 | CONTRACTL { |
| 1411 | NOTHROW; |
| 1412 | GC_NOTRIGGER; |
| 1413 | CONSISTENCY_CHECK(m_fAcquired); |
| 1414 | } CONTRACTL_END; |
| 1415 | |
| 1416 | return m_pInternalImport->EnumGetCount(&m_hEnum); |
| 1417 | } |
| 1418 | |
| 1419 | FORCEINLINE bool EnumNext(mdToken * pTok) |
| 1420 | { |
| 1421 | CONTRACTL { |
| 1422 | NOTHROW; |
| 1423 | GC_NOTRIGGER; |
| 1424 | CONSISTENCY_CHECK(m_fAcquired); |
| 1425 | } CONTRACTL_END; |
| 1426 | |
| 1427 | return m_pInternalImport->EnumNext(&m_hEnum, pTok); |
| 1428 | } |
| 1429 | |
| 1430 | FORCEINLINE void EnumReset() |
| 1431 | { |
| 1432 | CONTRACTL { |
| 1433 | NOTHROW; |
| 1434 | GC_NOTRIGGER; |
| 1435 | CONSISTENCY_CHECK(m_fAcquired); |
| 1436 | } CONTRACTL_END; |
| 1437 | |
| 1438 | return m_pInternalImport->EnumReset(&m_hEnum); |
| 1439 | } |
| 1440 | |
| 1441 | FORCEINLINE ~HENUMInternalHolder() |
| 1442 | { |
| 1443 | WRAPPER_NO_CONTRACT; |
| 1444 | |
| 1445 | if (m_fAcquired) |
| 1446 | { |
| 1447 | // Ignore the error |
| 1448 | (void)m_pInternalImport->EnumClose(&m_hEnum); |
| 1449 | } |
| 1450 | } |
| 1451 | |
| 1452 | FORCEINLINE HENUMInternal* operator& () |
| 1453 | { |
| 1454 | LIMITED_METHOD_CONTRACT; |
| 1455 | |
| 1456 | _ASSERTE(m_fAcquired); |
| 1457 | return &m_hEnum; |
| 1458 | } |
| 1459 | |
| 1460 | private: |
| 1461 | FORCEINLINE HENUMInternalHolder(const HENUMInternalHolder &) |
| 1462 | { |
| 1463 | WRAPPER_NO_CONTRACT; |
| 1464 | |
| 1465 | _ASSERTE(!"Don't try to assign this class." ); |
| 1466 | } |
| 1467 | |
| 1468 | |
| 1469 | protected: |
| 1470 | IMDInternalImport *m_pInternalImport; |
| 1471 | HENUMInternal m_hEnum; |
| 1472 | BOOL m_fAcquired; |
| 1473 | }; |
| 1474 | |
| 1475 | class HENUMInternalMethodImplHolder : protected HENUMInternalHolder |
| 1476 | { |
| 1477 | public: |
| 1478 | FORCEINLINE HENUMInternalMethodImplHolder(IMDInternalImport *pInternalImport) |
| 1479 | : HENUMInternalHolder(pInternalImport) |
| 1480 | { |
| 1481 | WRAPPER_NO_CONTRACT; |
| 1482 | } |
| 1483 | |
| 1484 | FORCEINLINE ~HENUMInternalMethodImplHolder() |
| 1485 | { |
| 1486 | WRAPPER_NO_CONTRACT; |
| 1487 | |
| 1488 | if (m_fAcquired) |
| 1489 | { |
| 1490 | // Ignore the error |
| 1491 | (void)m_pInternalImport->EnumClose(&m_hEnum2); |
| 1492 | } |
| 1493 | } |
| 1494 | |
| 1495 | FORCEINLINE void EnumMethodImplInit(mdToken tkParent // [IN] token to scope the search |
| 1496 | ) |
| 1497 | { |
| 1498 | CONTRACTL { |
| 1499 | THROWS; |
| 1500 | } CONTRACTL_END; |
| 1501 | |
| 1502 | HRESULT hr = EnumMethodImplInitNoThrow(tkParent); |
| 1503 | if (FAILED(hr)) |
| 1504 | { |
| 1505 | ThrowHR(hr); |
| 1506 | } |
| 1507 | } |
| 1508 | |
| 1509 | __checkReturn |
| 1510 | FORCEINLINE HRESULT EnumMethodImplInitNoThrow(mdToken tkParent // [IN] token to scope the search |
| 1511 | ) |
| 1512 | { |
| 1513 | CONTRACTL { |
| 1514 | NOTHROW; |
| 1515 | } CONTRACTL_END; |
| 1516 | |
| 1517 | _ASSERTE(!m_fAcquired); |
| 1518 | HRESULT hr = m_pInternalImport->EnumMethodImplInit(tkParent, &m_hEnum, &m_hEnum2); |
| 1519 | if (SUCCEEDED(hr)) |
| 1520 | { |
| 1521 | m_fAcquired = TRUE; |
| 1522 | } |
| 1523 | return hr; |
| 1524 | } |
| 1525 | |
| 1526 | __checkReturn |
| 1527 | FORCEINLINE HRESULT EnumMethodImplNext( |
| 1528 | mdToken *ptkImpl, |
| 1529 | mdToken *ptkDecl) |
| 1530 | { |
| 1531 | CONTRACTL { |
| 1532 | NOTHROW; |
| 1533 | GC_NOTRIGGER; |
| 1534 | CONSISTENCY_CHECK(m_fAcquired); |
| 1535 | } CONTRACTL_END; |
| 1536 | |
| 1537 | return m_pInternalImport->EnumMethodImplNext(&m_hEnum, &m_hEnum2, ptkImpl, ptkDecl); |
| 1538 | } |
| 1539 | |
| 1540 | FORCEINLINE ULONG EnumMethodImplGetCount() |
| 1541 | { |
| 1542 | CONTRACTL { |
| 1543 | NOTHROW; |
| 1544 | GC_NOTRIGGER; |
| 1545 | CONSISTENCY_CHECK(m_fAcquired); |
| 1546 | } CONTRACTL_END; |
| 1547 | |
| 1548 | return m_pInternalImport->EnumMethodImplGetCount(&m_hEnum, &m_hEnum2); |
| 1549 | } |
| 1550 | |
| 1551 | protected: |
| 1552 | HENUMInternal m_hEnum2; |
| 1553 | }; |
| 1554 | |
| 1555 | #endif //__HOLDER_H_ |
| 1556 | |
| 1557 | #endif // _METADATA_H_ |
| 1558 | |