当前位置: 首页>>代码示例>>C#>>正文


C# BlobReader.ReadBytes方法代码示例

本文整理汇总了C#中System.Reflection.Metadata.BlobReader.ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:C# BlobReader.ReadBytes方法的具体用法?C# BlobReader.ReadBytes怎么用?C# BlobReader.ReadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.Metadata.BlobReader的用法示例。


在下文中一共展示了BlobReader.ReadBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadStandalonePortablePdbStream

        // internal for testing
        internal static void ReadStandalonePortablePdbStream(MemoryBlock block, out DebugMetadataHeader debugMetadataHeader, out int[] externalTableRowCounts)
        {
            var reader = new BlobReader(block);

            const int PdbIdSize = 20;
            byte[] pdbId = reader.ReadBytes(PdbIdSize);

            // ECMA-335 15.4.1.2:
            // The entry point to an application shall be static.
            // This entry point method can be a global method or it can appear inside a type. 
            // The entry point method shall either accept no arguments or a vector of strings.
            // The return type of the entry point method shall be void, int32, or unsigned int32. 
            // The entry point method cannot be defined in a generic class.
            uint entryPointToken = reader.ReadUInt32();
            int entryPointRowId = (int)(entryPointToken & TokenTypeIds.RIDMask);
            if (entryPointToken != 0 && ((entryPointToken & TokenTypeIds.TypeMask) != TokenTypeIds.MethodDef || entryPointRowId == 0))
            {
                throw new BadImageFormatException(string.Format(SR.InvalidEntryPointToken, entryPointToken));
            }

            ulong externalTableMask = reader.ReadUInt64();

            // EnC & Ptr tables can't be referenced from standalone PDB metadata:
            const ulong validTables = (ulong)TableMask.ValidPortablePdbExternalTables;

            if ((externalTableMask & ~validTables) != 0)
            {
                throw new BadImageFormatException(string.Format(SR.UnknownTables, (TableMask)externalTableMask));
            }

            externalTableRowCounts = ReadMetadataTableRowCounts(ref reader, externalTableMask);

            debugMetadataHeader = new DebugMetadataHeader(
                ImmutableByteArrayInterop.DangerousCreateFromUnderlyingArray(ref pdbId),
                MethodDefinitionHandle.FromRowId(entryPointRowId));
        }
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:37,代码来源:MetadataReader.cs

示例2: GetFieldBody

        /// <summary>
        /// </summary>
        /// <param name="relativeVirtualAddress">
        /// </param>
        /// <param name="peReader">
        /// </param>
        /// <returns>
        /// </returns>
        public byte[] GetFieldBody(int relativeVirtualAddress, PEReader peReader)
        {
            var peHeaders = peReader.PEHeaders;

            var containingSectionIndex = peHeaders.GetContainingSectionIndex(relativeVirtualAddress);
            if (containingSectionIndex < 0)
            {
                return null;
            }

            var num = relativeVirtualAddress - peHeaders.SectionHeaders[containingSectionIndex].VirtualAddress;
            var length = peHeaders.SectionHeaders[containingSectionIndex].VirtualSize - num;

            IntPtr pointer;
            int size;
            peReader.GetEntireImage(out pointer, out size);

            var reader = new BlobReader(pointer + peHeaders.SectionHeaders[containingSectionIndex].PointerToRawData + num, length);
            var bytes = reader.ReadBytes(length);

            return bytes;
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:30,代码来源:MetadataFieldAdapter.cs


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