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


C# Stream.AssumeArgNotNull方法代码示例

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


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

示例1: Load

        internal void Load(Stream s)
        {
            s.AssumeArgNotNull("s");

            RVA = s.ReadUIntLE();
            Size = s.ReadUIntLE();
        }
开发者ID:scottwis,项目名称:Disil,代码行数:7,代码来源:BlockReference.cs

示例2: Load

        internal void Load(Stream stream, long size)
        {
            stream.AssumeArgNotNull("stream");
            size.AssumeArgGte(s_minSize, "size");

            using(var subStream = new SubStream(stream, size, "Invalid meta-data root."))
            {
                subStream.ReadUIntLE().AssumeEquals(
                    0x424A5342U,
                    "Incorrect meta-data signature."
                );

                MajorVersion = subStream.ReadUShortLE();
                MinorVersion = subStream.ReadUShortLE();
                Reserved = subStream.ReadUIntLE();
                var versionLen =
                    (int)(
                        subStream.ReadUIntLE().AssumeLte(
                            256,
                            "CLR Version string too long"
                        ));

                Util.Assume(
                    versionLen % 4 == 0,
                    "Mis-algned version string length in CLR Header."
                );

                Version =
                    Encoding.UTF8.GetString(
                        subStream.ReadBytes(versionLen)
                    ).TrimEnd('\0');

                Flags = subStream.ReadUShortLE();

                var numberOfStreams = subStream.ReadUShortLE();
                var streamHeaders = new StreamHeader[numberOfStreams];

                var b = new StringBuilder();

                for (var i = 0; i < numberOfStreams; ++i)
                {
                    streamHeaders[i] = new StreamHeader();
                    streamHeaders[i].Load(subStream, b);
                }

                StreamHeaders =
                    new ReadOnlyDictionary<string,StreamHeader>(
                        streamHeaders.ToDictionary(h=>h.Name)
                    );
            }
        }
开发者ID:scottwis,项目名称:Disil,代码行数:51,代码来源:ClrMetadataRoot.cs

示例3: Load

        internal void Load(Stream s)
        {
            s.AssumeArgNotNull("s");

            HeaderSize = s.ReadUIntLE();
            MajorRuntimeVersion = s.ReadUShortLE();
            MinorRuntimeVersion = s.ReadUShortLE();
            MetaDataPointer.Load(s);
            Flags = (ClrHeaderFlags) s.ReadUIntLE();
            EntryPointToken = s.ReadUIntLE();
            Resources.Load(s);
            StrongNameSignature.Load(s);
            CodeManagerTable.Load(s);
            VTableFixups.Load(s);
            ExportAddressTableJumps.Load(s);
            ManagedNativeHeader.Load(s);
        }
开发者ID:scottwis,项目名称:Disil,代码行数:17,代码来源:ClrHeader.cs

示例4: Load

        internal void Load(Stream s)
        {
            s.AssumeArgNotNull("s");

            MachineType = ((MachineType)s.ReadUShortLE()).AssumeDefined();
            NumberOfSections = s.ReadUShortLE().AssumeGt(0, "Empty section table detected. All valid PE files should contain at least one section.");
            TimeDateStamp = s.ReadUIntLE();
            PointerToSymbolTable = s.ReadUIntLE().AssumeEquals(0u);
            NumberOfSymbols = s.ReadUIntLE().AssumeEquals(0u);
            SizeOfOptionalHeader = s.ReadUShortLE();
            Characteristics = (FileCharacteristics)s.ReadUShortLE();

            Util.Assume(SizeOfOptionalHeader >= 92, "Unexpected optional header size");

            var optHeaderStart = s.Position;

            ImageType = ((ImageType)s.ReadUShortLE()).AssumeDefined();

            if (ImageType == ImageType.PE32PlusFile)
            {
                Util.Assume(SizeOfOptionalHeader >= 108, "Unexpected optional header size");
            }

            MajorLinkerVersion = s.ReadByteOrThrow();
            MinorLinkerVersion = s.ReadByteOrThrow();
            SizeOfCode = s.ReadUIntLE();
            SizeOfInitializedData = s.ReadUIntLE();
            SizeOfUnInitializedData = s.ReadUIntLE();
            EntryPointRVA = s.ReadUIntLE();
            BaseOfCode = s.ReadUIntLE();
            if (ImageType == ImageType.PEFile)
            {
                BaseOfData = s.ReadUIntLE();
                ImageBase = s.ReadUIntLE();
            }
            else
            {
                ImageBase = s.ReadULongLE();
            }

            SectionAlignment = s.ReadUIntLE();
            FileAlignment = s.ReadUIntLE();
            MajorOSVersion = s.ReadUShortLE();
            MinorOSVersion = s.ReadUShortLE();
            MajorImageVersion = s.ReadUShortLE();
            MinorImageVersion = s.ReadUShortLE();
            MajorSubsystemVersion = s.ReadUShortLE();
            MinorSubsystemVersion = s.ReadUShortLE();
            Win32VersionValue = s.ReadUIntLE();
            SizeOfImage = s.ReadUIntLE();
            SizeOfHeaders = s.ReadUIntLE();
            CheckSum = s.ReadUIntLE();
            Subsystem = ((WindowsSubsystem) s.ReadUShortLE()).AssumeDefined();
            DllCharacteristics = (DllCharacteristics) s.ReadUShortLE();

            if (ImageType == ImageType.PEFile)
            {
                SizeOfStackReserve = s.ReadUIntLE();
                SizeOfStackCommit = s.ReadUIntLE();
                SizeOfHeapReserve = s.ReadUIntLE();
                SizeOfHeapCommit = s.ReadUIntLE();
            }
            else
            {
                SizeOfStackReserve = s.ReadULongLE();
                SizeOfStackCommit = s.ReadULongLE();
                SizeOfHeapReserve = s.ReadULongLE();
                SizeOfHeapCommit = s.ReadULongLE();
            }
            LoaderFlags = s.ReadUIntLE();

            var dataDirCount = s.ReadUIntLE();

            Util.Assume(dataDirCount * 8 <= SizeOfOptionalHeader - (s.Position - optHeaderStart), "Inconsistent header fields");

            if (dataDirCount != 0)
            {
                var dirs = new BlockReference[dataDirCount];

                for (int i = 0; i < dirs.Length; ++i)
                {
                    dirs[i] = new BlockReference(s);
                }

                DataDirectories = new ReadOnlyCollection<BlockReference>(dirs);
            }
        }
开发者ID:scottwis,项目名称:Disil,代码行数:87,代码来源:PEHeader.cs


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