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?

1 Answer 1

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.

1
  • 3
    IDA 6.8 was released in 2015. I guess it is time to update your license... Mar 31, 2023 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.