我正在尝试编写一个 Windbg 脚本,其中我在一个文件中有 1k 个地址。对于每个地址,偏移处0x30
是一个 COM 对象。
我想从 COM 对象中获取所有本机指针。我知道如何手动操作,如下所示。我在脚本中迭代它时遇到了麻烦。
从 a System.__ComObject
,!do <comobject>
给RCW: in text
. 倾倒RCW
使用!DumpRCW
给了我IUnknown pointer
我需要的东西。
Name: System.__ComObject
MethodTable: 00007ffcf2941330
EEClass: 00007ffcf22264b0
RCW: 000001d3634f3460
Size: 32(0x20) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
MT Field Offset Type VT Attr Value Name
00007ffcf2949de8 40005b2 8 System.Object 0 instance 0000000000000000 __identity
00007ffcf294d1f8 400045c 10 ...ections.Hashtable 0 instance 0000000000000000 m_ObjectToDataMap
0:000> !DumpRCW /d 000001d35a9e0d70
Managed object: 000001d37976a708
Creating thread: 000001d35d552a60
IUnknown pointer: 000001d31e63ce28
COM Context: 000001dffecab0f8
Managed ref count: 1
IUnknown V-table pointer : 00007ffcd3f0edb8 (captured at RCW creation time)
Flags:
COM interface pointers:
IP Context MT Type
000001d31e63ce20 000001dffecab0f8 00007ffc949869c0 NativeClass.ClassX
000001d31e63ce28 000001dffecab0f8 00007ffc949868e0 NativeClass.ClassX
对于脚本,问题是:
如何从使用脚本中获取RCW
价值?ComObject
中的字段System.__ComObject
为空。
我到目前为止的脚本:
0:000> .foreach /f ( obj "d:\windbg\debug1.allmanagedtxs.small.txt") { .printf "%p\n", obj; !do poi(${obj}+0x30) }
000001d378daa6d8
Name: System.__ComObject
MethodTable: 00007ffcf2941330
EEClass: 00007ffcf22264b0
RCW: 000001d3634f3460
Size: 32(0x20) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
MT Field Offset Type VT Attr Value Name
00007ffcf2949de8 40005b2 8 System.Object 0 instance 0000000000000000 __identity
00007ffcf294d1f8 400045c 10 ...ections.Hashtable 0 instance 0000000000000000 m_ObjectToDataMap
000001d37976a728
Name: System.__ComObject
MethodTable: 00007ffcf2941330
EEClass: 00007ffcf22264b0
RCW: 000001d35a9e0d70
Size: 32(0x20) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
MT Field Offset Type VT Attr Value Name
00007ffcf2949de8 40005b2 8 System.Object 0 instance 0000000000000000 __identity
00007ffcf294d1f8 400045c 10 ...ections.Hashtable 0 instance 0000000000000000 m_ObjectToDataMap