Mono.Cecil.Cil.MethodBody.GetILProcessor C# (CSharp) Method

GetILProcessor() public method

public GetILProcessor ( ) : Mono.Cecil.Cil.ILProcessor
return Mono.Cecil.Cil.ILProcessor
		public ILProcessor GetILProcessor ()
		{
			return new ILProcessor (this);
		}
	}

Usage Example

Esempio n. 1
0
        private static void InsertInvalidIl(MethodBody methodBody)
        {
            //Get the instructions and cil worker
            var instructions = methodBody.Instructions;

            if (instructions.Count <= 0)
            {
                return; //We can only do this if we have instructions to work with
            }
            ILProcessor il = methodBody.GetILProcessor();

            //First create an invalid il instruction
            OpCode      fakeOpCode      = CreateInvalidOpCode();
            Instruction invalidIlInstr1 = il.Create(fakeOpCode);
            Instruction invalidIlInstr2 = il.Create(fakeOpCode);
            Instruction originalFirst   = instructions[0];

            //Insert invalid il at the start
            il.InsertBefore(originalFirst, invalidIlInstr1);
            il.InsertBefore(invalidIlInstr1, invalidIlInstr2);

            //Create the branch statement
            Instruction branchStatement = il.Create(OpCodes.Br_S, originalFirst);

            //Add the branch to the start
            il.InsertBefore(invalidIlInstr2, branchStatement);

            //Readjust the offsets
            il.AdjustOffsets(methodBody, 4);
        }
All Usage Examples Of Mono.Cecil.Cil.MethodBody::GetILProcessor