0:000> !do 00000000039a71d8
Name: System.Windows.Controls.Primitives.DataGridColumnHeader
MethodTable: 000007fee7e58090
EEClass: 000007fee7885bd8
Size: 384(0x180) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef3f2eb00 4000db0 8 ...eading.Dispatcher 0 instance 0000000002dd4e68 _dispatcher
000007fef3f3bb88 4001321 10 ...endencyObjectType 0 instance 000000000308a530 _dType
000007fef7825ac8 4001322 18 System.Object 0 instance 0000000000000000 _contextStorage
000007fef3f3e898 4001323 20 ...ctiveValueEntry[] 0 instance 00000000042efb08 _effectiveValues
000007fef7847b70 4001324 28 System.UInt32 1 instance 3680277 _packedData
000007fef3f33708 400131f 7c0 ...ependencyProperty 0 static 0000000002dd5ef0 DirectDependencyProperty
---------------------省略部分----
000007fef3f33708 40002ca 950 ...ependencyProperty 0 static 0000000002dfd820 ContentProperty
0000000000000000 40002cb 958 0 static 0000000002dfd908 HasContentPropertyKey
000007fef3f33708 40002cc 960 ...ependencyProperty 0 static 0000000002dfd948 HasContentProperty
000007fef3f33708 40002cd 968 ...ependencyProperty 0 static 0000000002dfdb00 ContentTemplateProperty
000007fef3f33708 40002ce 970 ...ependencyProperty 0 static 0000000002dfdc80 ContentTemplateSelectorProperty
3.利用!do命令查看依赖属性的成员变量值, 比如:
0:000> !do 0000000002dfd820
Name: System.Windows.DependencyProperty
MethodTable: 000007fef3f33708
EEClass: 000007fef3dd7550
Size: 88(0x58) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef7826970 400133c 8 System.String 0 instance 0000000002dfd630 _name
000007fef78282f8 400133d 10 System.Type 0 instance 0000000002d444b0 _propertyType
000007fef78282f8 400133e 18 System.Type 0 instance 0000000002dfab80 _ownerType
000007fef3f312a8 400133f 20 ....PropertyMetadata 0 instance 0000000002dfd7c0 _defaultMetadata
000007fef3f31088 4001340 28 ...dateValueCallback 0 instance 0000000000000000 _validateValueCallback
000007fef3f3e750 4001341 30 ...ndencyPropertyKey 0 instance 0000000000000000 _readOnlyKey
000007fef4194818 4001342 40 System.Int32 1 instance 4194530 _packedData
000007fef3f3e408 4001343 48 ....InsertionSortMap 1 instance 0000000002dfd868 _metadataMap
000007fef3f30fc8 4001344 38 ...erceValueCallback 0 instance 0000000000000000 _designerCoerceValueCallback
000007fef7825ac8 400133b 808 System.Object 0 static 0000000002d72000 UnsetValue
000007fef3f3c6c0 4001345 800 ...ty, WindowsBase]] 1 static 0000000012d5bb10 RegisteredPropertyList
000007fef7831c38 4001346 810 ...ections.Hashtable 0 static 0000000002d6f3d8 PropertyFromName
000007fef782c858 4001347 5c8 System.Int32 1 static 868 GlobalIndexCount
000007fef7825ac8 4001348 818 System.Object 0 static 0000000002d6f430 Synchronized
000007fef78282f8 4001349 820 System.Type 0 static 0000000002d68808 NullableType
4.利用.formats 得到依赖属性, 分2步
1)利用.formats 0n得到_packedData十六进制
2) 去掉高位,Decimal描述的就是依赖属性在依赖对象中的存储索引
如下:
0:000> .formats 0n4194530
Evaluate expression:
Hex: 00000000`004000e2
Decimal: 4194530
Octal: 0000000000000020000342
Binary: 00000000 00000000 00000000 00000000 00000000 01000000 00000000 11100010
Chars: .....@..
Time: Wed Feb 18 21:08:50 1970
Float: low 5.87779e-039 high 0
Double: 2.07237e-317
0:000> .formats 00e2
Evaluate expression:
Hex: 00000000`000000e2
Decimal: 226
Octal: 0000000000000000000342
Binary: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 11100010
Chars: ........
Time: Thu Jan 01 08:03:46 1970
Float: low 3.16693e-043 high 0
Double: 1.11659e-321
可知ContentProperty依赖属性在DataGridColumnHeader中的索引为226
5. 根据第4步的index,从第2步依赖对象的_effectiveValues 得到依赖属性的具体值,分3步:
1)利用!da -details 查看_effectiveValues 数组所有元素的值
2)查看每个元素,根据_propertyIndex (即第4步得到的Decimal值)确定依赖属性
3)利用!do命令查看元素的_value成员的值
比如:
0:000> !da -details 00000000042efb08
Name: System.Windows.EffectiveValueEntry[]
MethodTable: 000007fef3f3e898
EEClass: 000007fef3e0c8a0
Size: 408(0x198) bytes
Array: Rank 1, Number of elements 24, Type VALUETYPE
Element Methodtable: 000007fef3f36120
[0] 00000000042efb18
Name: System.Windows.EffectiveValueEntry
MethodTable: 000007fef3f36120
EEClass: 000007fef3dd8c90
Size: 32(0x20) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef7825ac8 400136e 0 System.Object 0 instance 0000000002e1c5d8 _value
000007fef7830940 400136f 8 System.Int16 1 instance 3 _propertyIndex
000007fef41949d0 4001370 a System.Int16 1 instance 2 _source
--------------------------------省略部分------------------------------
[15] 00000000042efc08
Name: System.Windows.EffectiveValueEntry
MethodTable: 000007fef3f36120
EEClass: 000007fef3dd8c90
Size: 32(0x20) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef7825ac8 400136e 0 System.Object 0 instance 00000000042efca0 _value
000007fef7830940 400136f 8 System.Int16 1 instance 226 _propertyIndex
000007fef41949d0 4001370 a System.Int16 1 instance 65 _source
可知ContentProperty为_effectiveValues的第16个元素, 其值存储在_value中
0:000> !do 00000000042efca0
Name: System.Windows.ModifiedValue
MethodTable: 000007fef3f40d58
EEClass: 000007fef3e0d000
Size: 48(0x30) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef7825ac8 4001387 8 System.Object 0 instance 0000000000000000 _baseValue
000007fef7825ac8 4001388 10 System.Object 0 instance 0000000000000000 _expressionValue
000007fef7825ac8 4001389 18 System.Object 0 instance 0000000000000000 _animatedValue
000007fef7825ac8 400138a 20 System.Object 0 instance 0000000002d93618 _coercedValue
6.根据第5步中的成员_coercedValue得到依赖属性的具体值,大功告成!
0:000> !do 0000000002d93618
Name: System.String
MethodTable: 000007fef7826970
EEClass: 000007fef73aeec8
Size: 36(0x24) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
String: 导入数据源
Fields:
MT Field Offset Type VT Attr Value Name
000007fef782c858 40000ed 8 System.Int32 1 instance 5 m_stringLength
000007fef782b398 40000ee c System.Char 1 instance 5bfc m_firstChar
000007fef7826970 40000ef 10 System.String 0 shared static Empty
>> Domain:Value 00000000007f85a0:0000000002d41420 <<