コード例 #1
0
ファイル: Tables.Debug.cs プロジェクト: er0dr1guez/corefx
        internal DocumentTableReader(
            int numberOfRows,
            int guidHeapRefSize,
            int blobHeapRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset)
        {
            NumberOfRows = numberOfRows;
            _isGuidHeapRefSizeSmall = guidHeapRefSize == 2;
            _isBlobHeapRefSizeSmall = blobHeapRefSize == 2;

            _hashAlgorithmOffset = NameOffset + blobHeapRefSize;
            _hashOffset = _hashAlgorithmOffset + guidHeapRefSize;
            _languageOffset = _hashOffset + blobHeapRefSize;
            RowSize = _languageOffset + guidHeapRefSize;

            Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, RowSize * numberOfRows);
        }
コード例 #2
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal ModuleTableReader(
     int numberOfRows,
     int stringHeapRefSize,
     int guidHeapRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
     _IsGUIDHeapRefSizeSmall = guidHeapRefSize == 2;
     _GenerationOffset = 0;
     _NameOffset = _GenerationOffset + sizeof(UInt16);
     _MVIdOffset = _NameOffset + stringHeapRefSize;
     _EnCIdOffset = _MVIdOffset + guidHeapRefSize;
     _EnCBaseIdOffset = _EnCIdOffset + guidHeapRefSize;
     this.RowSize = _EnCBaseIdOffset + guidHeapRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, this.RowSize * (int)numberOfRows);
 }
コード例 #3
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal EnCLogTableReader(
            int numberOfRows,
            MemoryBlock containingBlock,
            int containingBlockOffset,
            MetadataStreamKind metadataStreamKind)
        {
            // EnC tables are not allowed in a compressed stream.
            // However when asked for a snapshot of the current metadata after an EnC change has been applied 
            // the CLR includes the EnCLog table into the snapshot (but not EnCMap). We pretend EnCLog is empty.
            this.NumberOfRows = (metadataStreamKind == MetadataStreamKind.Compressed) ? 0 : numberOfRows;

            _TokenOffset = 0;
            _FuncCodeOffset = _TokenOffset + sizeof(uint);
            this.RowSize = _FuncCodeOffset + sizeof(uint);
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
        }
