开发者

How to replace allocators of stl with actual source code

开发者 https://www.devze.com 2023-01-09 15:39 出处:网络
I need to replace allocators with their original source code. I am extracting exported methods from the PE export table and facing strange lengthy allocators where STL containers were used in the orig

I need to replace allocators with their original source code. I am extracting exported methods from the PE export table and facing strange lengthy allocators where STL containers were used in the original source code. i.e. If source code was:

开发者_开发知识库
   typedef std::list<std::basic_string<_TCHAR> > TokenList;
   EXPORTS_API const TokenList& getLiteralList( );

from the export table I am getting:

std::list<class std::basic_string<unsigned short, std::char_traits<unsigned short>,class
 std::allocator<unsigned short> >,class std::allocator<class std::basic_string<unsigned 
short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > > > 
const & __thiscall CExpressionTokenizer::getLiteralList(void)

How do I get the backtrack from the above lengthy allocators to its original source code? (typedefs increase more in size.)

Regards,

Usman


I think you mean that you want to be able to determine a more succinct type name from the export table. The standard allocator (std::allocator) is the default template parameter for allocator parameter in most standard container class templates so you can just remove the entire allocator parameter from the template specialization to come up with a simpler expression of the same type.

E.g.

std::list<class std::basic_string<unsigned short, std::char_traits<unsigned short>,class
std::allocator<unsigned short> >,class std::allocator<class std::basic_string<unsigned 
short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > > > 
const & __thiscall CExpressionTokenizer::getLiteralList(void)

becomes

std::list<class std::basic_string<unsigned short, std::char_traits<unsigned short> > > 
const & __thiscall CExpressionTokenizer::getLiteralList(void)


I believe you are talking about decoding the error messages? Try STLFilt.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号