Side-by-side Assemblies

最近准备往AntiSpy中加入应用层检测Hook的功能。在写这个功能的时候碰上了一些问题,花了很长时间才搞定,在此记录下,后来人可以少走俺的这些“弯路”。

在枚举“阿里旺旺”进程的钩子时,发现此进程加载了两个同名的Dll,即“ comctl32.dll”。
而其中comdlg32.dll的导入表中会引入  comctl32.dll 模块的导出函数,这里就有一个问题了,comdlg32.dll模块到底导入的是哪个 comctl32.dll 导出的函数呢?

Google了下才发现,此技术叫Side-by-side Assemblies( http://msdn.microsoft.com/en-us/library/aa376307.aspx)。用到此技术的模块通常会被放在Windows\winsxs目录下。
Side-by-side Assemblies_第1张图片

当PE文件的Dll加载器加载相关的模块时,会 根据PE文件发布时自带的manifest 加载适当版本的Dll ,如果不发布该项manifest ,Dll加载器按默认版本加载Dll,例如,xp系统的默认   Comctl32.DLL   版本 5.0
Side-by-side Assemblies_第2张图片

用资源编辑器打开comdlg32.dll,并定位到manifest。
...
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="*"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>
...
这里要求使用的是6.0.0.0版本,因此,此处 comdlg32.dll 导入的是第二个版本的 Comctl32.DLL  模块。

你可能感兴趣的:(Side-by-side Assemblies)