WinDbg 查看静态变量

 

 

有如下Class。若想查看静态变量内容。因为静态变量和类绑定,仅需要查看类即可。

namespace ConsoleApplication13
{
    class Program
    {
        public static string public_string = "pubstr_static";
        public static string private_string = "pristr_static";
...
} }

 

1、查找类。 !Name2EE ConsoleApplication13.exe ConsoleApplication13.Program

0:000> !Name2EE ConsoleApplication13.exe ConsoleApplication13.Program
Module:      00007ff83abd40c0
Assembly:    ConsoleApplication13.exe
Token:       0000000002000002
MethodTable: 00007ff83abd5d98
EEClass:     00007ff83ace3238
Name:        ConsoleApplication13.Program

2、导出类。 !DumpClass 00007ff83ace3238

0:000> !DumpClass 00007ff83ace3238
Class Name:      ConsoleApplication13.Program
mdToken:         0000000002000002
File:            E:\新建文件夹\ConsoleApplication13\bin\Debug\ConsoleApplication13.exe
Parent Class:    00007ff887de4b60
Module:          00007ff83abd40c0
Method Table:    00007ff83abd5d98
Vtable Slots:    4
Total Method Slots:  6
Class Attributes:    100000  
Transparency:        Critical
NumInstanceFields:   0
NumStaticFields:     3
              MT    Field   Offset                 Type VT     Attr            Value Name
00007ff888498538  4000001        8        System.String  0   static 000000000f0143a0 public_string
00007ff888498538  4000002       10        System.String  0   static 000000000f0143d8 private_string
0000000000000000  4000003       18                       0   static 0000000000000000 CS$<>9__CachedAnonymousMethodDelegate1

3、可看出3个静态变量,其中2个String。!do  000000000f0143a0 。红色即为内容。

0:000> !do  000000000f0143a0 
Name:        System.String
MethodTable: 00007ff888498538
EEClass:     00007ff887de4ab8
Size:        52(0x34) bytes
File:        C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
String:      pubstr_static
Fields:
              MT    Field   Offset                 Type VT     Attr            Value Name
00007ff88849af60  4000243        8         System.Int32  1 instance               13 m_stringLength
00007ff8884996e8  4000244        c          System.Char  1 instance               70 m_firstChar
00007ff888498538  4000248       80        System.String  0   shared           static Empty
                                 >> Domain:Value  0000000000559b60:NotInit  <<

 

posted on 2017-09-06 15:24  水手paul2008  阅读(545)  评论(0编辑  收藏  举报