考试首页 | 考试用书 | 培训课程 | 模拟考场 | 考试论坛  
  当前位置:编程开发 > DotNET > C# > 文章内容
  

C教程:编辑IL文件修改DLL文件的方法

 [ 2017年6月27日 ] 【

  如:KS.Gantt.DLL 为例

  1、使用ILSpy反编译 工具

  2、利用ildasm反编译 KS.Gantt.dll 生成IL中间代码 一般会生成 *.il 和*.res 一些其它资源文件 *.resources

  3、然后用记事本修改IL文件

  4、然后用ilasm编译中间代码,生成新的KS.Gantt.dll

  5、在项目中使用 查看效果

  破解过程

  1 我找到了Gantt 控件的验证的代码

  2 利用ildasm反编译 KS.Gantt.dll

  3 打开IL文件找到对应的代码然后删除掉 如果不会 去学习一哈 怎么使用IL

  哈哈 就这个。。

  ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
.try
  {
   IL_0260: ldarg.0
   IL_0261: ldtoken  KS.Gantt.Gantt
   IL_0266: call    class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
   IL_026b: ldarg.0
   IL_026c: call    class [System]System.ComponentModel.License [System]System.ComponentModel.LicenseManager::Validate(class [mscorlib]System.Type,
                                                               object)
   IL_0271: stfld   class [System]System.ComponentModel.License KS.Gantt.Gantt::license
   IL_0276: leave.s  IL_0297
 
  } // end .try
  catch [mscorlib]System.Exception
  {
   IL_0278: pop
   IL_0279: call    bool [mscorlib]System.Diagnostics.Debugger::get_IsAttached()
   IL_027e: brtrue.s  IL_0295
 
   IL_0280: newobj   instance void KS.Gantt.frmAbout::.ctor()
   IL_0285: stloc.0
   IL_0286: ldloc.0
   IL_0287: callvirt  instance valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.Form::ShowDialog()
   IL_028c: pop
   IL_028d: ldloc.0
   IL_028e: callvirt  instance void [System]System.ComponentModel.Component::Dispose()
   IL_0293: ldnull
   IL_0294: stloc.0
   IL_0295: leave.s  IL_0297
 
  }

  4 然后用ilasm编译中间代码

  ?

1
ilasm /dll /output=D:\MyDll\KS.Gantt.dll /Resource=D:\MyDll\Gantt.res D:\MyDll\Gantt.il

  我一看到这几个单词。我就知道成功了。。

  5 然后在去验证一哈DLL文件

  那个授权验证代码不在了哈。。

  不过呢。后来我测试 。我发现在这个DLL不能用的。运行会报这个错的

  ?

1
Unhandled Exception: System.IO.FileLoadException: Strong name validation failed

  所以又得删除那个签名,删除以下所有内容

  ?

1
2
3
4
5
6
7
8
9
10
.publickey = (00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00  // .$..............
        00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00  // .$..RSA1........
        3B B2 D0 F9 DA 7E 55 B2 50 40 6B CF EB 20 F6 67  // ;....~U.P@k.. .g
        E7 D6 AF 65 32 4F 6D 21 5D 91 53 0B 04 C7 E2 15  // ...e2Om!].S.....
        F0 6A EE 38 F8 74 DB 22 34 F9 A1 B5 16 C1 04 66  // .j.8.t."4......f
        B7 0B A8 36 49 9E 8A 71 E1 D1 26 AB A2 78 4E 3A  // ...6I..q..&..xN:
        8B 71 8C 7F 4D 54 22 28 5F 1F 8D DE 6C 96 EC 22  // .q..MT"(_...l.."
        34 8A 35 3F 95 0A F4 F4 7F B7 8C F5 5D F4 CB 54  // 4.5?........]..T
        92 94 DD 5E D5 0D 20 12 7F B1 9B 15 7F 0E FB 2A  // ...^.. ........*
        76 5F 45 3D 20 2C E2 6D FE 55 72 30 49 76 28 FE ) // v_E= ,.m.Ur0Iv(.
首页 1 2 尾页
本文纠错】【告诉好友】【打印此文】【返回顶部
将考试网添加到收藏夹 | 每次上网自动访问考试网 | 复制本页地址,传给QQ/MSN上的好友 | 申请链接 | 意见留言 TOP
关于本站  网站声明  广告服务  联系方式  站内导航  考试论坛
Copyright © 2007-2013 中华考试网(Examw.com) All Rights Reserved