[WinDBG 技巧] 列举所有Handle(句柄)以及查看Handle 信息

WinDBG的 !handle 命令可以让你方便调试句柄(handle)。

 

查看进程内所有句柄, 输入命令行 

0:014> !handle
Handle 4
  Type          Directory
Handle 8
  Type          Process
Handle c
  Type          Key
Handle 10
  Type          Mutant
Handle 14
  Type          ALPC Port
Handle 18
  Type          Key
Handle 1c
  Type          Event
Handle 20
  Type          Key

 ... (省略)

 

Handle 7e0
  Type          Mutant
392 Handles
Type            Count
None            17
Event           134
Section         47
File            35
Directory       3
Mutant          34
WindowStation   2
Semaphore       24
Key             47
Token           1
Process         3
Thread          27
Desktop         1
IoCompletion    4
Timer           5
Job             1
KeyedEvent      1
TpWorkerFactory 6


从WinDBG输出结果我们可以看到所有句柄的类型和值,以及统计信息(一共392个handle,其中有35个文件句柄,47个注册表句柄 .... )。

 

 

如果想查看某个句柄的详细信息, 可以用命令:

 

0:014> !handle 0x5c8 f
Handle 5c8
  Type          Key
  Attributes    0
  GrantedAccess 0x20019:
         ReadControl
         QueryValue,EnumSubKey,Notify
  HandleCount   2
  PointerCount  3
  Name          /REGISTRY/USER/S-1-5-21-2127521184-1604012920-1887927527-2966534/Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts
  Object Specific Information
    Key last write time:  16:52:14. 5/20/2009
    Key name FileExts

 

0x5c8 是句柄的值, 参数f 表示显示全部信息。 我们可以看到句柄0x5c8 是注册表句柄,路径为/REGISTRY/USER/S-1-5-21-2127521184-1604012920-1887927527-2966534/Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts。

 

 

值得一提的是,WinDBG 还提供了!htrace 命令,可以很方便来用检查句柄泄露(Handle Leak), 下次再写篇blog 专门介绍 !htrace

 

 

>> 原创文章的版权属于作者,转载请注明出处(http://blog.csdn.net/WinGeek/), 谢谢。 <<

 

 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值