Mono.Cecil.Cil.CodeReader.GetInstruction C# (CSharp) Method

GetInstruction() static private method

static private GetInstruction ( Collection instructions, int offset ) : Instruction
instructions Collection
offset int
return Instruction
        static Instruction GetInstruction(Collection<Instruction> instructions, int offset)
        {
            var size = instructions.size;
            var items = instructions.items;
            if (offset < 0 || offset > items [size - 1].offset)
                return null;

            int min = 0;
            int max = size - 1;
            while (min <= max) {
                int mid = min + ((max - min) / 2);
                var instruction = items [mid];
                var instruction_offset = instruction.offset;

                if (offset == instruction_offset)
                    return instruction;

                if (offset < instruction_offset)
                    max = mid - 1;
                else
                    min = mid + 1;
            }

            return null;
        }

Same methods

CodeReader::GetInstruction ( int offset ) : Instruction

Usage Example

Esempio n. 1
0
        private void ReadMethodBody()
        {
            this.MoveTo(this.method.RVA);
            byte num  = base.ReadByte();
            int  num1 = num & 3;

            if (num1 == 2)
            {
                this.body.code_size    = num >> 2;
                this.body.MaxStackSize = 8;
                this.ReadCode();
            }
            else
            {
                if (num1 != 3)
                {
                    throw new InvalidOperationException();
                }
                this.position--;
                this.ReadFatMethod();
            }
            ISymbolReader symbolReader = this.reader.module.symbol_reader;

            if (symbolReader != null)
            {
                Collection <Instruction> instructions = this.body.Instructions;
                symbolReader.Read(this.body, (int offset) => CodeReader.GetInstruction(instructions, offset));
            }
        }
All Usage Examples Of Mono.Cecil.Cil.CodeReader::GetInstruction