• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MetadataObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MetadataObject的典型用法代码示例。如果您正苦于以下问题:C# MetadataObject类的具体用法?C# MetadataObject怎么用?C# MetadataObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MetadataObject类属于命名空间,在下文中一共展示了MetadataObject类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FieldSignatureConverter

 internal FieldSignatureConverter(PEFileToObjectModel peFileToObjectModel, MetadataObject moduleField, MemoryReader signatureMemoryReader)
     : base(peFileToObjectModel, signatureMemoryReader, moduleField)
 {
     //^ base;
       //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary.
       this.FirstByte = this.SignatureMemoryReader.ReadByte();
       if (!SignatureHeader.IsFieldSignature(this.FirstByte)) {
     //  Error...
       }
       bool isPinned;
       this.customModifiers = this.GetCustomModifiers(out isPinned);
       this.TypeReference = this.GetTypeReference();
 }
开发者ID:riverar,项目名称:devtools,代码行数:13,代码来源:PEFileToObjectModel.cs


示例2: GetCustomAttributeAtRow

 internal ICustomAttribute GetCustomAttributeAtRow(
   MetadataObject owningObject,
   uint token,
   uint customAttributeRowId
 ) {
   if (customAttributeRowId == 0 || customAttributeRowId > this.PEFileReader.CustomAttributeTable.NumberOfRows) {
     //  MD Error
     return Dummy.CustomAttribute;
   }
   if (this.CustomAttributeArray[customAttributeRowId] == null) {
     lock (GlobalLock.LockingObject) {
       if (this.CustomAttributeArray[customAttributeRowId] == null) {
         CustomAttributeRow customAttribute = this.PEFileReader.CustomAttributeTable[customAttributeRowId];
         if (customAttribute.Parent == token || (customAttribute.Parent == 1 && token == TokenTypeIds.Assembly+1)) {
           uint ctorTokenType = customAttribute.Type & TokenTypeIds.TokenTypeMask;
           uint ctorRowId = customAttribute.Type & TokenTypeIds.RIDMask;
           IMethodReference/*?*/ moduleMethodReference = null;
           if (ctorTokenType == TokenTypeIds.MethodDef) {
             moduleMethodReference = this.GetMethodDefAtRow(ctorRowId);
           } else if (ctorTokenType == TokenTypeIds.MemberRef) {
             moduleMethodReference = this.GetModuleMemberReferenceAtRow(owningObject, ctorRowId) as IMethodReference;
           }
           if (moduleMethodReference == null) {
             //  TODO: MDError
             this.CustomAttributeArray[customAttributeRowId] = Dummy.CustomAttribute;
             return Dummy.CustomAttribute;
           }
           this.currentOwningObject = owningObject;
           if (customAttribute.Value == 0) {
             this.CustomAttributeArray[customAttributeRowId] = 
               this.ModuleReader.metadataReaderHost.Rewrite(this.Module, new CustomAttribute(this, customAttributeRowId, moduleMethodReference, null, null));
           } else {
             //  TODO: Check if customAttribute.Value is within the range
             MemoryBlock signatureMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(customAttribute.Value);
             //  TODO: Error checking enough space in signature memoryBlock.
             MemoryReader memoryReader = new MemoryReader(signatureMemoryBlock);
             this.ModuleReader.metadataReaderHost.StartGuessingGame();
             CustomAttributeDecoder customAttrDecoder = new CustomAttributeDecoder(this, memoryReader, customAttributeRowId, moduleMethodReference);
             while (customAttrDecoder.decodeFailed && this.ModuleReader.metadataReaderHost.TryNextPermutation())
               customAttrDecoder = new CustomAttributeDecoder(this, memoryReader, customAttributeRowId, moduleMethodReference);
             if (!customAttrDecoder.decodeFailed)
               this.ModuleReader.metadataReaderHost.WinGuessingGame();
             //else
             //TODO: error
             this.CustomAttributeArray[customAttributeRowId] = customAttrDecoder.CustomAttribute;
           }
         } else {
           //  MD Error
           this.CustomAttributeArray[customAttributeRowId] = Dummy.CustomAttribute;
         }
       }
     }
   }
   ICustomAttribute/*?*/ ret = this.CustomAttributeArray[customAttributeRowId];
   //^ assert ret != null;
   return ret;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:57,代码来源:PEFileToObjectModel.cs


示例3: GetCustomAttributeInfo

 internal void GetCustomAttributeInfo(
   MetadataObject metadataObject,
   out uint customAttributeRowIdStart,
   out uint customAttributeRowIdEnd
 ) {
   customAttributeRowIdStart = 0;
   customAttributeRowIdEnd = 0;
   if (metadataObject.TokenValue == 0xFFFFFFFF)
     return;
   uint customAttributeCount;
   customAttributeRowIdStart = this.PEFileReader.CustomAttributeTable.FindCustomAttributesForToken(metadataObject.TokenValue, out customAttributeCount);
   customAttributeRowIdEnd = customAttributeRowIdStart + customAttributeCount;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:13,代码来源:PEFileToObjectModel.cs


示例4: GetReferenceForToken

 //  Caller must lock this...
 internal object/*?*/ GetReferenceForToken(
   MetadataObject owningObject,
   uint token
 ) {
   uint tokenKind = token & TokenTypeIds.TokenTypeMask;
   uint rowId = token & TokenTypeIds.RIDMask;
   switch (tokenKind) {
     case TokenTypeIds.TypeDef: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeDefTable.NumberOfRows) {
           //  handle Error
           return null;
         }
         return this.GetTypeDefinitionAtRow(rowId);
       }
     case TokenTypeIds.TypeRef: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeRefTable.NumberOfRows) {
           //  handle Error
           return null;
         }
         return this.GetTypeRefReferenceAtRow(rowId);
       }
     case TokenTypeIds.TypeSpec: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeSpecTable.NumberOfRows) {
           //  handle Error
           return null;
         }
         return this.GetTypeSpecReferenceAtRow(owningObject, rowId).UnderlyingModuleTypeReference;
       }
     case TokenTypeIds.MethodDef:
       if (rowId == 0 || rowId > this.PEFileReader.MethodTable.NumberOfRows) {
         //  handle Error
         return null;
       }
       return this.GetMethodDefAtRow(rowId);
     case TokenTypeIds.FieldDef:
       if (rowId == 0 || rowId > this.PEFileReader.FieldTable.NumberOfRows) {
         //  handle Error
         return null;
       }
       return this.GetFieldDefAtRow(rowId);
     case TokenTypeIds.MemberRef:
       if (rowId == 0 || rowId > this.PEFileReader.MemberRefTable.NumberOfRows) {
         //  handle Error
         return null;
       }
       return this.GetModuleMemberReferenceAtRow(owningObject, rowId);
     case TokenTypeIds.MethodSpec:
       if (rowId == 0 || rowId > this.PEFileReader.MethodSpecTable.NumberOfRows) {
         //  handle Error
         return null;
       }
       return this.GetMethodSpecAtRow(owningObject, rowId);
     default:
       return null;
   }
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:57,代码来源:PEFileToObjectModel.cs


