首页
社区
课程
招聘
[求助]windbg中dt CRITICAL_SECTION命令显示的字段如何解读
发表于: 2011-8-24 10:18 7208

[求助]windbg中dt CRITICAL_SECTION命令显示的字段如何解读

2011-8-24 10:18
7208
0:003> dt CRITICAL_SECTION 12443c8
hello!CRITICAL_SECTION
  +0x000 DebugInfo : 0x00184b38 _RTL_CRITICAL_SECTION_DEBUG
  +0x004 LockCount : 0n-6
  +0x008 RecursionCount : 0n1
  +0x00c OwningThread : 0x0000139c Void
  +0x010 LockSemaphore : 0x00000754 Void
  +0x014 SpinCount : 0

红色的文字如何解读?

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
免费 6
支持
分享
最新回复 (5)
雪    币: 113
活跃值: (100)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
2
看看大牛的文章吧,http://msdn.microsoft.com/zh-cn/magazine/cc164040(en-us).aspx

LockCount 它被初始化为数值 -1;此数值等于或大于 0
时,表示此临界区被占用。当其不等于 -1 时,OwningThread 字段包含了拥有此临界区的线程 ID。此字段与 (RecursionCount -1) 数值之间的差值表示有多少个其他线程在等待获得该临界区。
RecursionCount
此字段包含所有者线程已经获得该临界区的次数。如果该数值为零,下一个尝试获取该临界区的线程将会成功。

但是,大牛的文章也是有局限性的,那是基于XP的,后来的系统多了很多变化。

Interpreting Critical Section Fields in Windows Server 2003 SP1 and Later

In Microsoft Windows Server 2003 Service Pack 1 and later versions of Windows, the LockCount field is parsed as follows:
The lowest bit shows the lock status. If this bit is 0, the critical section is locked; if it is 1, the critical section is not locked.
The next bit shows whether a thread has been woken for this lock. If this bit is 0, then a thread has been woken for this lock; if it is 1, no thread has been woken.
The remaining bits are the ones-complement of the number of threads waiting for the lock.
As an example, suppose the LockCount is -22. The lowest bit can be determined in this way:
0:009> ? 0x1 & (-0n22)
uate expression: 0 = 00000000
The next-lowest bit can be determined in this way:
0:009> ? (0x2 & (-0n22)) >> 1
uate expression: 1 = 00000001
The ones-complement of the remaining bits can be determined in this way:
0:009> ? ((-1) - (-0n22)) >> 2
uate expression: 5 = 00000005
In this example, the first bit is 0 and therefore the critical section is locked. The second bit is 1, and so no thread has been woken for this lock. The complement of
the remaining bits is 5, and so there are five threads waiting for this lock.

希望对你有帮助。
2011-8-24 23:02
0
雪    币: 47
活跃值: (34)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
其它的都明白,就是不明白0n-6, 0n1表示的数值具体是多少,难道是复数?
2011-8-25 14:09
0
雪    币: 113
活跃值: (100)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
4
晕倒,难道我上面的都白打了。
0n1就是1,0n-6就是-6啊。
2011-8-25 21:50
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
可以用!cs 命令来看的.
windbg帮助里面有详细解释.
2011-8-25 22:54
0
雪    币: 47
活跃值: (34)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
明白了,多谢ronging
2011-8-26 20:18
0
游客
登录 | 注册 方可回帖
返回
//