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


C# ByteBuffer.ReadInt32方法代码示例

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


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

示例1: GetDebugHeader

        public ImageDebugDirectory GetDebugHeader(out byte[] header)
        {
            var section = GetSectionAtVirtualAddress(Debug.VirtualAddress);
            var buffer = new ByteBuffer(section.Data);
            buffer.position = (int)(Debug.VirtualAddress - section.VirtualAddress);

            var directory = new ImageDebugDirectory
            {
                Characteristics = buffer.ReadInt32(),
                TimeDateStamp = buffer.ReadInt32(),
                MajorVersion = buffer.ReadInt16(),
                MinorVersion = buffer.ReadInt16(),
                Type = buffer.ReadInt32(),
                SizeOfData = buffer.ReadInt32(),
                AddressOfRawData = buffer.ReadInt32(),
                PointerToRawData = buffer.ReadInt32(),
            };

            if (directory.SizeOfData == 0 || directory.PointerToRawData == 0)
            {
                header = Empty<byte>.Array;
                return directory;
            }

            buffer.position = (int)(directory.PointerToRawData - section.PointerToRawData);

            header = new byte[directory.SizeOfData];
            Buffer.BlockCopy(buffer.buffer, buffer.position, header, 0, header.Length);

            return directory;
        }
开发者ID:beatcracker,项目名称:GUILess-Reflexil,代码行数:31,代码来源:Image.cs

示例2: PatchRawCode

        void PatchRawCode(ByteBuffer buffer, int code_size, CodeWriter writer)
        {
            var metadata = writer.metadata;
            buffer.WriteBytes(ReadBytes(code_size));
            var end = buffer.position;
            buffer.position -= code_size;

            while (buffer.position < end)
            {
                OpCode opcode;
                var il_opcode = buffer.ReadByte();
                if (il_opcode != 0xfe)
                {
                    opcode = OpCodes.OneByteOpCode[il_opcode];
                }
                else
                {
                    var il_opcode2 = buffer.ReadByte();
                    opcode = OpCodes.TwoBytesOpCode[il_opcode2];
                }

                switch (opcode.OperandType)
                {
                    case OperandType.ShortInlineI:
                    case OperandType.ShortInlineBrTarget:
                    case OperandType.ShortInlineVar:
                    case OperandType.ShortInlineArg:
                        buffer.position += 1;
                        break;
                    case OperandType.InlineVar:
                    case OperandType.InlineArg:
                        buffer.position += 2;
                        break;
                    case OperandType.InlineBrTarget:
                    case OperandType.ShortInlineR:
                    case OperandType.InlineI:
                        buffer.position += 4;
                        break;
                    case OperandType.InlineI8:
                    case OperandType.InlineR:
                        buffer.position += 8;
                        break;
                    case OperandType.InlineSwitch:
                        var length = buffer.ReadInt32();
                        buffer.position += length * 4;
                        break;
                    case OperandType.InlineString:
                        var @string = GetString(new MetadataToken(buffer.ReadUInt32()));
                        buffer.position -= 4;
                        buffer.WriteUInt32(
                            new MetadataToken(
                                TokenType.String,
                                metadata.user_string_heap.GetStringIndex(@string)).ToUInt32());
                        break;
                    case OperandType.InlineSig:
                        var call_site = GetCallSite(new MetadataToken(buffer.ReadUInt32()));
                        buffer.position -= 4;
                        buffer.WriteUInt32(writer.GetStandAloneSignature(call_site).ToUInt32());
                        break;
                    case OperandType.InlineTok:
                    case OperandType.InlineType:
                    case OperandType.InlineMethod:
                    case OperandType.InlineField:
                        var provider = reader.LookupToken(new MetadataToken(buffer.ReadUInt32()));
                        buffer.position -= 4;
                        buffer.WriteUInt32(metadata.LookupToken(provider).ToUInt32());
                        break;
                }
            }
        }
开发者ID:beatcracker,项目名称:GUILess-Reflexil,代码行数:70,代码来源:CodeReader.cs


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