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


C# BinaryReader.ReadULEB128方法代码示例

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


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

示例1: ReadValues

 private object[] ReadValues(BinaryReader reader)
 {
     var size = reader.ReadULEB128();
     var array = new ArrayList();
     for (uint i = 0; i < size; i++)
     {
         array.Add(ReadValue(reader));
     }
     return array.ToArray();
 }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:10,代码来源:DexReader.cs

示例2: PrefetchClassDefinition

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

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

示例3: ReadFieldDefinitions

        private void ReadFieldDefinitions(BinaryReader reader, ClassDefinition classDefinition, uint fieldcount)
        {
            uint fieldIndex = 0;
            for (var i = 0; i < fieldcount; i++)
            {
                fieldIndex += reader.ReadULEB128();
                var accessFlags = reader.ReadULEB128();

                var fdef = (FieldDefinition)Dex.FieldReferences[(int)fieldIndex];
                fdef.AccessFlags = (AccessFlags)accessFlags;
                fdef.Owner = classDefinition;

                classDefinition.Fields.Add(fdef);
            }
        }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:15,代码来源:DexReader.cs

示例4: ReadMethodDefinitions

        private void ReadMethodDefinitions(BinaryReader reader, ClassDefinition classDefinition, uint methodcount, bool isVirtual)
        {
            uint methodIndex = 0;
            for (var i = 0; i < methodcount; i++)
            {
                methodIndex += reader.ReadULEB128();
                var accessFlags = reader.ReadULEB128();
                var codeOffset = reader.ReadULEB128();

                var mdef = (MethodDefinition)Dex.MethodReferences[(int)methodIndex];
                mdef.AccessFlags = (AccessFlags)accessFlags;
                mdef.Owner = classDefinition;
                mdef.IsVirtual = isVirtual;

                classDefinition.Methods.Add(mdef);

                if (codeOffset > 0)
                    ReadMethodBody(reader, mdef, codeOffset);
            }
        }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:20,代码来源:DexReader.cs

示例5: ReadEncodedAnnotation

        private Annotation ReadEncodedAnnotation(BinaryReader reader)
        {
            var typeIndex = (int)reader.ReadULEB128();
            var elementSize = (int)reader.ReadULEB128();

            var annotation = new Annotation {Type = (ClassReference) Dex.TypeReferences[typeIndex]};

            for (var i = 0; i < elementSize; i++)
            {
                var argument = new AnnotationArgument();
                var nameIndex = (int)reader.ReadULEB128();
                argument.Name = Dex.Strings[nameIndex];
                argument.Value = ReadValue(reader);
                annotation.Arguments.Add(argument);
            }

            return annotation;
        }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:18,代码来源:DexReader.cs

示例6: ReadExceptionHandlers

        private void ReadExceptionHandlers(BinaryReader reader, MethodDefinition mdef, InstructionReader instructionReader, ushort triesSize)
        {
            var exceptionLookup = new Dictionary<uint, List<ExceptionHandler>>();
            for (var i = 0; i < triesSize; i++)
            {
                var startOffset = reader.ReadUInt32();
                var insCount = reader.ReadUInt16();
                var endOffset = startOffset + insCount - 1;
                uint handlerOffset = reader.ReadUInt16();

                var ehandler = new ExceptionHandler();
                mdef.Body.Exceptions.Add(ehandler);
                if (!exceptionLookup.ContainsKey(handlerOffset))
                {
                    exceptionLookup.Add(handlerOffset, new List<ExceptionHandler>());
                }
                exceptionLookup[handlerOffset].Add(ehandler);
                ehandler.TryStart = instructionReader.Lookup[(int)startOffset];
                // The last code unit covered (inclusive) is start_addr + insn_count - 1
                ehandler.TryEnd = instructionReader.LookupLast[(int)endOffset];
            }

            var baseOffset = reader.BaseStream.Position;
            var catchHandlersSize = reader.ReadULEB128();
            for (var i = 0; i < catchHandlersSize; i++)
            {
                var itemoffset = reader.BaseStream.Position - baseOffset;
                var catchTypes = reader.ReadSLEB128();
                var catchAllPresent = catchTypes <= 0;
                catchTypes = Math.Abs(catchTypes);

                for (var j = 0; j < catchTypes; j++)
                {
                    var typeIndex = reader.ReadULEB128();
                    var offset = reader.ReadULEB128();
                    var @catch = new Catch
                    {
                        Type = Dex.TypeReferences[(int) typeIndex],
                        Instruction = instructionReader.Lookup[(int) offset]
                    };

                    // As catch handler can be used in several tries, let's clone the catch
                    foreach (var ehandler in exceptionLookup[(uint)itemoffset])
                        ehandler.Catches.Add(@catch.Clone());
                }

                if (!catchAllPresent)
                    continue;

                var caOffset = reader.ReadULEB128();
                foreach (var ehandler in exceptionLookup[(uint)itemoffset])
                    ehandler.CatchAll = instructionReader.Lookup[(int)caOffset];
            }
        }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:54,代码来源:DexReader.cs

