Confuser.Core/DnlibUtils.cs
/// <summary>
///     Replaces the specified instruction reference with another instruction.
/// </summary>
/// <param name="body">The method body.</param>
/// <param name="target">The instruction to replace.</param>
/// <param name="newInstr">The new instruction.</param>
// Token: 0x0600015B RID: 347 RVA: 0x0000BD00 File Offset: 0x00009F00
Replaces the specified instruction reference with another instruction.
Replaces the specified instruction reference with another instruction .
public static void ReplaceReference(this CilBody body, Instruction target, Instruction newInstr)
		{
			foreach (ExceptionHandler eh in body.ExceptionHandlers)
			{
				if (eh.TryStart == target)
				{
					eh.TryStart = newInstr;
				}
				if (eh.TryEnd == target)
				{
					eh.TryEnd = newInstr;
				}
				if (eh.HandlerStart == target)
				{
					eh.HandlerStart = newInstr;
				}
				if (eh.HandlerEnd == target)
				{
					eh.HandlerEnd = newInstr;
				}
			}
			foreach (Instruction instr in body.Instructions)
			{
				if (instr.Operand == target)
				{
					instr.Operand = newInstr;
				}
				else if (instr.Operand is Instruction[])
				{
					Instruction[] targets = (Instruction[])instr.Operand;
					for (int i = 0; i < targets.Length; i++)
					{
						if (targets[i] == target)
						{
							targets[i] = newInstr;
						}
					}
				}
			}
		}
public static void ReplaceReference ( this CilBody body , Instruction target , Instruction newInstr ) { foreach ( ExceptionHandler eh in body . ExceptionHandlers ) { if ( eh . TryStart == target ) { eh . TryStart = newInstr ; } if ( eh . TryEnd == target ) { eh . TryEnd = newInstr ; } if ( eh . HandlerStart == target ) { eh . HandlerStart = newInstr ; } if ( eh . HandlerEnd == target ) { eh . HandlerEnd = newInstr ; } } foreach ( Instruction instr in body . Instructions ) { if ( instr . Operand == target ) { instr . Operand = newInstr ; } else if ( instr . Operand is Instruction [ ] ) { Instruction [ ] targets = ( Instruction [ ] ) instr . Operand ; for ( int i = 0 ; i < targets . Length ; i ++ ) { if ( targets [ i ] == target ) { targets [ i ] = newInstr ; } } } } }
Replaces the specified instruction reference with another instruction.
Replaces the specified instruction reference with another instruction .
CilBody
this
target
Instruction
The instruction to replace.
The instruction to replace .
newInstr
Instruction
The new instruction.
The new instruction .
body
The method body.
The method body .