コード例 #4
0
ファイル: BlobReaderTests.cs プロジェクト: noahfalk/corefx
        public unsafe void ReadFromMemoryBlock()
        {
            byte[] buffer = new byte[4] { 0, 1, 0, 2 };
            fixed (byte* bufferPtr = buffer)
            {
                var block = new MemoryBlock(bufferPtr, buffer.Length);

                Assert.Throws<BadImageFormatException>(() => block.PeekUInt32(Int32.MaxValue));
                Assert.Throws<BadImageFormatException>(() => block.PeekUInt32(-1));
                Assert.Throws<BadImageFormatException>(() => block.PeekUInt32(Int32.MinValue));
                Assert.Throws<BadImageFormatException>(() => block.PeekUInt32(4));
                Assert.Throws<BadImageFormatException>(() => block.PeekUInt32(1));
                Assert.Equal(0x02000100U, block.PeekUInt32(0));

                Assert.Throws<BadImageFormatException>(() => block.PeekUInt16(Int32.MaxValue));
                Assert.Throws<BadImageFormatException>(() => block.PeekUInt16(-1));
                Assert.Throws<BadImageFormatException>(() => block.PeekUInt16(Int32.MinValue));
                Assert.Throws<BadImageFormatException>(() => block.PeekUInt16(4));
                Assert.Equal(0x0200, block.PeekUInt16(2));

                int bytesRead;

                MetadataStringDecoder stringDecoder = MetadataStringDecoder.DefaultUTF8;
                Assert.Throws<BadImageFormatException>(() => block.PeekUtf8NullTerminated(Int32.MaxValue, null, stringDecoder, out bytesRead));
                Assert.Throws<BadImageFormatException>(() => block.PeekUtf8NullTerminated(-1, null, stringDecoder, out bytesRead));
                Assert.Throws<BadImageFormatException>(() => block.PeekUtf8NullTerminated(Int32.MinValue, null, stringDecoder, out bytesRead));
                Assert.Throws<BadImageFormatException>(() => block.PeekUtf8NullTerminated(5, null, stringDecoder, out bytesRead));

                Assert.Throws<BadImageFormatException>(() => block.GetMemoryBlockAt(-1, 1));
                Assert.Throws<BadImageFormatException>(() => block.GetMemoryBlockAt(1, -1));
                Assert.Throws<BadImageFormatException>(() => block.GetMemoryBlockAt(0, -1));
                Assert.Throws<BadImageFormatException>(() => block.GetMemoryBlockAt(-1, 0));
                Assert.Throws<BadImageFormatException>(() => block.GetMemoryBlockAt(-Int32.MaxValue, Int32.MaxValue));
                Assert.Throws<BadImageFormatException>(() => block.GetMemoryBlockAt(Int32.MaxValue, -Int32.MaxValue));
                Assert.Throws<BadImageFormatException>(() => block.GetMemoryBlockAt(Int32.MaxValue, Int32.MaxValue));
                Assert.Throws<BadImageFormatException>(() => block.GetMemoryBlockAt(block.Length, -1));
                Assert.Throws<BadImageFormatException>(() => block.GetMemoryBlockAt(-1, block.Length));


                Assert.Equal("\u0001", block.PeekUtf8NullTerminated(1, null, stringDecoder, out bytesRead));
                Assert.Equal(bytesRead, 2);

                Assert.Equal("\u0002", block.PeekUtf8NullTerminated(3, null, stringDecoder, out bytesRead));
                Assert.Equal(bytesRead, 1);

                Assert.Equal("", block.PeekUtf8NullTerminated(4, null, stringDecoder, out bytesRead));
                Assert.Equal(bytesRead, 0);

                byte[] helloPrefix = Encoding.UTF8.GetBytes("Hello");

                Assert.Equal("Hello\u0001", block.PeekUtf8NullTerminated(1, helloPrefix, stringDecoder, out bytesRead));
                Assert.Equal(bytesRead, 2);

                Assert.Equal("Hello\u0002", block.PeekUtf8NullTerminated(3, helloPrefix, stringDecoder, out bytesRead));
                Assert.Equal(bytesRead, 1);

                Assert.Equal("Hello", block.PeekUtf8NullTerminated(4, helloPrefix, stringDecoder, out bytesRead));
                Assert.Equal(bytesRead, 0);
            }
        }
コード例 #5
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal FieldMarshalTableReader(
            int numberOfRows,
            bool declaredSorted,
            int hasFieldMarshalRefSize,
            int blobHeapRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset
        )
        {
            this.NumberOfRows = numberOfRows;
            _IsHasFieldMarshalRefSizeSmall = hasFieldMarshalRefSize == 2;
            _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
            _ParentOffset = 0;
            _NativeTypeOffset = _ParentOffset + hasFieldMarshalRefSize;
            this.RowSize = _NativeTypeOffset + blobHeapRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, this.RowSize * numberOfRows);

            if (!declaredSorted && !CheckSorted())
            {
                Throw.TableNotSorted(TableIndex.FieldMarshal);
            }
        }
コード例 #6
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal CustomAttributeTableReader(
            int numberOfRows,
            bool declaredSorted,
            int hasCustomAttributeRefSize,
            int customAttributeTypeRefSize,
            int blobHeapRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset
        )
        {
            this.NumberOfRows = numberOfRows;
            _IsHasCustomAttributeRefSizeSmall = hasCustomAttributeRefSize == 2;
            _IsCustomAttributeTypeRefSizeSmall = customAttributeTypeRefSize == 2;
            _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
            _ParentOffset = 0;
            _TypeOffset = _ParentOffset + hasCustomAttributeRefSize;
            _ValueOffset = _TypeOffset + customAttributeTypeRefSize;
            this.RowSize = _ValueOffset + blobHeapRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
            this.PtrTable = null;

            if (!declaredSorted && !CheckSorted())
            {
                this.PtrTable = this.Block.BuildPtrTable(
                    numberOfRows,
                    this.RowSize,
                    _ParentOffset,
                    _IsHasCustomAttributeRefSizeSmall);
            }
        }
