Exemple #1
0
        public TypeSpecMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            byte sizeOfBlobIndex = indexDetails.GetSizeOfBlobIndex();

            _signiture = new BlobIndex(sizeOfBlobIndex, contents, Signatures.Signatures.TypeSpecification, offset);
        }
Exemple #2
0
        /// <summary>
        /// Initialises a new instance of the FileMetadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public FileMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            byte sizeOfStringIndex = indexDetails.GetSizeOfStringIndex();
            byte sizeOfBlobIndex   = indexDetails.GetSizeOfBlobIndex();

            _flags     = (FileAttributes)FieldReader.ToUInt32(contents, offset.Shift(4));
            _nameIndex = new StringIndex(contents, sizeOfStringIndex, offset);
            _hashValue = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
        }
        /// <summary>
        /// Initialises a new instance of the FieldMetadataTableRow
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public FieldMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            byte sizeOfStringIndex = indexDetails.GetSizeOfStringIndex();
            byte sizeOfBlobIndex   = indexDetails.GetSizeOfBlobIndex();

            _flags          = (FieldAttributes)FieldReader.ToUInt16(contents, offset.Shift(2));
            _nameIndex      = new StringIndex(contents, sizeOfStringIndex, offset);
            _signitureIndex = new BlobIndex(sizeOfBlobIndex, contents, Reflection.Signatures.Signatures.Field, offset);
        }
Exemple #4
0
        /// <summary>
        /// Initialises a new instance of the PropertyMetadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of this row</param>
        public PropertyMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            FileOffset = offset;

            byte sizeOfBlobIndex   = indexDetails.GetSizeOfBlobIndex();
            byte sizeOfStringIndex = indexDetails.GetSizeOfStringIndex();

            _attributes = (PropertyAttributes)FieldReader.ToUInt16(contents, offset.Shift(2));
            _nameIndex  = new StringIndex(contents, sizeOfStringIndex, offset);
            _typeIndex  = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
        }
        /// <summary>
        /// Initialises a new instance of the MethodSpecMetadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public MethodSpecMetadataTableRow(byte[] contents, Offset offset, ICodedIndexResolver resolver, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            int  sizeOfCodedIndex = resolver.GetSizeOfIndex(CodedIndexes.MethodDefOrRef);
            byte sizeOfBlobIndex  = indexDetails.GetSizeOfBlobIndex();

            _method = resolver.Resolve(CodedIndexes.MethodDefOrRef,
                                       FieldReader.ToUInt32(contents, offset.Shift(sizeOfCodedIndex), sizeOfCodedIndex)
                                       );
            _instantiation = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
        }
        /// <summary>
        /// Initialises a new instnace of the StandAloneSigMetadataTableRow
        /// </summary>
        /// <param name="contents">The contents of teh file</param>
        /// <param name="offset">The offset for this row</param>
        public StandAloneSigMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            byte sizeOfBlobIndex = indexDetails.GetSizeOfBlobIndex();

            // TODO: Fix; stand alone is not forced to be a methoddef.. i think
            _signiture = new BlobIndex(
                sizeOfBlobIndex,
                contents,
                TheBoxSoftware.Reflection.Signatures.Signatures.MethodDef,
                offset);
        }
        /// <summary>
        /// Initialises a new instance of the FieldMarshalMEtadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public FieldMarshalMetadataTableRow(byte[] contents, Offset offset, ICodedIndexResolver resolver, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            int  sizeOfHasFieldMarshalIndex = resolver.GetSizeOfIndex(CodedIndexes.HasFieldMarshall);
            byte sizeOfBlobIndex            = indexDetails.GetSizeOfBlobIndex();

            _parentIndex = resolver.Resolve(
                CodedIndexes.HasFieldMarshall,
                FieldReader.ToUInt32(contents, offset.Shift(sizeOfHasFieldMarshalIndex), sizeOfHasFieldMarshalIndex)
                );
            _nativeTypeIndex = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
        }
        /// <summary>
        /// Initialises a new instance of the DeclSecurityMetadataTableRow
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the this row</param>
        public DeclSecurityMetadataTableRow(byte[] contents, Offset offset, ICodedIndexResolver resolver, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            int  declSecurityIndexSize = resolver.GetSizeOfIndex(CodedIndexes.HasDeclSecurity);
            byte sizeOfBlobIndex       = indexDetails.GetSizeOfBlobIndex();

            _action      = BitConverter.ToUInt16(contents, offset.Shift(2));
            _parentIndex = resolver.Resolve(
                CodedIndexes.HasDeclSecurity,
                FieldReader.ToUInt32(contents, offset.Shift(declSecurityIndexSize), declSecurityIndexSize)
                );
            _permissionSet = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
        }
        /// <summary>
        /// Initialises a new instance of the MemberRefMetadataTableRow
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of this row</param>
        public MemberRefMetadataTableRow(byte[] contents, Offset offset, ICodedIndexResolver resolver, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            int  sizeOfMemberRefParentIndex = resolver.GetSizeOfIndex(CodedIndexes.MemberRefParent);
            byte sizeOfStringIndex          = indexDetails.GetSizeOfStringIndex();
            byte sizeOfBlobIndex            = indexDetails.GetSizeOfBlobIndex();

            _class = resolver.Resolve(CodedIndexes.MemberRefParent,
                                      FieldReader.ToUInt32(contents, offset.Shift(sizeOfMemberRefParentIndex), sizeOfMemberRefParentIndex)
                                      );
            _name      = new StringIndex(contents, sizeOfStringIndex, offset);
            _signiture = new BlobIndex(sizeOfBlobIndex, contents, Reflection.Signatures.Signatures.MethodDef, offset);
        }
