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


C# BinaryReader.PreserveCurrentPosition方法代码示例

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


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

示例1: ReadMapList

        private void ReadMapList(BinaryReader reader)
        {
            reader.PreserveCurrentPosition(header.MapOffset, () => {
                var mapsize = reader.ReadUInt32();
                for (var i = 0; i < mapsize; i++)
                {
                    var type = (TypeCodes)reader.ReadUInt16();
                    reader.ReadUInt16(); // unused
                    var size = reader.ReadUInt32();
                    var offset = reader.ReadUInt32();

                    map.Add(type, size, offset);
                }
            });
        }
开发者ID:rfcclub,项目名称:dot42,代码行数:15,代码来源:DexReader.cs

示例2: ReadTypesReferences

 private void ReadTypesReferences(BinaryReader reader)
 {
     reader.PreserveCurrentPosition(Header.TypeReferencesOffset, () =>
     {
         for (var i = 0; i < Header.TypeReferencesSize; i++)
         {
             var descriptorIndex = reader.ReadInt32();
             var descriptor = Dex.Strings[descriptorIndex];
             TypeDescriptor.Fill(descriptor, Dex.TypeReferences[i], Dex);
         }
     });
 }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:12,代码来源:DexReader.cs

示例3: ReadParameters

 private void ReadParameters(BinaryReader reader, Prototype prototype, uint parametersOffset)
 {
     reader.PreserveCurrentPosition(parametersOffset, () =>
     {
         var typecount = reader.ReadUInt32();
         for (var j = 0; j < typecount; j++)
         {
             var parameter = new Parameter();
             var typeIndex = reader.ReadUInt16();
             parameter.Type = Dex.TypeReferences[typeIndex];
             prototype.Parameters.Add(parameter);
         }
     });
 }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:14,代码来源:DexReader.cs

示例4: ReadStaticValues

 private void ReadStaticValues(BinaryReader reader, ClassDefinition classDefinition, uint staticValuesOffset)
 {
     reader.PreserveCurrentPosition(staticValuesOffset, () =>
     {
         var values = ReadValues(reader);
         for (var j = 0; j < values.Length; j++)
             classDefinition.Fields[j].Value = values[j];
     });
 }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:9,代码来源:DexReader.cs

示例5: ReadInterfaces

 private void ReadInterfaces(BinaryReader reader, ClassDefinition classDefinition, uint interfaceOffset)
 {
     reader.PreserveCurrentPosition(interfaceOffset, () =>
     {
         var typecount = reader.ReadUInt32();
         for (var j = 0; j < typecount; j++)
         {
             var typeIndex = reader.ReadUInt16();
             classDefinition.Interfaces.Add((ClassReference)Dex.TypeReferences[typeIndex]);
         }
     });
 }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:12,代码来源:DexReader.cs

示例6: ReadMethodBody

        private void ReadMethodBody(BinaryReader reader, MethodDefinition mdef, uint codeOffset)
        {
            reader.PreserveCurrentPosition(codeOffset, () =>
            {
                var registersSize = reader.ReadUInt16();
                var incomingArgsSize = reader.ReadUInt16();
                var outgoingArgsSize = reader.ReadUInt16();
                var triesSize = reader.ReadUInt16();
                var debugOffset = reader.ReadUInt32();

                mdef.Body = new MethodBody(mdef, registersSize)
                {
                    IncomingArguments = incomingArgsSize,
                    OutgoingArguments = outgoingArgsSize
                };

                var ireader = new InstructionReader(Dex, mdef);
                ireader.ReadFrom(reader);

                if ((triesSize != 0) && (ireader.Codes.Length % 2 != 0))
                    reader.ReadUInt16(); // padding (4-byte alignment)

                if (triesSize != 0)
                    ReadExceptionHandlers(reader, mdef, ireader, triesSize);

                if (debugOffset != 0)
                    ReadDebugInfo(reader, mdef, debugOffset);
            });
        }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:29,代码来源:DexReader.cs

