首页
社区
课程
招聘
windbg查看STL类型数据
发表于: 2022-11-25 19:49 9985

windbg查看STL类型数据

2022-11-25 19:49
9985

windbg自带的stl_map等指令不能正确导出stl容器中的数据,网上有个同行写的windbg插件stlkit,用于导出stl map和set的数据


备注:如果是查看std::string类型,不用安装任何插件。直接执行命令 :dt -b 字符串变量名字

查看_Ptr成员就是string字符串的内容。


一、不使用插件查看STL类型

备注:(不使用插件的这种方法,显示map的,这些在windbg 10版本上可以,windbg6.12好像不行)

1、根据map变量名称显示std::map的内容

      使用命令:dx map变量名

0:000> dx direct
		direct                 : { size=0x2 } [Type: std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >]
			[<Raw View>]     [Type: std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >]
			[comparator]     : less [Type: std::_Compressed_pair<std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::_Compressed_pair<std::allocator<std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,void *> >,std::_Tree_val<std::_Tree_simple_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >,1>,1>]
			[allocator]      : allocator [Type: std::_Compressed_pair<std::allocator<std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,void *> >,std::_Tree_val<std::_Tree_simple_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >,1>]
			[0x0]            : "sanganlei", "hello" [Type: std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >]
			[0x1]            : "yuyu", "zhognguo" [Type: std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >]


2、根据map地址和类型,显示std::map的内容

a)根据map地址和类型,显示std::map的内容

指令格式:dx @$myvar = ((map类型*)addr)

	0:000> dx @$myvar = ((std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > * ) 0x00cffec8)
			@$myvar = ((std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > * ) 0x00cffec8)                 : 0xcffec8 : { size=0x2 } [Type: std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > *]
				[<Raw View>]     [Type: std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >]
				[comparator]     : less [Type: std::_Compressed_pair<std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::_Compressed_pair<std::allocator<std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,void *> >,std::_Tree_val<std::_Tree_simple_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >,1>,1>]
				[allocator]      : allocator [Type: std::_Compressed_pair<std::allocator<std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,void *> >,std::_Tree_val<std::_Tree_simple_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >,1>]
				[0x1]            : "sanganlei", "hello" [Type: std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >]
				[0x2]            : "yuyu", "zhognguo" [Type: std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >]

        b)接着上一步显示map的second内容,循环次数根据上右边的个数填写。

            0:000> .for (r $t0 = 0 ; @$t0 < 5 ; r $t0 = @$t0+1) { dx @$myvar[0][@$t0].second }

			0:000> .for (r $t0 = 0 ; @$t0 < 5 ; r $t0 = @$t0+1) { dx @$myvar[0][@$t0].second }
			@$myvar[0][@$t0].second                  : "hello" [Type: std::basic_string<char,std::char_traits<char>,std::allocator<char> >]
				[<Raw View>]     [Type: std::basic_string<char,std::char_traits<char>,std::allocator<char> >]
				[size]           : 0x5 [Type: unsigned int]
				[capacity]       : 0xf [Type: unsigned int]
				[allocator]      : allocator [Type: std::_Compressed_pair<std::allocator<char>,std::_String_val<std::_Simple_types<char> >,1>]
				[0]              : 104 'h' [Type: char]
				[1]              : 101 'e' [Type: char]
				[2]              : 108 'l' [Type: char]
				[3]              : 108 'l' [Type: char]
				[4]              : 111 'o' [Type: char]


二、使用插件的方法查看STL类型

使用方法和下载地址如下:

1.stlkit拷贝到windbg安装路径下的winext目录中;

2.windbg没有自动加载stlkit时,使用.load stlkit指令手动加载

3.!set或!stlkit.set指令导出STL set的内容(参考图1)

使用方法是:

!set 变量名

!set 地址#成员类型

4.!map或!stlkit.map指令导出STL map的内容(参考图2、图3、图4)

使用方法是:

!map 变量名

!map 地址#map继承的树类型

!map 地址#key_type#value_type

5.注意参数一定用’#’串联;所有类型名最好直接从windbg中复制,windbg对类型名很敏感,即使一个空格的差别都不能识别

6.插件下载地址(某个):http://download.csdn.net/detail/yichigo/7687719

                           (图1、set查看的两种方法)



                                            (图2、!map 变量名)



                         (图3、!map 地址#map继承的树类型)


(图4、!map 地址#key_type#value_type)

(图4、!map 地址#key_type#value_type)



[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

最后于 2022-11-25 20:08 被sanganlei编辑 ,原因:
收藏
免费 2
支持
分享
最新回复 (2)
雪    币: 832
活跃值: (3936)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
2
你这是有符号表的情况把???
2022-11-25 20:16
0
雪    币: 1922
活跃值: (4165)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
mark
2023-1-13 23:30
0
游客
登录 | 注册 方可回帖
返回
//