示例7: 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

示例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: PrefetchMethodDefinitions

        private void PrefetchMethodDefinitions(BinaryReader reader, uint methodcount)
        {
            var methodIndex = 0;
            for (var i = 0; i < methodcount; i++)
            {
                if (i == 0)
                    methodIndex = (int)reader.ReadULEB128();
                else
                    methodIndex += (int)reader.ReadULEB128();

                reader.ReadULEB128();
                reader.ReadULEB128();
                var mdef = new MethodDefinition(Dex.MethodReferences[methodIndex]);
                Dex.MethodReferences[methodIndex] = mdef;
            }
        }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:16,代码来源:DexReader.cs

示例10: PrefetchFieldDefinitions

        private void PrefetchFieldDefinitions(BinaryReader reader, uint fieldcount)
        {
            var fieldIndex = 0;
            for (var i = 0; i < fieldcount; i++)
            {
                if (i == 0)
                    fieldIndex = (int)reader.ReadULEB128();
                else
                    fieldIndex += (int)reader.ReadULEB128();

                reader.ReadULEB128();
                var fdef = new FieldDefinition(Dex.FieldReferences[fieldIndex]);
                Dex.FieldReferences[fieldIndex] = fdef;
            }
        }
开发者ID:shuixi2013,项目名称:Dexer,代码行数:15,代码来源:DexReader.cs

示例11: ReadEncodedAnnotation

        private Annotation ReadEncodedAnnotation(BinaryReader reader)
        {
            var typeIndex = (int) reader.ReadULEB128();
            var elementSize = (int) reader.ReadULEB128();

            var annotation = new Annotation();
            annotation.Type = (ClassReference) typeReferences[typeIndex];

            for (int i = 0; i < elementSize; i++)
            {
                var nameIndex = (int) reader.ReadULEB128();
                var name = strings[nameIndex];
                var value = ReadValue(reader);
                var argument = new AnnotationArgument(name, value);
                annotation.Arguments.Add(argument);
            }

            return annotation;
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:19,代码来源:DexReader.cs

示例12: PrefetchMethodDefinitions

 private void PrefetchMethodDefinitions(BinaryReader reader, ClassDefinition classDefinition, uint methodcount)
 {
     int methodIndex = 0;
     for (int i = 0; i < methodcount; i++)
     {
         if (i == 0)
         {
             methodIndex = (int) reader.ReadULEB128();
         }
         else
         {
             methodIndex += (int) reader.ReadULEB128();
         }
         reader.ReadULEB128();
         reader.ReadULEB128();
         var mdef = new MethodDefinition(methodReferences[methodIndex]);
         methodReferences[methodIndex] = mdef;
     }
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:19,代码来源:DexReader.cs

示例13: PrefetchFieldDefinitions

 private void PrefetchFieldDefinitions(BinaryReader reader, ClassDefinition classDefinition, uint fieldcount)
 {
     int fieldIndex = 0;
     for (int i = 0; i < fieldcount; i++)
     {
         if (i == 0)
         {
             fieldIndex = (int) reader.ReadULEB128();
         }
         else
         {
             fieldIndex += (int) reader.ReadULEB128();
         }
         reader.ReadULEB128();
         var fdef = new FieldDefinition(fieldReferences[fieldIndex]);
         fieldReferences[fieldIndex] = fdef;
     }
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:18,代码来源:DexReader.cs


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