示例7: ReadMethodReferences

        private void ReadMethodReferences(BinaryReader reader)
        {
            reader.PreserveCurrentPosition(header.MethodReferencesOffset, () =>
            {
                for (int i = 0; i < header.MethodReferencesSize; i++)
                {
                    int classIndex = reader.ReadUInt16();
                    int prototypeIndex = reader.ReadUInt16();
                    int nameIndex = reader.ReadInt32();

                    var mref = new MethodReference();
                    mref.Owner = (CompositeType) typeReferences[classIndex];
                    // Clone the prototype so we can annotate & update it easily
                    mref.Prototype = prototypes[prototypeIndex].Clone();
                    mref.Name = strings[nameIndex];

                    methodReferences.Add(mref);
                }
            });
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:20,代码来源:DexReader.cs

示例8: ReadDebugInfo

        private void ReadDebugInfo(BinaryReader reader, MethodDefinition mdef, uint debugOffset)
        {
            reader.PreserveCurrentPosition(debugOffset, () =>
            {
                var debugInfo = new DebugInfo(mdef.Body);
                mdef.Body.DebugInfo = debugInfo;

                var lineStart = reader.ReadULEB128();
                debugInfo.LineStart = lineStart;

                var parametersSize = reader.ReadULEB128();
                for (var i = 0; i < parametersSize; i++)
                {
                    var index = reader.ReadULEB128P1();
                    string name = null;
                    if (index != DexConsts.NoIndex && index >= 0)
                        name = Dex.Strings[(int)index];
                    debugInfo.Parameters.Add(name);
                }

                while (true)
                {
                    var ins = new DebugInstruction {OpCode = (DebugOpCodes) reader.ReadByte()};
                    debugInfo.DebugInstructions.Add(ins);

                    uint registerIndex;
                    long nameIndex;
                    string name;

                    switch (ins.OpCode)
                    {
                        case DebugOpCodes.AdvancePc:
                            // uleb128 addr_diff
                            var addrDiff = reader.ReadULEB128();
                            ins.Operands.Add(addrDiff);
                            break;
                        case DebugOpCodes.AdvanceLine:
                            // sleb128 line_diff
                            var lineDiff = reader.ReadSLEB128();
                            ins.Operands.Add(lineDiff);
                            break;
                        case DebugOpCodes.EndLocal:
                        case DebugOpCodes.RestartLocal:
                            // uleb128 register_num
                            registerIndex = reader.ReadULEB128();
                            ins.Operands.Add(mdef.Body.Registers[(int)registerIndex]);
                            break;
                        case DebugOpCodes.SetFile:
                            // uleb128p1 name_idx
                            nameIndex = reader.ReadULEB128P1();
                            name = null;
                            if (nameIndex != DexConsts.NoIndex && nameIndex >= 0)
                                name = Dex.Strings[(int)nameIndex];
                            ins.Operands.Add(name);
                            break;
                        case DebugOpCodes.StartLocalExtended:
                        case DebugOpCodes.StartLocal:
                            // StartLocalExtended : uleb128 register_num, uleb128p1 name_idx, uleb128p1 type_idx, uleb128p1 sig_idx
                            // StartLocal : uleb128 register_num, uleb128p1 name_idx, uleb128p1 type_idx
                            var isExtended = ins.OpCode == DebugOpCodes.StartLocalExtended;

                            registerIndex = reader.ReadULEB128();
                            ins.Operands.Add(mdef.Body.Registers[(int)registerIndex]);

                            nameIndex = reader.ReadULEB128P1();
                            name = null;
                            if (nameIndex != DexConsts.NoIndex && nameIndex >= 0)
                                name = Dex.Strings[(int)nameIndex];
                            ins.Operands.Add(name);

                            var typeIndex = reader.ReadULEB128P1();
                            TypeReference type = null;
                            if (typeIndex != DexConsts.NoIndex && typeIndex >= 0)
                                type = Dex.TypeReferences[(int)typeIndex];
                            ins.Operands.Add(type);

                            if (isExtended)
                            {
                                var signatureIndex = reader.ReadULEB128P1();
                                string signature = null;
                                if (signatureIndex != DexConsts.NoIndex && signatureIndex >= 0)
                                    signature = Dex.Strings[(int)signatureIndex];
                                ins.Operands.Add(signature);
                            }

                            break;
                        case DebugOpCodes.EndSequence:
                            return;
                        //case DebugOpCodes.Special:
                        // between 0x0a and 0xff (inclusive)
                        //case DebugOpCodes.SetPrologueEnd:
                        //case DebugOpCodes.SetEpilogueBegin:
                        //default:
                        //    break;
                    }
                }
            });
        }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:98,代码来源:DexReader.cs

示例9: ReadAnnotationDirectory

        private void ReadAnnotationDirectory(BinaryReader reader, ClassDefinition classDefinition, uint annotationOffset)
        {
            reader.PreserveCurrentPosition(annotationOffset, () =>
            {
                uint classAnnotationOffset = reader.ReadUInt32();
                uint annotatedFieldsSize = reader.ReadUInt32();
                uint annotatedMethodsSize = reader.ReadUInt32();
                uint annotatedParametersSize = reader.ReadUInt32();

                if (classAnnotationOffset > 0)
                    classDefinition.Annotations =
                        ReadAnnotationSet(reader,
                            classAnnotationOffset);

                for (int j = 0; j < annotatedFieldsSize; j++)
                    ((FieldDefinition) fieldReferences[reader.ReadInt32()]).Annotations =
                        ReadAnnotationSet(reader, reader.ReadUInt32());

                for (int j = 0; j < annotatedMethodsSize; j++)
                    ((MethodDefinition) methodReferences[reader.ReadInt32()]).Annotations =
                        ReadAnnotationSet(reader, reader.ReadUInt32());

                for (int j = 0; j < annotatedParametersSize; j++)
                {
                    int methodIndex = reader.ReadInt32();
                    uint offset = reader.ReadUInt32();
                    var annotations = ReadAnnotationSetRefList(reader, offset);
                    var mdef = (methodReferences[methodIndex] as MethodDefinition);

                    for (int i = 0; i < annotations.Count; i++)
                    {
                        if (annotations[i].Count > 0)
                        {
                            mdef.Prototype.Parameters[i].Annotations = annotations[i];
                        }
                    }
                }
            });
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:39,代码来源:DexReader.cs

示例10: ReadFieldReferences

        private void ReadFieldReferences(BinaryReader reader)
        {
            reader.PreserveCurrentPosition(header.FieldReferencesOffset, () =>
            {
                for (int i = 0; i < header.FieldReferencesSize; i++)
                {
                    int classIndex = reader.ReadUInt16();
                    int typeIndex  = reader.ReadUInt16();
                    int nameIndex  = reader.ReadInt32();

                    var fref = new FieldReference();

                    fref.Owner = (ClassReference) typeReferences[classIndex];
                    fref.Type  = typeReferences[typeIndex];
                    fref.Name  = strings[nameIndex];

                    fieldReferences.Add(fref);
                }
            });
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:20,代码来源:DexReader.cs

示例11: PrefetchTypeReferences

        private void PrefetchTypeReferences(BinaryReader reader)
        {
            reader.PreserveCurrentPosition(header.TypeReferencesOffset, () =>
            {
                reader.BaseStream.Seek(header.TypeReferencesOffset, SeekOrigin.Begin);

                for (int i = 0; i < header.TypeReferencesSize; i++)
                {
                    int descriptorIndex = reader.ReadInt32();
                    string descriptor = strings[descriptorIndex];
                    typeReferences.Add(TypeDescriptor.Allocate(descriptor));
                }
            });
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:14,代码来源:DexReader.cs

示例12: PrefetchClassDefinitions

        private void PrefetchClassDefinitions(BinaryReader reader, bool prefetchMembers)
        {
            reader.PreserveCurrentPosition(header.ClassDefinitionsOffset, () =>
            {
                for (int i = 0; i < header.ClassDefinitionsSize; i++)
                {
                    int classIndex = reader.ReadInt32();

                    ClassDefinition cdef;
                    if (typeReferences[classIndex] is ClassDefinition)
                    {
                        cdef = (ClassDefinition) typeReferences[classIndex];
                    }
                    else
                    {
                        cdef = new ClassDefinition((ClassReference) typeReferences[classIndex]);
                        typeReferences[classIndex] = cdef;
                        classes.Add(cdef);
                    }

                    reader.ReadInt32();
                    // skip access_flags
                    reader.ReadInt32();
                    // skip superclass_idx
                    reader.ReadInt32();
                    // skip interfaces_off
                    reader.ReadInt32();
                    // skip source_file_idx
                    reader.ReadInt32();
                    // skip annotations_off

                    uint classDataOffset = reader.ReadUInt32();
                    if ((classDataOffset > 0) && prefetchMembers)
                    {
                        PrefetchClassDefinition(reader, cdef, classDataOffset);
                    }

                    reader.ReadInt32();
                    // skip static_values_off
                }
            });
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:42,代码来源:DexReader.cs

示例13: ReadTypesReferences

 private void ReadTypesReferences(BinaryReader reader)
 {
     reader.PreserveCurrentPosition(header.TypeReferencesOffset, () => {
                                                                     for (int i = 0;
                                                                          i < header.TypeReferencesSize;
                                                                          i++)
                                                                     {
                                                                         int descriptorIndex =
                                                                             reader.ReadInt32();
                                                                         string descriptor =
                                                                             strings[descriptorIndex];
                                                                         TypeDescriptor.Fill(descriptor,
                                                                                             typeReferences
                                                                                                 [i]);
                                                                     }
                                                                 });
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:17,代码来源:DexReader.cs

示例14: ReadClassDefinition

        private void ReadClassDefinition(BinaryReader reader, ClassDefinition classDefinition, uint classDataOffset)
        {
            reader.PreserveCurrentPosition(classDataOffset, () =>
            {
                var staticFieldSize = reader.ReadULEB128();
                var instanceFieldSize = reader.ReadULEB128();
                var directMethodSize = reader.ReadULEB128();
                var virtualMethodSize = reader.ReadULEB128();

                ReadFieldDefinitions(reader, classDefinition, staticFieldSize);
                ReadFieldDefinitions(reader, classDefinition, instanceFieldSize);
                ReadMethodDefinitions(reader, classDefinition, directMethodSize, false);
                ReadMethodDefinitions(reader, classDefinition, virtualMethodSize, true);
            });
        }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:15,代码来源:DexReader.cs

示例15: ReadPrototypes

        private void ReadPrototypes(BinaryReader reader)
        {
            reader.PreserveCurrentPosition(header.PrototypesOffset, () =>
            {
                for (int i = 0; i < header.PrototypesSize; i++)
                {
                    long thisOffset = reader.BaseStream.Position;
                    int shortyIndex = reader.ReadInt32();
                    int returnTypeIndex = reader.ReadInt32();
                    uint parametersOffset = reader.ReadUInt32();

                    var prototype = new Prototype();
                    prototype.ReturnType = typeReferences[returnTypeIndex];

                    if (parametersOffset > 0)
                    {
                        ReadParameters(reader, prototype, parametersOffset);
                    }

                    prototype.Freeze();

                    // cache the signature and hashcode.
                    // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
                    prototype.GetHashCode();
                    prototype.ToSignature();

                    prototypes.Add(prototype);
                }
            });
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:30,代码来源:DexReader.cs


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