Exemple #10
0
        /// <summary>
        /// Initialises a new instance of the MethodMetadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public MethodMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            byte sizeOfStringIndex = indexDetails.GetSizeOfStringIndex();
            byte sizeOfBlobIndex   = indexDetails.GetSizeOfBlobIndex();
            byte sizeOfParamIndex  = indexDetails.GetSizeOfIndex(MetadataTables.Param);

            _rva       = FieldReader.ToUInt32(contents, offset.Shift(4));
            _implFlags = (MethodImplFlags)FieldReader.ToUInt16(contents, offset.Shift(2));
            _flags     = (MethodAttributes)FieldReader.ToUInt16(contents, offset.Shift(2));
            _name      = new StringIndex(contents, sizeOfStringIndex, offset);
            _signiture = new BlobIndex(sizeOfBlobIndex, contents, Signatures.Signatures.MethodDef, offset);
            _paramList = new Index(contents, offset, sizeOfParamIndex);
        }
Exemple #11
0
        /// <summary>
        /// Initialises a new instance of the ConstantMetadataTableRow
        /// </summary>
        /// <param name="contents">The contents fo the file</param>
        /// <param name="offset">The offset for the current row</param>
        public ConstantMetadataTableRow(byte[] contents, Offset offset, ICodedIndexResolver resolver, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            int  hasConstantIndexSize = resolver.GetSizeOfIndex(CodedIndexes.HasConstant);
            byte sizeOfBlobIndex      = indexDetails.GetSizeOfBlobIndex();

            _type = (Signatures.ElementTypes)contents[offset.Shift(1)];
            offset.Shift(1);
            _parentIndex = resolver.Resolve(
                CodedIndexes.HasConstant,
                FieldReader.ToUInt32(contents, offset.Shift(hasConstantIndexSize), hasConstantIndexSize)
                );
            _valueIndex = new BlobIndex(sizeOfBlobIndex, contents, Signatures.Signatures.MethodDef, offset);
        }
        /// <summary>
        /// Initialises a new instance of the AssemblyMetadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        /// <param name="indexDetails">Object which enables the retrieval of index sizes</param>
        public AssemblyMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            FileOffset = offset;

            byte sizeOfBlobIndex   = indexDetails.GetSizeOfBlobIndex();
            byte sizeOfStringIndex = indexDetails.GetSizeOfStringIndex();

            _hashAlgId      = (AssemblyHashAlgorithms)FieldReader.ToUInt32(contents, offset.Shift(4));
            _majorVersion   = FieldReader.ToUInt16(contents, offset.Shift(2));
            _minorVersion   = FieldReader.ToUInt16(contents, offset.Shift(2));
            _buildNumber    = FieldReader.ToUInt16(contents, offset.Shift(2));
            _revisionNumber = FieldReader.ToUInt16(contents, offset.Shift(2));
            _flags          = (AssemblyFlags)FieldReader.ToUInt32(contents, offset.Shift(4));
            _publicKey      = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
            _nameIndex      = new StringIndex(contents, sizeOfStringIndex, offset);
            _culture        = new StringIndex(contents, sizeOfStringIndex, offset);
        }
        /// <summary>
        /// Initialises a new instance of the CustomAttributeMetadataTableRow
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public CustomAttributeMetadataTableRow(byte[] contents, Offset offset, ICodedIndexResolver resolver, IIndexDetails indexDetails)
        {
            int  hasCustomAttributeIndexSize = resolver.GetSizeOfIndex(CodedIndexes.HasCustomAttribute);
            int  customAttributeIndexSize    = resolver.GetSizeOfIndex(CodedIndexes.CustomAttributeType);
            byte sizeOfBlobIndex             = indexDetails.GetSizeOfBlobIndex();

            this.FileOffset = offset;

            _parentIndex = resolver.Resolve(
                CodedIndexes.HasCustomAttribute,
                FieldReader.ToUInt32(contents, offset.Shift(hasCustomAttributeIndexSize), hasCustomAttributeIndexSize)
                );
            _typeIndex = resolver.Resolve(CodedIndexes.CustomAttributeType,
                                          FieldReader.ToUInt32(contents, offset.Shift(customAttributeIndexSize), customAttributeIndexSize)
                                          );
            _value = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
        }