示例5: GetFieldReferenceForToken

 //  Caller should lock this...
 internal IFieldReference GetFieldReferenceForToken(
   MetadataObject owningObject,
   uint fieldRefToken
 ) {
   uint tokenKind = fieldRefToken & TokenTypeIds.TokenTypeMask;
   uint rowId = fieldRefToken & TokenTypeIds.RIDMask;
   switch (tokenKind) {
     case TokenTypeIds.FieldDef:
       FieldDefinition/*?*/ fieldDef = this.GetFieldDefAtRow(rowId);
       if (fieldDef == null)
         return Dummy.FieldReference;
       else
         return fieldDef;
     case TokenTypeIds.MemberRef: {
         var fieldRef = this.GetModuleMemberReferenceAtRow(owningObject, rowId) as IFieldReference;
         if (fieldRef == null) {
           //  MDError/ILError?
           return Dummy.FieldReference;
         } else {
           return fieldRef;
         }
       }
     default:
       return Dummy.FieldReference;
   }
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:27,代码来源:PEFileToObjectModel.cs


示例6: GetMethodReferenceForToken

 //  Caller should lock this...
 internal IMethodReference GetMethodReferenceForToken(
   MetadataObject owningObject,
   uint methodRefToken
 ) {
   uint tokenKind = methodRefToken & TokenTypeIds.TokenTypeMask;
   uint rowId = methodRefToken & TokenTypeIds.RIDMask;
   IMethodReference/*?*/ methRef = null;
   switch (tokenKind) {
     case TokenTypeIds.MethodDef:
       methRef = this.GetMethodDefAtRow(rowId);
       break;
     case TokenTypeIds.MethodSpec:
       methRef = this.GetMethodSpecAtRow(owningObject, rowId);
       break;
     case TokenTypeIds.MemberRef:
       methRef = this.GetModuleMemberReferenceAtRow(owningObject, rowId) as IMethodReference;
       break;
   }
   if (methRef == null) {
     //  Error...
     methRef = Dummy.MethodReference;
   }
   return methRef;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:25,代码来源:PEFileToObjectModel.cs


示例7: GetModuleMemberReferenceAtRowWorker

    //^ invariant this.PEFileReader.MethodSpecTable.NumberOfRows >= 1 ==> this.MethodSpecHashtable != null;

    internal MemberReference/*?*/ GetModuleMemberReferenceAtRowWorker(
      MetadataObject owningObject,
      uint memberRefRowId
    ) {
      if (memberRefRowId == 0 || memberRefRowId > this.PEFileReader.MemberRefTable.NumberOfRows) {
        return null;
      }
      if (this.ModuleMemberReferenceArray[memberRefRowId] == null) {
        MemberRefRow memberRefRow = this.PEFileReader.MemberRefTable[memberRefRowId];
        uint classTokenType = memberRefRow.Class & TokenTypeIds.TokenTypeMask;
        uint classRowId = memberRefRow.Class & TokenTypeIds.RIDMask;
        IModuleTypeReference/*?*/ parentTypeReference = null;
        switch (classTokenType) {
          case TokenTypeIds.TypeDef:
            parentTypeReference = this.GetTypeDefinitionAtRowWorker(classRowId);
            break;
          case TokenTypeIds.TypeRef:
            parentTypeReference = this.GetTypeRefReferenceAtRowWorker(classRowId);
            break;
          case TokenTypeIds.TypeSpec:
            parentTypeReference = this.GetTypeSpecReferenceAtRow(owningObject, classRowId).UnderlyingModuleTypeReference;
            break;
          case TokenTypeIds.MethodDef: {
              MethodDefinition/*?*/ methodDef = this.GetMethodDefAtRow(classRowId);
              if (methodDef == null) {
                //  Error...
                return null;
              }
              parentTypeReference = methodDef.OwningModuleType;
              break;
            }
          case TokenTypeIds.ModuleRef: {
              ModuleReference/*?*/ modRef = this.GetModuleReferenceAt(classRowId);
              if (modRef == null) {
                //  MDError
                return null;
              }
              Module/*?*/ module = this.ResolveModuleRefReference(modRef);
              if (module == null) {
                //TODO: MDError...
                return null;
              }
              PEFileToObjectModel modulePEFileToObjectModel = module.PEFileToObjectModel;
              parentTypeReference = modulePEFileToObjectModel._Module_;
              break;
            }
          default: {
              //  MDError...
              return null;
            }
        }
        if (parentTypeReference == null) {
          //  Error...
          return null;
        }
        MemberReference retModuleMemberReference;
        IName name = this.GetNameFromOffset(memberRefRow.Name);
        byte firstByte = this.PEFileReader.BlobStream.GetByteAt(memberRefRow.Signature, 0);
        IModuleGenericTypeInstance/*?*/ genericTypeInstance = parentTypeReference as IModuleGenericTypeInstance;
        IModuleSpecializedNestedTypeReference/*?*/ specializedNestedTypeReference = parentTypeReference as IModuleSpecializedNestedTypeReference;
        if (SignatureHeader.IsFieldSignature(firstByte)) {
          if (genericTypeInstance != null) {
            //The same memberRef token can be shared by distinct instance references, therefore recompute every time.
            return new GenericInstanceFieldReference(this, memberRefRowId, genericTypeInstance, name);
          } else if (specializedNestedTypeReference != null) {
            //The same memberRef token can be shared by distinct instance references, therefore recompute every time.
            return new SpecializedNestedTypeFieldReference(this, memberRefRowId, parentTypeReference, specializedNestedTypeReference, name);
          } else {
            retModuleMemberReference = new FieldReference(this, memberRefRowId, parentTypeReference, name);
          }
        } else if (SignatureHeader.IsMethodSignature(firstByte)) {
          if (genericTypeInstance != null) {
            //The same memberRef token can be shared by distinct instance references, therefore recompute every time.
            return new GenericInstanceMethodReference(this, memberRefRowId, genericTypeInstance, name, firstByte);
          } else if (specializedNestedTypeReference != null) {
            //The same memberRef token can be shared by distinct instance references, therefore recompute every time.
            return new SpecializedNestedTypeMethodReference(this, memberRefRowId, parentTypeReference, specializedNestedTypeReference, name, firstByte);
          } else {
            retModuleMemberReference = new MethodReference(this, memberRefRowId, parentTypeReference, name, firstByte);
          }
        } else {
          //  MD Error
          return null;
        }
        this.ModuleMemberReferenceArray[memberRefRowId] = retModuleMemberReference;
      }
      MemberReference/*?*/ ret = this.ModuleMemberReferenceArray[memberRefRowId];
      return ret;
    }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:91,代码来源:PEFileToObjectModel.cs


示例8: SignatureConverter

 internal SignatureConverter(
   PEFileToObjectModel peFileToObjectModel,
   MemoryReader signatureMemoryReader,
   MetadataObject metadataOwnerObject
 )
   //^ requires signatureMemoryReader.Length > 0;
 {
   this.PEFileToObjectModel = peFileToObjectModel;
   this.SignatureMemoryReader = signatureMemoryReader;
   this.MetadataOwnerObject = metadataOwnerObject;
   this.ModuleMethodReference = metadataOwnerObject as IMethodReference;
   this.ModuleMemberReference = metadataOwnerObject as ITypeMemberReference;
   TypeMember/*?*/ moduleTypeMember = metadataOwnerObject as TypeMember;
   if (moduleTypeMember != null) {
     this.ModuleGenericType = moduleTypeMember.ContainingTypeDefinition as TypeBase;
     this.ModuleGenericMethod = moduleTypeMember as GenericMethod;
     return;
   }
   var moduleGenericType = metadataOwnerObject as TypeBase;
   if (moduleGenericType != null) {
     this.ModuleGenericType = moduleGenericType;
     return;
   }
   GenericTypeParameter/*?*/ genericTypeParam = metadataOwnerObject as GenericTypeParameter;
   if (genericTypeParam != null) {
     this.ModuleGenericType = genericTypeParam.OwningGenericType;
     return;
   }
   GenericMethodParameter/*?*/ genericMethodParam = metadataOwnerObject as GenericMethodParameter;
   if (genericMethodParam != null) {
     this.ModuleGenericType = genericMethodParam.OwningGenericMethod.ContainingTypeDefinition as TypeBase;
     this.ModuleGenericMethod = genericMethodParam.OwningGenericMethod;
     return;
   }
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:35,代码来源:PEFileToObjectModel.cs


示例9: GetModuleMemberReferenceAtRowWorker

    //^ invariant this.PEFileReader.MethodSpecTable.NumberOfRows >= 1 ==> this.MethodSpecHashtable != null;

    internal ITypeMemberReference/*?*/ GetModuleMemberReferenceAtRowWorker(
      MetadataObject owningObject,
      uint memberRefRowId
    ) {
      if (memberRefRowId == 0 || memberRefRowId > this.PEFileReader.MemberRefTable.NumberOfRows) {
        return null;
      }
      if (this.ModuleMemberReferenceArray[memberRefRowId] == null) {
        MemberRefRow memberRefRow = this.PEFileReader.MemberRefTable[memberRefRowId];
        uint classTokenType = memberRefRow.Class & TokenTypeIds.TokenTypeMask;
        uint classRowId = memberRefRow.Class & TokenTypeIds.RIDMask;
        ITypeReference/*?*/ parentTypeReference = null;
        switch (classTokenType) {
          case TokenTypeIds.TypeDef:
            parentTypeReference = this.GetTypeDefinitionAtRow(classRowId);
            break;
          case TokenTypeIds.TypeRef:
            parentTypeReference = this.GetTypeRefReferenceAtRow(classRowId);
            break;
          case TokenTypeIds.TypeSpec:
            parentTypeReference = this.GetTypeSpecReferenceAtRow(owningObject, classRowId).UnderlyingModuleTypeReference;
            break;
          case TokenTypeIds.MethodDef: {
              var/*?*/ methodDef = this.GetMethodDefAtRow(classRowId);
              if (methodDef == null) {
                //  Error...
                return null;
              }
              parentTypeReference = methodDef.ContainingType;
              break;
            }
          case TokenTypeIds.ModuleRef: {
              ModuleReference/*?*/ modRef = this.GetModuleReferenceAt(classRowId);
              if (modRef == null) {
                //  MDError
                return null;
              }
              var module = this.ResolveModuleRefReference(modRef) as Module;
              if (module == null) {
                //TODO: MDError...
                return null;
              }
              PEFileToObjectModel modulePEFileToObjectModel = module.PEFileToObjectModel;
              parentTypeReference = modulePEFileToObjectModel._Module_;
              break;
            }
          default: {
              //  MDError...
              return null;
            }
        }
        if (parentTypeReference == null) {
          //  Error...
          return null;
        }
        MemberReference retModuleMemberReference;
        IName name = this.GetNameFromOffset(memberRefRow.Name);
        byte firstByte = this.PEFileReader.BlobStream.GetByteAt(memberRefRow.Signature, 0);
        var genericTypeInstance = parentTypeReference as IGenericTypeInstanceReference;
        var specializedNestedTypeReference = parentTypeReference as ISpecializedNestedTypeReference;
        if (SignatureHeader.IsFieldSignature(firstByte)) {
          if (genericTypeInstance != null || specializedNestedTypeReference != null) {
            //The same memberRef token can be shared by distinct instance references, therefore special caching is required
            FieldReference unspecializedFieldReference = this.UnspecializedMemberReferenceArray[memberRefRowId] as FieldReference;
            if (unspecializedFieldReference == null) {
              unspecializedFieldReference = new FieldReference(this, memberRefRowId, TypeCache.Unspecialize(parentTypeReference), name);
              this.UnspecializedMemberReferenceArray[memberRefRowId] = unspecializedFieldReference;
            }
            uint key1 = parentTypeReference.InternedKey;
            uint key2 = unspecializedFieldReference.InternedKey;
            var specializedField = this.SpecializedFieldHashtable.Find(key1, key2);
            if (specializedField == null) {
              specializedField = new SpecializedFieldReference(parentTypeReference, unspecializedFieldReference, this.InternFactory);
              this.SpecializedFieldHashtable.Add(key1, key2, specializedField);
            }
            return specializedField;
          } else {
            retModuleMemberReference = new FieldReference(this, memberRefRowId, parentTypeReference, name);
          }
        } else if (SignatureHeader.IsMethodSignature(firstByte)) {
          if (genericTypeInstance != null || specializedNestedTypeReference != null) {
            //The same memberRef token can be shared by distinct instance references, therefore special caching is required
            MethodReference unspecializedMethodReference = this.UnspecializedMemberReferenceArray[memberRefRowId] as MethodReference;
            if (unspecializedMethodReference == null) {
              unspecializedMethodReference = new MethodReference(this, memberRefRowId, TypeCache.Unspecialize(parentTypeReference), name, firstByte);
              this.UnspecializedMemberReferenceArray[memberRefRowId] = unspecializedMethodReference;
            }
            uint key1 = parentTypeReference.InternedKey;
            uint key2 = unspecializedMethodReference.InternedKey;
            var specializedMethod = this.SpecializedMethodHashtable.Find(key1, key2);
            if (specializedMethod == null) {
              specializedMethod = new SpecializedMethodReference(parentTypeReference, unspecializedMethodReference, this.InternFactory);
              this.SpecializedMethodHashtable.Add(key1, key2, specializedMethod);
            }
            return specializedMethod;
          } else {
            retModuleMemberReference = new MethodReference(this, memberRefRowId, parentTypeReference, name, firstByte);
          }
//.........这里部分代码省略.........
开发者ID:Biegal,项目名称:Afterthought,代码行数:101,代码来源:PEFileToObjectModel.cs


示例10: GetMarshallingInformation

 internal IMarshallingInformation GetMarshallingInformation(
   MetadataObject metadataObject
 ) {
   uint fieldMarshalRowId = this.PEFileReader.FieldMarshalTable.GetFieldMarshalRowId(metadataObject.TokenValue);
   if (fieldMarshalRowId == 0)
     return Dummy.MarshallingInformation;
   FieldMarshalRow fieldMarshalRow = this.PEFileReader.FieldMarshalTable[fieldMarshalRowId];
   MemoryBlock fieldMarshalMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(fieldMarshalRow.NativeType);
   MemoryReader memoryReader = new MemoryReader(fieldMarshalMemoryBlock);
   System.Runtime.InteropServices.UnmanagedType unmanagedType = (System.Runtime.InteropServices.UnmanagedType)memoryReader.ReadByte();
   if (memoryReader.NotEndOfBytes) {
     if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValArray) {
       uint numElements = (uint)memoryReader.ReadCompressedUInt32();
       System.Runtime.InteropServices.UnmanagedType elementType = System.Runtime.InteropServices.UnmanagedType.AsAny;
       if (memoryReader.NotEndOfBytes)
         elementType = (System.Runtime.InteropServices.UnmanagedType)memoryReader.ReadByte();
       return new ByValArrayMarshallingInformation(elementType, numElements);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler) {
       string marshallerName;
       string marshallerArgument;
       memoryReader.ReadInt16(); //  Deliberate Skip...
       int byteLen = memoryReader.ReadCompressedUInt32();
       if (byteLen == -1 || byteLen == 0)
         marshallerName = string.Empty;
       else
         marshallerName = memoryReader.ReadUTF8WithSize(byteLen);
       ITypeReference/*?*/ marshaller = this.GetSerializedTypeNameAsTypeReference(marshallerName);
       if (marshaller == null) marshaller = Dummy.TypeReference;
       byteLen = memoryReader.ReadCompressedUInt32();
       if (byteLen == -1 || byteLen == 0)
         marshallerArgument = string.Empty;
       else
         marshallerArgument = memoryReader.ReadUTF8WithSize(byteLen);
       return new CustomMarshallingInformation(marshaller, marshallerArgument);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.LPArray) {
       System.Runtime.InteropServices.UnmanagedType elementType = (System.Runtime.InteropServices.UnmanagedType)memoryReader.ReadByte();
       int paramIndex = -1;
       uint flag = 0;
       uint numElements = 0;
       if (memoryReader.NotEndOfBytes)
         paramIndex = (int)memoryReader.ReadCompressedUInt32();
       if (memoryReader.NotEndOfBytes)
         numElements = (uint)memoryReader.ReadCompressedUInt32();
       if (memoryReader.NotEndOfBytes) {
         flag = (uint)memoryReader.ReadCompressedUInt32();
         if (flag == 0) {
           //TODO: check that paramIndex is 0
           paramIndex = -1; //paramIndex is just a place holder so that numElements can be present
         }
       }
       return new LPArrayMarshallingInformation(elementType, paramIndex, numElements);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.SafeArray) {
       System.Runtime.InteropServices.VarEnum elementType = (System.Runtime.InteropServices.VarEnum)memoryReader.ReadByte();
       string subType = string.Empty;
       if (memoryReader.NotEndOfBytes) {
         int byteLen = memoryReader.ReadCompressedUInt32();
         if (byteLen > 0)
           subType = memoryReader.ReadUTF8WithSize(byteLen);
       }
       ITypeReference/*?*/ subTypeRef = this.GetSerializedTypeNameAsTypeReference(subType);
       if (subTypeRef == null) subTypeRef = Dummy.TypeReference;
       return new SafeArrayMarshallingInformation(elementType, subTypeRef);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValTStr) {
       uint numElements = (uint)memoryReader.ReadCompressedUInt32();
       return new ByValTStrMarshallingInformation(numElements);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.Interface) {
       uint iidParameterIndex = (uint)memoryReader.ReadCompressedUInt32();
       return new IidParameterIndexMarshallingInformation(iidParameterIndex);
     } else {
       //TODO: error blob should not have extra info unless one of the above types.
     }
   }
   return new SimpleMarshallingInformation(unmanagedType);
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:74,代码来源:PEFileToObjectModel.cs


示例11: GetDefaultValue

 internal IMetadataConstant GetDefaultValue(
   MetadataObject metadataObject
 ) {
   uint constRowId = this.PEFileReader.ConstantTable.GetConstantRowId(metadataObject.TokenValue);
   if (constRowId == 0)
     return Dummy.Constant;
   ConstantRow constRow = this.PEFileReader.ConstantTable[constRowId];
   MemoryBlock constValueMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(constRow.Value);
   MemoryReader memoryReader = new MemoryReader(constValueMemoryBlock);
   switch (constRow.Type) {
     case ElementType.Boolean: {
         byte val = memoryReader.ReadByte();
         return new ConstantExpression(this.PlatformType.SystemBoolean, val != 0);
       }
     case ElementType.Char:
       return new ConstantExpression(this.PlatformType.SystemChar, memoryReader.ReadChar());
     case ElementType.Int8:
       return new ConstantExpression(this.PlatformType.SystemInt8, memoryReader.ReadSByte());
     case ElementType.Int16:
       return new ConstantExpression(this.PlatformType.SystemInt16, memoryReader.ReadInt16());
     case ElementType.Int32:
       return new ConstantExpression(this.PlatformType.SystemInt32, memoryReader.ReadInt32());
     case ElementType.Int64:
       return new ConstantExpression(this.PlatformType.SystemInt64, memoryReader.ReadInt64());
     case ElementType.UInt8:
       return new ConstantExpression(this.PlatformType.SystemUInt8, memoryReader.ReadByte());
     case ElementType.UInt16:
       return new ConstantExpression(this.PlatformType.SystemUInt16, memoryReader.ReadUInt16());
     case ElementType.UInt32:
       return new ConstantExpression(this.PlatformType.SystemUInt32, memoryReader.ReadUInt32());
     case ElementType.UInt64:
       return new ConstantExpression(this.PlatformType.SystemUInt64, memoryReader.ReadUInt64());
     case ElementType.Single:
       return new ConstantExpression(this.PlatformType.SystemFloat32, memoryReader.ReadSingle());
     case ElementType.Double:
       return new ConstantExpression(this.PlatformType.SystemFloat64, memoryReader.ReadDouble());
     case ElementType.String: {
         int byteLen = memoryReader.Length;
         string/*?*/ value;
         if (byteLen == -1) {
           value = null;
         } else if (byteLen == 0) {
           value = string.Empty;
         } else {
           value = memoryReader.ReadUTF16WithSize(byteLen);
         }
         return new ConstantExpression(this.PlatformType.SystemString, value);
       }
     case ElementType.Class:
       return new ConstantExpression(this.PlatformType.SystemObject, null);
   }
   //  MDError...
   return Dummy.Constant;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:54,代码来源:PEFileToObjectModel.cs


示例12: GetTypeReferenceForToken

 internal ITypeReference/*?*/ GetTypeReferenceForToken(
   MetadataObject owningObject,
   uint token,
   bool mustBeStruct
 ) {
   uint tokenType = token & TokenTypeIds.TokenTypeMask;
   uint rowId = token & TokenTypeIds.RIDMask;
   switch (tokenType) {
     case TokenTypeIds.TypeDef: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeDefTable.NumberOfRows) {
           //  handle Error
         }
         return this.GetTypeDefinitionAtRow(rowId);
       }
     case TokenTypeIds.TypeRef: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeRefTable.NumberOfRows) {
           //  handle Error
         }
         return this.GetTypeRefReferenceAtRow(rowId, mustBeStruct);
       }
     case TokenTypeIds.TypeSpec: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeSpecTable.NumberOfRows) {
           //  handle Error
         }
         return this.GetTypeSpecReferenceAtRow(owningObject, rowId).UnderlyingModuleTypeReference;
       }
   }
   return null;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:29,代码来源:PEFileToObjectModel.cs


示例13: GetTypeSpecReferenceAtRow

 internal TypeSpecReference/*?*/ GetTypeSpecReferenceAtRow(
   MetadataObject owningObject,
   uint typeSpecRowId
 )
   //^ requires this.PEFileReader.TypeSpecTable.NumberOfRows >= 1;
   //^ requires typeSpecRowId >= 1 && typeSpecRowId <= this.PEFileReader.TypeSpecTable.NumberOfRows;
 {
   if (typeSpecRowId > this.PEFileReader.TypeSpecTable.NumberOfRows || typeSpecRowId == 0) {
     return null;
   }
   uint ownerId = owningObject.TokenValue;
   //^ assert this.ModuleTypeSpecHashtable != null;
   TypeSpecReference/*?*/ typeSpecReference = this.ModuleTypeSpecHashtable.Find(ownerId, typeSpecRowId);
   if (typeSpecReference == null) {
     lock (GlobalLock.LockingObject) {
       typeSpecReference = this.ModuleTypeSpecHashtable.Find(ownerId, typeSpecRowId);
       if (typeSpecReference == null) {
         typeSpecReference = new TypeSpecReference(this, typeSpecRowId, owningObject);
       }
       this.ModuleTypeSpecHashtable.Add(ownerId, typeSpecRowId, typeSpecReference);
     }
   }
   return typeSpecReference;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:24,代码来源:PEFileToObjectModel.cs


示例14: GetSecurityAttributeInfo

 internal void GetSecurityAttributeInfo(
   MetadataObject metadataObject,
   out uint securityAttributeRowIdStart,
   out uint securityAttributeRowIdEnd
 ) {
   securityAttributeRowIdStart = 0;
   securityAttributeRowIdEnd = 0;
   if (metadataObject.TokenValue == 0xFFFFFFFF)
     return;
   uint securityAttributeCount;
   securityAttributeRowIdStart = this.PEFileReader.DeclSecurityTable.FindSecurityAttributesForToken(metadataObject.TokenValue, out securityAttributeCount);
   securityAttributeRowIdEnd = securityAttributeRowIdStart + securityAttributeCount;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:13,代码来源:PEFileToObjectModel.cs


示例15: GetSecurityAttributeAtRow

 internal ISecurityAttribute GetSecurityAttributeAtRow(
   MetadataObject owningObject,
   uint securityAttributeRowId
 ) {
   if (securityAttributeRowId >= this.DeclSecurityArray.Length) {
     //  MD Error
     return Dummy.SecurityAttribute;
   }
   if (this.DeclSecurityArray[securityAttributeRowId] == null) {
     lock (GlobalLock.LockingObject) {
       if (this.DeclSecurityArray[securityAttributeRowId] == null) {
         DeclSecurityRow declSecurity = this.PEFileReader.DeclSecurityTable[securityAttributeRowId];
         if (declSecurity.Parent == owningObject.TokenValue) {
           this.DeclSecurityArray[securityAttributeRowId] = new SecurityAttribute(this, securityAttributeRowId, (SecurityAction)declSecurity.ActionFlags);
         } else {
           //  MD Error
           this.DeclSecurityArray[securityAttributeRowId] = Dummy.SecurityAttribute;
         }
       }
     }
   }
   ISecurityAttribute/*?*/ ret = this.DeclSecurityArray[securityAttributeRowId];
   //^ assert ret != null;
   return ret;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:25,代码来源:PEFileToObjectModel.cs


示例16: GetModuleMemberReferenceAtRow

 internal ITypeMemberReference/*?*/ GetModuleMemberReferenceAtRow(
   MetadataObject owningObject,
   uint memberRefRowId
 ) {
   if (memberRefRowId == 0 || memberRefRowId > this.PEFileReader.MemberRefTable.NumberOfRows) {
     return null;
   }
   if (this.ModuleMemberReferenceArray[memberRefRowId] == null) {
     lock (GlobalLock.LockingObject) {
       //The same memberRef token can sometimes be shared by references that are distinct in the object model.
       //Hence the worker decides whether to cache or not.
       return this.GetModuleMemberReferenceAtRowWorker(owningObject, memberRefRowId);
     }
   }
   MemberReference/*?*/ ret = this.ModuleMemberReferenceArray[memberRefRowId];
   return ret;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:17,代码来源:PEFileToObjectModel.cs


示例17: MethodSpecSignatureConverter

 //^ [NotDelayed]
 internal MethodSpecSignatureConverter(
   PEFileToObjectModel peFileToObjectModel,
   MetadataObject owningObject,
   MemoryReader signatureMemoryReader
 )
   : base(peFileToObjectModel, signatureMemoryReader, owningObject) {
   //^ this.GenericTypeArguments = TypeCache.EmptyTypeArray;
   //^ this.SignatureMemoryReader = signatureMemoryReader;
   //^ base;
   byte firstByte = this.SignatureMemoryReader.ReadByte();
   if (!SignatureHeader.IsGenericInstanceSignature(firstByte)) {
     //  MDError
   }
   int typeArgCount = this.SignatureMemoryReader.ReadCompressedUInt32();
   ITypeReference/*?*/[] typeRefArr = new ITypeReference/*?*/[typeArgCount];
   for (int i = 0; i < typeArgCount; ++i) {
     typeRefArr[i] = this.GetTypeReference();
   }
   this.GenericTypeArguments = new EnumerableArrayWrapper<ITypeReference/*?*/, ITypeReference>(typeRefArr, Dummy.TypeReference);
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:21,代码来源:PEFileToObjectModel.cs


示例18: GetMethodSpecAtRow

 internal IMethodReference/*?*/ GetMethodSpecAtRow(
   MetadataObject owningObject,
   uint methodSpecRowId
 ) {
   if (methodSpecRowId == 0 || methodSpecRowId > this.PEFileReader.MethodSpecTable.NumberOfRows) {
     return null;
   }
   uint ownerId = owningObject.TokenValue;
   IGenericMethodInstanceReference/*?*/ methodSpecReference = this.ModuleMethodSpecHashtable.Find(ownerId, methodSpecRowId);
   if (methodSpecReference == null) {
     lock (GlobalLock.LockingObject) {
       methodSpecReference = this.ModuleMethodSpecHashtable.Find(ownerId, methodSpecRowId);
       if (methodSpecReference == null) {
         MethodSpecRow methodSpecRow = this.PEFileReader.MethodSpecTable[methodSpecRowId];
         uint methToken = methodSpecRow.Method;
         uint tokenKind = methToken & TokenTypeIds.TokenTypeMask;
         uint rowId = methToken & TokenTypeIds.RIDMask;
         IMethodReference/*?*/ moduleMethod;
         if (tokenKind == TokenTypeIds.MethodDef) {
           moduleMethod = this.GetMethodDefAtRow(rowId);
         } else if (tokenKind == TokenTypeIds.MemberRef) {
           moduleMethod = this.GetModuleMemberReferenceAtRow(owningObject, rowId) as IMethodReference;
         } else {
           //  MDError...
           return null;
         }
         if (moduleMethod == null) {
           //  MDError...
           return null;
         }
         //  TODO: error checking offset in range
         MemoryBlock signatureMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(methodSpecRow.Instantiation);
         //  TODO: Error checking enough space in signature memoryBlock.
         MemoryReader memoryReader = new MemoryReader(signatureMemoryBlock);
         //  TODO: Check if this is really a method spec signature there.
         MethodSpecSignatureConverter methodSpecSigConv = new MethodSpecSignatureConverter(this, owningObject, memoryReader);
         methodSpecReference = new GenericMethodInstanceReferenceWithToken(moduleMethod, methodSpecSigConv.GenericTypeArguments, this.InternFactory,
           methodSpecRowId | TokenTypeIds.MethodSpec);
         this.ModuleMethodSpecHashtable.Add(ownerId, methodSpecRowId, methodSpecReference);
       }
     }
   }
   return methodSpecReference;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:44,代码来源:PEFileToObjectModel.cs



注:本文中的MetadataObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MetadataReader类代码示例发布时间:2022-05-24
下一篇:
C# MetadataImageReference类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap