Tuesday, February 17, 2009

Display content of std::map

After reading STL AND WINDBG from Memory Dump Analysis Vol 2 by Dmitry Vostokov, I try to dump the content for std::map as following.

0:056> dt ftpaccess!IFTPLicense_Impl 0x0f7d0318
+0x000 __VFN_table : 0x01ba058c
+0x004 m_nRefCount : 1
+0x008 m_CS : IFTPCritSec
+0x020 m_pLicense : 0x00ffdfb8 CIpswitchLicense2
+0x024 m_FeatureMap : std::map,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> > >
+0x030 m_pszFeatureList : 0x0f802ed0 "IPLocking,SSH,ThinWeb"


It is a license object. Its memeber m_FeatureMap is std::map.

0:056> dt -n std::map,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> > > (0x0f7d0318+0x024)
ftpaccess!std::map,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> > >
+0x000 comp : std::less,std::allocator > >
+0x001 _Alnod : std::allocator,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node>
+0x002 _Alptr : std::allocator,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node *>
+0x003 _Alval : std::allocator,std::allocator > const ,FEATURE_DATA *> >
+0x004 _Myhead : 0x0f806c98 std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node
+0x008 _Mysize : 3


There are three items in the map. _Myhead is the first node.

0:056> dt -n std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node 0x0f806c98
ftpaccess!std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node
+0x000 _Left : 0x0f806d28 std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node
+0x004 _Parent : 0x00ffea70 std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node
+0x008 _Right : 0x00ffeac8 std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node
+0x00c _Myval : std::pair,std::allocator > const ,FEATURE_DATA *>
+0x02c _Color : 1 ''
+0x02d _Isnil : 1 ''

The key-value pair in the first node (_Myhead) is empty. However, it is linked to another three nodes. Let us dump the left node.

0:056> dt -n std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node 0x0f806d28
ftpaccess!std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node
+0x000 _Left : 0x0f806c98 std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node
+0x004 _Parent : 0x00ffea70 std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node
+0x008 _Right : 0x0f806c98 std::_Tree_nod,std::allocator >,FEATURE_DATA *,std::less,std::allocator > >,std::allocator,std::allocator > const ,FEATURE_DATA *> >,0> >::_Node
+0x00c _Myval : std::pair,std::allocator > const ,FEATURE_DATA *>
+0x02c _Color : 0 ''
+0x02d _Isnil : 0 ''


The key-value pair (_Myval) in the left node is not empty. Let us dump the pair to see what it is.

0:056> dt -n std::pair,std::allocator > const ,FEATURE_DATA *> (0x0f806d28+0x00c)
ftpaccess!std::pair,std::allocator > const ,FEATURE_DATA *>
+0x000 first : std::basic_string,std::allocator >
+0x01c second : 0x0f7d1bb0 FEATURE_DATA


The key-value pair consists of first and second. The first is key, which is std::string, the second is value, which is FEATURE_DATA.

0:056> dt -r -n std::basic_string,std::allocator > (0x0f806d28+0x00c)
ftpaccess!std::basic_string,std::allocator >
+0x000 _Alval : std::allocator
=01b90000 npos : 0x905a4d
+0x004 _Bx : std::basic_string,std::allocator >::_Bxty
+0x000 _Buf : [8] "ฐཽSSHEna"
+0x000 _Ptr : 0x0f7d0e10 "IPLocking"
+0x014 _Mysize : 9
+0x018 _Myres : 0xf


0:056> dt -r -n FEATURE_DATA 0x0f7d1bb0
ftpaccess!FEATURE_DATA
+0x000 nEnabled : 1
+0x004 nLicenseType : -1
+0x008 tmActivationDate : _SYSTEMTIME
+0x000 wYear : 0
+0x002 wMonth : 0
+0x004 wDayOfWeek : 0
+0x006 wDay : 0
+0x008 wHour : 0
+0x00a wMinute : 0
+0x00c wSecond : 0
+0x00e wMilliseconds : 0
+0x018 tmLicenseExpires : _SYSTEMTIME
+0x000 wYear : 0
+0x002 wMonth : 0
+0x004 wDayOfWeek : 0
+0x006 wDay : 0
+0x008 wHour : 0
+0x00a wMinute : 0
+0x00c wSecond : 0
+0x00e wMilliseconds : 0
+0x028 szSerialNumber : [260] ""


So the key-value pair indicates that IPLocking feature is enbled in the license. With the same approach, I can dump the content for the parent and right nodes.
 

0 comments:

Post a Comment