半夜ATM机前看书的那位

导航

C#中将dll汇入exe,并加壳

ILMerge runs in the v2.0 .NET Runtime, but it is also able to merge v1 or v1.1 assemblies. However it can merge PDB files only for v2 assemblies.

Currently, ILMerge works only on Windows-based platforms. It does not yet support Rotor or Mono.

Download: http://download.microsoft.com/download/1/3/4/1347C99E-9DFB-4252-8F6D-A3129A069F79/ILMerge.msi

因为使用了3层架构,运行目录下有很多dll文件,最终发布时,我打算将dll文件都合并到exe文件中去。微软发布的免费软件ILmerge可以完成这项工作,研究了一下,其用法如下:

1、合并file1.dll、file2.dll到destination.dll
ILmerge /ndebug /target:dll /out:C:\destination.dll /log C:\file1.dll C:\file2.dll

2、合并file1.dll、file2.dll以及myApp.exe到newApp.exe  
ILmerge /ndebug /target:winexe /out:C:\newApp.exe /log C:\myapp.exe C:\file1.dll C:\file2.dll

注意:合并为exe时,myapp.exe必须写在file1.dll、file2.dll前面

完 成之后,就得到了一个exe文件,如果想做一些邪恶的事情,可以将一些破解软件的dll合并到你的exe中去。前提是,所有的dll都是托管的,如果尝试 合并C++写的dll,则会失败。有一个工具,叫做mergebin.exe,可以合并托管和非托管dll,用法我还没研究出来,似乎比较困难的样子。这 个工具是ADO.NET 2.0 Data Provider for SQLite的作者写的,他发布的System.Data.SQLite.dll可以被dotNet程序引用,还可以直接被C/C++程序调用,这个 dll就是托管和非托管混合的dll,果然是很牛的!mergebin.exe在其源码包里,有兴趣的朋友可以研究一下。

posted on 2011-08-22 14:27  zhizhesky  阅读(263)  评论(0编辑  收藏  举报