4

How to add STL to Local Types in Ida Pro?

I can import debug information from a pdb file along with STL types, but I can't manually add STL types to Local Types.

Also I can't import STL when I click "Parse C header file"

enter image description here

it's all the fault of the symbols <> but, after all, import from PDB - successfully passes?

0xC0000022L
  • 10,908
  • 9
  • 41
  • 79

1 Answers1

6

To parse templates you need to use the IDAClang plugin that comes with Ida Pro (I think it's not available with IDA Free).

To add a single class/structure definition you can use IDAPython:

import ida_srclang

code = """ template <typename T, typename U> struct S;

template<> struct S<int, void > { int x; void y; }; """

ida_srclang.set_parser_argv("clang", "-x c++") ida_srclang.parse_decls_with_parser("clang", None, code, False)

If you want to parse whole header files, you need to:

  • Set clang as your parser in Options > Compiler > Source parser
  • Ensure you set the correct include directories
  • Ensure you added the -x c++ argument

You should then be able to parse whole files with Load file > Parse C header file

Sadly you cannot later edit such structures because the Edit dialog in Local Types will not be able to parse them correctly. If you want to modify such a structure, you will need to re-parse it with clang using one of the two ways above.

See the IDAClang tutorial on Hex-Rays website for more information.

overflo
  • 268
  • 1
  • 6