Winform工程反编译后的工作

Winform工程,反编译后,虽然能用,但不太好用。

因为form并没有像原生的那样。

 

所以,需要几个步聚:

 

1。 用ResGen工具,把二进制资源文件还原为xml格式:

ResGen fromXX.resource fromxx.resx

然后引入工程中。

可以,现在资源文件,还是散放在那里,没有与form在一块。

 

2。把fromXX的代码,一分为二,分成fromxx.cs和fromxx.Designer.cs

这个简单,只需要把formxx.cs做一个复制,然后把复制的这个改成fromxx.Designer.cs

然后,有点难度的就来的。

 

1) 修改vsproj文件,

    < Compile Include= "FormXX.cs ">
      < SubType> Form</ SubType>
    </ Compile>
    < Compile Include= "FormXX.Designer.cs ">
      < DependentUpon >FormXX.cs </DependentUpon >
    </ Compile>
    < EmbeddedResource Include= "SU.resx ">
      < DependentUpon >FormXX.cs </DependentUpon >
    </ EmbeddedResource>

2) 两个文件的类前面都加上partial关键字
3) designer.cs中,只留下定义和InitializeComponent
4) 其它的在from中。

3. 编译过。
4。这里,我们还是不能使用窗体编辑器,还需要过几关:
1) designer.cs把头部的所有的import都要去除,一个诀窍是一个一个去除,去除一个namespace,则所有的引用,都需要用全名称方式,如:
Lable 要换成 System.Windows.Forms.Label
2) 编译过,还是不行。窗体编辑器会告诉你一个奇怪的错误:指向这里。
  this.BackgroundImage = ((System.Drawing.Image)(manager.GetObject("$this.BackgroundImage")));

然后,的倒。怎么也看不出这里有什么错啊?
然后,我把manager这个变量,全部换成resources
如:
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SU));

然后,竟然通过了!!!

至此,窗体编辑器可以对窗体进行所见即所得编辑了。

posted on 2017-03-06 20:31  andywu188  阅读(475)  评论(0编辑  收藏  举报

导航