コード例 #7
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal MemberRefTableReader(
     int numberOfRows,
     int memberRefParentRefSize,
     int stringHeapRefSize,
     int blobHeapRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsMemberRefParentRefSizeSmall = memberRefParentRefSize == 2;
     _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
     _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
     _ClassOffset = 0;
     _NameOffset = _ClassOffset + memberRefParentRefSize;
     _SignatureOffset = _NameOffset + stringHeapRefSize;
     this.RowSize = _SignatureOffset + blobHeapRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #8
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal ParamTableReader(
     int numberOfRows,
     int stringHeapRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
     _FlagsOffset = 0;
     _SequenceOffset = _FlagsOffset + sizeof(UInt16);
     _NameOffset = _SequenceOffset + sizeof(UInt16);
     this.RowSize = _NameOffset + stringHeapRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #9
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal MethodTableReader(
     int numberOfRows,
     int paramRefSize,
     int stringHeapRefSize,
     int blobHeapRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsParamRefSizeSmall = paramRefSize == 2;
     _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
     _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
     _RVAOffset = 0;
     _ImplFlagsOffset = _RVAOffset + sizeof(UInt32);
     _FlagsOffset = _ImplFlagsOffset + sizeof(UInt16);
     _NameOffset = _FlagsOffset + sizeof(UInt16);
     _SignatureOffset = _NameOffset + stringHeapRefSize;
     _ParamListOffset = _SignatureOffset + blobHeapRefSize;
     this.RowSize = _ParamListOffset + paramRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #10
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal AssemblyRefOSTableReader(
     int numberOfRows,
     int assemblyRefTableRowRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset)
 {
     this.NumberOfRows = numberOfRows;
     _IsAssemblyRefTableRowRefSizeSmall = assemblyRefTableRowRefSize == 2;
     _OSPlatformIdOffset = 0;
     _OSMajorVersionIdOffset = _OSPlatformIdOffset + sizeof(UInt32);
     _OSMinorVersionIdOffset = _OSMajorVersionIdOffset + sizeof(UInt32);
     _AssemblyRefOffset = _OSMinorVersionIdOffset + sizeof(UInt32);
     this.RowSize = _AssemblyRefOffset + assemblyRefTableRowRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #11
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal AssemblyRefProcessorTableReader(
     int numberOfRows,
     int assemblyRefTableRowRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsAssemblyRefTableRowSizeSmall = assemblyRefTableRowRefSize == 2;
     _ProcessorOffset = 0;
     _AssemblyRefOffset = _ProcessorOffset + sizeof(UInt32);
     this.RowSize = _AssemblyRefOffset + assemblyRefTableRowRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #12
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal AssemblyRefTableReader(
            int numberOfRows,
            int stringHeapRefSize,
            int blobHeapRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset,
            MetadataKind metadataKind)
        {
            this.NumberOfNonVirtualRows = numberOfRows;
            this.NumberOfVirtualRows = (metadataKind == MetadataKind.Ecma335) ? 0 : (int)AssemblyReferenceHandle.VirtualIndex.Count;

            _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
            _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
            _MajorVersionOffset = 0;
            _MinorVersionOffset = _MajorVersionOffset + sizeof(UInt16);
            _BuildNumberOffset = _MinorVersionOffset + sizeof(UInt16);
            _RevisionNumberOffset = _BuildNumberOffset + sizeof(UInt16);
            _FlagsOffset = _RevisionNumberOffset + sizeof(UInt16);
            _PublicKeyOrTokenOffset = _FlagsOffset + sizeof(UInt32);
            _NameOffset = _PublicKeyOrTokenOffset + blobHeapRefSize;
            _CultureOffset = _NameOffset + stringHeapRefSize;
            _HashValueOffset = _CultureOffset + stringHeapRefSize;
            this.RowSize = _HashValueOffset + blobHeapRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, this.RowSize * numberOfRows);
        }
コード例 #13
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal AssemblyProcessorTableReader(
     int numberOfRows,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _ProcessorOffset = 0;
     this.RowSize = _ProcessorOffset + sizeof(UInt32);
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #14
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal AssemblyTableReader(
            int numberOfRows,
            int stringHeapRefSize,
            int blobHeapRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset
        )
        {
            // NOTE: obfuscated assemblies may have more than one row in Assembly table,
            //       we ignore all rows but the first one
            this.NumberOfRows = numberOfRows > 1 ? 1 : numberOfRows;

            _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
            _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
            _HashAlgIdOffset = 0;
            _MajorVersionOffset = _HashAlgIdOffset + sizeof(UInt32);
            _MinorVersionOffset = _MajorVersionOffset + sizeof(UInt16);
            _BuildNumberOffset = _MinorVersionOffset + sizeof(UInt16);
            _RevisionNumberOffset = _BuildNumberOffset + sizeof(UInt16);
            _FlagsOffset = _RevisionNumberOffset + sizeof(UInt16);
            _PublicKeyOffset = _FlagsOffset + sizeof(UInt32);
            _NameOffset = _PublicKeyOffset + blobHeapRefSize;
            _CultureOffset = _NameOffset + stringHeapRefSize;
            this.RowSize = _CultureOffset + stringHeapRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, this.RowSize * numberOfRows);
        }
コード例 #15
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal EnCMapTableReader(
     int numberOfRows,
     MemoryBlock containingBlock,
     int containingBlockOffset)
 {
     this.NumberOfRows = numberOfRows;
     _TokenOffset = 0;
     this.RowSize = _TokenOffset + sizeof(uint);
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, this.RowSize * numberOfRows);
 }
コード例 #16
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal FieldPtrTableReader(
     int numberOfRows,
     int fieldTableRowRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsFieldTableRowRefSizeSmall = fieldTableRowRefSize == 2;
     _FieldOffset = 0;
     this.RowSize = _FieldOffset + fieldTableRowRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #17
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal MethodPtrTableReader(
     int numberOfRows,
     int methodTableRowRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsMethodTableRowRefSizeSmall = methodTableRowRefSize == 2;
     _MethodOffset = 0;
     this.RowSize = _MethodOffset + methodTableRowRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #18
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal FileTableReader(
     int numberOfRows,
     int stringHeapRefSize,
     int blobHeapRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset)
 {
     this.NumberOfRows = numberOfRows;
     _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
     _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
     _FlagsOffset = 0;
     _NameOffset = _FlagsOffset + sizeof(UInt32);
     _HashValueOffset = _NameOffset + stringHeapRefSize;
     this.RowSize = _HashValueOffset + blobHeapRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #19
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal ParamPtrTableReader(
     int numberOfRows,
     int paramTableRowRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsParamTableRowRefSizeSmall = paramTableRowRefSize == 2;
     _ParamOffset = 0;
     this.RowSize = _ParamOffset + paramTableRowRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #20
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal ExportedTypeTableReader(
     int numberOfRows,
     int implementationRefSize,
     int stringHeapRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsImplementationRefSizeSmall = implementationRefSize == 2;
     _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
     _FlagsOffset = 0;
     _TypeDefIdOffset = _FlagsOffset + sizeof(UInt32);
     _TypeNameOffset = _TypeDefIdOffset + sizeof(UInt32);
     _TypeNamespaceOffset = _TypeNameOffset + stringHeapRefSize;
     _ImplementationOffset = _TypeNamespaceOffset + stringHeapRefSize;
     this.RowSize = _ImplementationOffset + implementationRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #21
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal InterfaceImplTableReader(
            int numberOfRows,
            bool declaredSorted,
            int typeDefTableRowRefSize,
            int typeDefOrRefRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset
        )
        {
            this.NumberOfRows = numberOfRows;
            _IsTypeDefTableRowRefSizeSmall = typeDefTableRowRefSize == 2;
            _IsTypeDefOrRefRefSizeSmall = typeDefOrRefRefSize == 2;
            _ClassOffset = 0;
            _InterfaceOffset = _ClassOffset + typeDefTableRowRefSize;
            this.RowSize = _InterfaceOffset + typeDefOrRefRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));

            if (!declaredSorted && !CheckSorted())
            {
                Throw.TableNotSorted(TableIndex.InterfaceImpl);
            }
        }
コード例 #22
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal ManifestResourceTableReader(
     int numberOfRows,
     int implementationRefSize,
     int stringHeapRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsImplementationRefSizeSmall = implementationRefSize == 2;
     _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
     _OffsetOffset = 0;
     _FlagsOffset = _OffsetOffset + sizeof(UInt32);
     _NameOffset = _FlagsOffset + sizeof(UInt32);
     _ImplementationOffset = _NameOffset + stringHeapRefSize;
     this.RowSize = _ImplementationOffset + implementationRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #23
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal ConstantTableReader(
            int numberOfRows,
            bool declaredSorted,
            int hasConstantRefSize,
            int blobHeapRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset
        )
        {
            this.NumberOfRows = numberOfRows;
            _IsHasConstantRefSizeSmall = hasConstantRefSize == 2;
            _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
            _TypeOffset = 0;
            _ParentOffset = _TypeOffset + sizeof(Byte) + 1; // Alignment here (+1)...
            _ValueOffset = _ParentOffset + hasConstantRefSize;
            this.RowSize = _ValueOffset + blobHeapRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));

            if (!declaredSorted && !CheckSorted())
            {
                Throw.TableNotSorted(TableIndex.Constant);
            }
        }
コード例 #24
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal NestedClassTableReader(
            int numberOfRows,
            bool declaredSorted,
            int typeDefTableRowRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset
        )
        {
            this.NumberOfRows = numberOfRows;
            _IsTypeDefTableRowRefSizeSmall = typeDefTableRowRefSize == 2;
            _NestedClassOffset = 0;
            _EnclosingClassOffset = _NestedClassOffset + typeDefTableRowRefSize;
            this.RowSize = _EnclosingClassOffset + typeDefTableRowRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));

            if (!declaredSorted && !CheckSorted())
            {
                Throw.TableNotSorted(TableIndex.NestedClass);
            }
        }
コード例 #25
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal TypeRefTableReader(
     int numberOfRows,
     int resolutionScopeRefSize,
     int stringHeapRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset
 )
 {
     this.NumberOfRows = numberOfRows;
     _IsResolutionScopeRefSizeSmall = resolutionScopeRefSize == 2;
     _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
     _ResolutionScopeOffset = 0;
     _NameOffset = _ResolutionScopeOffset + resolutionScopeRefSize;
     _NamespaceOffset = _NameOffset + stringHeapRefSize;
     this.RowSize = _NamespaceOffset + stringHeapRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #26
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal GenericParamTableReader(
            int numberOfRows,
            bool declaredSorted,
            int typeOrMethodDefRefSize,
            int stringHeapRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset)
        {
            this.NumberOfRows = numberOfRows;
            _IsTypeOrMethodDefRefSizeSmall = typeOrMethodDefRefSize == 2;
            _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
            _NumberOffset = 0;
            _FlagsOffset = _NumberOffset + sizeof(UInt16);
            _OwnerOffset = _FlagsOffset + sizeof(UInt16);
            _NameOffset = _OwnerOffset + typeOrMethodDefRefSize;
            this.RowSize = _NameOffset + stringHeapRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));

            if (!declaredSorted && !CheckSorted())
            {
                Throw.TableNotSorted(TableIndex.GenericParam);
            }
        }
コード例 #27
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal DeclSecurityTableReader(
            int numberOfRows,
            bool declaredSorted,
            int hasDeclSecurityRefSize,
            int blobHeapRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset
        )
        {
            this.NumberOfRows = numberOfRows;
            _IsHasDeclSecurityRefSizeSmall = hasDeclSecurityRefSize == 2;
            _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
            _ActionOffset = 0;
            _ParentOffset = _ActionOffset + sizeof(UInt16);
            _PermissionSetOffset = _ParentOffset + hasDeclSecurityRefSize;
            this.RowSize = _PermissionSetOffset + blobHeapRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));

            if (!declaredSorted && !CheckSorted())
            {
                Throw.TableNotSorted(TableIndex.DeclSecurity);
            }
        }
