C# 使用reflector与reflexil实现代码注入

需求

1.         双击窗体,弹出无标题的messageBox

1.bmp

源码

using System;

using System.Windows.Forms;

 

namespace ReflexilDemo

{

    public class DemoForm : Form

    {

        public DemoForm()

        {

            //InitializeComponent();

            this.Click+=DisplayResultButton_Click;

        }

 

        private void ComputeAndDisplay(decimal x, decimal y)

        {

            MessageBox.Show(String.Format("{0}+{1}={2}", x, y, x + y));

        }

 

        private void DisplayResultButton_Click(object sender, EventArgs e)

        {

            decimal a=3.0M;

            decimal b=6.0M;

            ComputeAndDisplay(a, b);

        }

       

        static void Main()

   

        {

            DemoForm df=new DemoForm();

            df.ShowDialog();

           

            Console.Read ();

        }

    }

}

 

2.         注入代码后,双击窗体,弹出有标题的messageBox

2.bmp

 

 

实现

使用.NET ReflectorReflexil ,修改il代码实现。

由源码可知,messagebox的调用是在ComputeAndDisplay方法中完成的,所以我们需要修改此方法的il

实现步骤:

Reflexil打开 ComputeAndDisplay

 

 

1.jpg

 

 

插入字符串

2.jpg

修改MessageBoxShowstring----àMessageBox.Show(string,string)

3.jpg

4.jpg

5.jpg

 

 

 

选择Show(string,string),双击

6.jpg

 

 

然后保存修改后的结果

7.jpg

再次运行

8.jpg

转载于:https://www.cnblogs.com/hbb0b0/archive/2009/10/08/1579307.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值