For the complete documentation index, see llms.txt. This page is also available as Markdown.

TILIB

TILIB is a utility to create custom type libraries for IDA Pro. Since IDA 9.1, TILIB is shipped with IDA, in the tools folder within the main IDA installation directory.

This small utility creates type library (til) files for IDA Pro. Its functionality overlaps with "Parse C header file...". However, TILIB can also preserve preprocessor macro definitions in type libraries and convert selected numeric macros into enums. IDA’s "Parse C header file..." command processes macros while parsing declarations, but does not import those macros as named constants.

The utility takes a C/C++/Obj-C header file and extracts all type information from it. The extracted type information is stored in an internal format as a type library file. Type library files can be loaded and used in IDA Pro by opening the Type Library Window and pressing Insert.

Installation

Copy the tilib executable file into the IDA Pro directory.

TILIB uses the IDA Pro kernel library and needs nothing else from the installation. Copying the executable into the IDA Pro directory is the simplest way to let it find the library; if you prefer to keep it elsewhere, make the library reachable through the usual library search path of your system.

Usage

If started without parameters, the utility displays a short explanation. Below are some command line samples.

Parse a header file and create a new type library:

tilib -c -hinput_header_file output_til_file
  • -c means to create a new type library

  • -h denotes the name of the input file to read

If you need to parse multiple files into one type library, you may create a text file with #include directives and specify it as the input.

TILIB can handle input files for Visual Studio, Borland, GCC out of the box. Please check the configuration files for them in the archive (*.cfg).

If you need to fine-tune TILIB for another compiler (or unusual compiler settings), feel free to copy the provided configuration files and modify them.

TILIB is not very good at error handling and some error messages may be quite unhelpful (e.g. syntax error). To alleviate this problem, use the -z switch. If this switch is specified, TILIB creates a .i file with the preprocessed contents. All recognized type names are prepended with @, like this: @my_type_name.

In some urgent cases, the -e switch may be used to ignore any parsing errors. Please note that the problematic type definitions will be skipped in this mode. This switch may be used together with the -R switch to allow type redeclarations.

If your input file uses another header file (e.g. windows.h), you may opt to use the vc6win.til file instead of parsing it again. For that, just use the -b switch and specify vc6win.til as the base til. TILIB loads the contents of the specified file into the memory and parses the input file. All definitions from windows.h, including the preprocessor definitions, are available:

TILIB can also be used to list the contents of a til file:

If the -c switch is not specified, TILIB uses the specified til file as the input and as the output file. This mode allows you to modify existing til files.

Building type libraries with TILIB

TILIB is a utility to create custom type libraries for IDA Pro. You can find it in the tools folder within the main IDA installation directory. For an overview just run tilib.

Basic examples

Important flags:

  • -TC - enables the clang parser

  • -P - enables C++ mode

  • -I - is used to specify include directories

  • -CT - is used to specify additional clang arguments, for example -std=c++20 for C++20 code

  • -v - you'll see CLANG command line: printed, which is the easiest way to debug your configuration

C++

Objective-C

Objective-C++

Complex type libraries

Qt

This example will be given using macOS and Qt 6.

To install Qt, one can use Homebrew:

For convenience, you can set some environment variables. These may vary based on your system and Qt installation.

Create an umbrella header (qt.h):

Create the type library:

Note that sometimes there may be inconsistencies between IDA's clang and the system's clang, which may cause parsing errors. For example, if Apple's clang header files use some features that are not supported by the LLVM clang, you may need to add some additional flags to the command line to work around the issue. You can use -v to see the exact command line used for parsing and debug the problem. However, if that doesn't work and the parser gets in your way, you can also pass -e in order to ignore potential parsing errors and get as much of the type information as possible. You'll likely still extract a good amount of useful information.

To verify what has been parsed into the type library, dump the information using tilib -lc qt_mac_arm64.til > qt_mac_arm64.txt.

XNU Kernel

If you're on a macOS system, this is pretty straightforward, since you can use the system's SDK and clang headers.

Create xnu.h and include your headers of interest:

You can check your OS version and the corresponding SDK version using sw_vers.

Creating the type library for Darwin Kernel headers of macOS 26.3:

macOS/iOS SDK

The same process can be applied to create type libraries for macOS or iOS SDKs. Just make sure to set the right target and include paths.

An umbrella header (macos_sdk.h) can be found here:

Open

.

Here's a recipe of how to generate the umbrella header on your system:

Generate the type library for macOS:

For iOS, change the SDK path and the target:

Example TILIB command:

Use -v (verbose) or -e (ignore errors) if you run into issues.

How to create preprocessor macro enums?

TILIB can also convert selected preprocessor macros into enums. If the input file has lines like the following:

they can be converted to enum and used in IDA Pro. This is a three step process. At the first step, you create a .mac file (note the -M switch):

The second step is to edit the generated .mac file: to remove undesired macro definitions and regroup macros if necessary. Macro group names start at the beginning of a line, symbol definitions are indented:

Feel free to edit the macro file to your taste.

It is also possible to describe the changes to the macro group names and rerun TILIB to regenerate the macro file. There are two ways to describe the changes:

  1. Through the -g[nb]X:Y command-line options. If the regex X matches the macro name (n) or the macro body (b), the group is set to Y. For example:

    with this header file:

    produces this macro file:

    An empty regex prevents the group from being created (useful when you want to leave a group name available from a base til).

  2. Adding a TILIB-specific #pragma to the header files:

  3. The third and last step is to specify the macro file as the input for TILIB:

The generated til file has all normal type definitions and all macro definitions from the .mac file.

List of supported keywords

Below is the list of supported keywords. If your header files happen to have an unsupported keyword, you can take one of the following actions:

  • edit the input files and remove the unsupported keywords

  • use #define to replace or hide the unsupported keywords

  • use the -D command line switch for the same purpose

What's next?

Learn more about TILIB utility and check Igor's tip of the week about creating custom libraries.

Last updated

Was this helpful?