コード例 #28
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
 internal MethodSpecTableReader(
     int numberOfRows,
     int methodDefOrRefRefSize,
     int blobHeapRefSize,
     MemoryBlock containingBlock,
     int containingBlockOffset)
 {
     this.NumberOfRows = numberOfRows;
     _IsMethodDefOrRefRefSizeSmall = methodDefOrRefRefSize == 2;
     _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
     _MethodOffset = 0;
     _InstantiationOffset = _MethodOffset + methodDefOrRefRefSize;
     this.RowSize = _InstantiationOffset + blobHeapRefSize;
     this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));
 }
コード例 #29
0
        private void InitializeStreamReaders(ref MemoryBlock metadataRoot, StreamHeader[] streamHeaders, out MemoryBlock metadataTableStream)
        {
            metadataTableStream = default(MemoryBlock);

            foreach (StreamHeader streamHeader in streamHeaders)
            {
                switch (streamHeader.Name)
                {
                    case COR20Constants.StringStreamName:
                        if (metadataRoot.Length < streamHeader.Offset + streamHeader.Size)
                        {
                            throw new BadImageFormatException(MetadataResources.NotEnoughSpaceForStringStream);
                        }

                        this.StringStream = new StringStreamReader(metadataRoot.GetMemoryBlockAt((int)streamHeader.Offset, streamHeader.Size), this.metadataKind);
                        break;

                    case COR20Constants.BlobStreamName:
                        if (metadataRoot.Length < streamHeader.Offset + streamHeader.Size)
                        {
                            throw new BadImageFormatException(MetadataResources.NotEnoughSpaceForBlobStream);
                        }

                        this.BlobStream = new BlobStreamReader(metadataRoot.GetMemoryBlockAt((int)streamHeader.Offset, streamHeader.Size), this.metadataKind);
                        break;

                    case COR20Constants.GUIDStreamName:
                        if (metadataRoot.Length < streamHeader.Offset + streamHeader.Size)
                        {
                            throw new BadImageFormatException(MetadataResources.NotEnoughSpaceForGUIDStream);
                        }

                        this.GuidStream = new GuidStreamReader(metadataRoot.GetMemoryBlockAt((int)streamHeader.Offset, streamHeader.Size));
                        break;

                    case COR20Constants.UserStringStreamName:
                        if (metadataRoot.Length < streamHeader.Offset + streamHeader.Size)
                        {
                            throw new BadImageFormatException(MetadataResources.NotEnoughSpaceForBlobStream);
                        }

                        this.UserStringStream = new UserStringStreamReader(metadataRoot.GetMemoryBlockAt((int)streamHeader.Offset, streamHeader.Size));
                        break;

                    case COR20Constants.CompressedMetadataTableStreamName:
                        if (metadataRoot.Length < streamHeader.Offset + streamHeader.Size)
                        {
                            throw new BadImageFormatException(MetadataResources.NotEnoughSpaceForMetadataStream);
                        }

                        this.metadataStreamKind = MetadataStreamKind.Compressed;
                        metadataTableStream = metadataRoot.GetMemoryBlockAt((int)streamHeader.Offset, streamHeader.Size);
                        break;

                    case COR20Constants.UncompressedMetadataTableStreamName:
                        if (metadataRoot.Length < streamHeader.Offset + streamHeader.Size)
                        {
                            throw new BadImageFormatException(MetadataResources.NotEnoughSpaceForMetadataStream);
                        }

                        this.metadataStreamKind = MetadataStreamKind.Uncompressed;
                        metadataTableStream = metadataRoot.GetMemoryBlockAt((int)streamHeader.Offset, streamHeader.Size);
                        break;

                    case COR20Constants.MinimalDeltaMetadataTableStreamName:
                        if (metadataRoot.Length < streamHeader.Offset + streamHeader.Size)
                        {
                            throw new BadImageFormatException(MetadataResources.NotEnoughSpaceForMetadataStream);
                        }

                        // the content of the stream is ignored
                        this.IsMinimalDelta = true;
                        break;

                    default:
                        // Skip unknown streams. Some obfuscators insert invalid streams.
                        continue;
                }
            }

            if (IsMinimalDelta && metadataStreamKind != MetadataStreamKind.Uncompressed)
            {
                throw new BadImageFormatException(MetadataResources.InvalidMetadataStreamFormat);
            }
        }
コード例 #30
0
ファイル: Tables.cs プロジェクト: jmhardison/corefx
        internal GenericParamConstraintTableReader(
            int numberOfRows,
            bool declaredSorted,
            int genericParamTableRowRefSize,
            int typeDefOrRefRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset)
        {
            this.NumberOfRows = numberOfRows;
            _IsGenericParamTableRowRefSizeSmall = genericParamTableRowRefSize == 2;
            _IsTypeDefOrRefRefSizeSmall = typeDefOrRefRefSize == 2;
            _OwnerOffset = 0;
            _ConstraintOffset = _OwnerOffset + genericParamTableRowRefSize;
            this.RowSize = _ConstraintOffset + typeDefOrRefRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, (int)(this.RowSize * numberOfRows));

            if (!declaredSorted && !CheckSorted())
            {
                Throw.TableNotSorted(TableIndex.GenericParamConstraint);
            }
        }