介绍SOS中的SaveModule命令

这个命令允许你把一个已经加载到内存中的一个镜像(DLL, EXE)写回到一个文件中. 这非常有用, 尤其是你在debugging一个full memory dump, 并且没有原始的exe或dll的时候. 这个命令通常用来保存一个托管二进制信息到一个文件中, 稍后你就可以使用Reflector来反汇编里面的代码了.

 

首先, 使用lm命令来获得image的base address.

0:000> lm
start    end        module name
00400000 00408000   image00400000     (deferred)
10200000 102ac000   MSVCR80D     (deferred)
5a000000 5a0b1000   mscoree      (deferred)
5a140000 5a29e000   mscorjit     (deferred)
5b660000 5c440000   mscorlib_dll     (deferred)
5d1d0000 5e13c000   mscorwks     (deferred)

 

我们需要一份mscorwks.dll的拷贝, 我们可以运行:

0:000> !SaveModule 5d1d0000 c:\pub\out.tmp
4 sections in file
section 0 - VA=1000, VASize=e82da9, FileAddr=400, FileSize=e82e00
section 1 - VA=e84000, VASize=24d24, FileAddr=e83200, FileSize=ec00
section 2 - VA=ea9000, VASize=5a8, FileAddr=e91e00, FileSize=600
section 3 - VA=eaa000, VASize=c183c, FileAddr=e92400, FileSize=c1a00

 

在debugging第三方的托管组件时, 这个命令可以让你看一下第三方的组件的源代码, 以便你分析引发问题的可能的原因.

 

参考资料:

WinDBG帮助

posted on 2010-08-13 14:54  中道学友  阅读(770)  评论(0编辑  收藏  举报

导航

技术追求准确,态度积极向上