Reflector 之reflexil使用
先写个简单的控制台程序

工具,添加插件.

选中reflexil 1.6 (1.7从来没附加成功过.不知道为啥..)

一 直接修改操作数

可以直接编辑IL

Update 后
在程序集中右键

另存程序.
执行刚保存的程序

还可以直接添加IL 接着让后面继续输出
二 直接注入IL
右键,新建(new Create),填写对应的操作码,选择类型,
值得注意的是右边的按钮,append(添加),接着是插入在选择之前,然后是插入在选择之后;别选错了.


注意 注入的时候操作数的类型别选错了.
然后继续参照上面的,将程序另存一次.

三 替换代码
如果不想折腾IL,直接选择 替换所有代码.

不过这意味着你要重写所有代码(大多数时,我都会用在重写某个方法上)…然后提交一下,他会自动编译, 然后继续参照上面的,将程序另存一次.

提交完成后会自动编译,并且再右侧区域会生成对应的IL.
然后继续参照上面的,将程序另存一次.
执行下…

四 注入方法

别选错地方了.是你要将方法注入到某个类中,不是注入class所以,一定是在类上右键

暂时只能注入返回值为void的方法
对了,点击OK后会有个该死的提示,这提示的大致意思是:
当你在执行,增加,删除,重命名,等动作时,你不会直接看见相应的操作,他们是不同步的.
你必须要重新加载程序集才可以看见.
当然,你还需要将程序另存一次.!!!!!!!!!!!!!
然后你需要关闭程序集,接着重新打开刚才另存的

现在方法已经注入进去了.

然后我需要给它添加点内容..
让方法输出个InjectedMethod字符串
在方法中添加IL

接着修改Main方法,并且调用刚才注入的方法.

另存下..
执行结果.

PS: 如果是替换代码的话,先更改injectmethod时不用实现main方法,只需要修改injectmethod()方法,然后再去修改Main方法.调用时因为injectmethod方法不是static所以需要实例化Program
接下来说说添加有参数,有返回值的方法:
先在参数(parameter)标签,中添加一个参数.

然后在属性标签中修改返回值为string.

接着使用替换代码的功能

可以看见方法已经带有参数并且有返回值.
修改下这个方法

打印下传进来的名字,并且打印当前时间
修改主函数调用

编译,然后不要忘记另存….

Good Job .
Have Fun .
By McevilRock
9-7/2014




网友评论