Type libraries are collections of high-level type information for selected platforms and compilers which can be used by IDA and the decompiler.
A type library may contain:
void *__cdecl memcpy(void *, const void *Src, size_t Size); BOOL __stdcall EnumWindows(WNDENUMPROC lpEnumFunc, LPARAM lParam);
typedef unsigned long DWORD; BOOL (__stdcall *WNDENUMPROC)(HWND, LPARAM);
struct tagPOINT { LONG x; LONG y; }; enum tagSCRIPTGCTYPE { SCRIPTGCTYPE_NORMAL = 0x0, SCRIPTGCTYPE_EXHAUSTIVE = 0x1, };
enum MACRO_WM { WM_NULL = 0x0, WM_CREATE = 0x1, WM_DESTROY = 0x2, WM_MOVE = 0x3, WM_SIZEWAIT = 0x4, WM_SIZE = 0x5, WM_ACTIVATE = 0x6, WM_SETFOCUS = 0x7, WM_KILLFOCUS = 0x8, WM_SETVISIBLE = 0x9, [...] };
The list of currently loaded type libraries is available in the Type Libraries view (View > Open subiews > Type Libraries, or Shift–F11).
Additional libraries can be loaded using “Load type library…” context menu item or the Ins hotkey.
Once loaded, definitions from the type library can be used in IDA and the decompiler: you can use them in function prototypes and global variable types (Y hotkey), as well as when adding new definitions in Local Types.
While the decompiler can use types from loaded type libraries without extra work, to use them in the disassembly some additional action may be necessary. For example, to use a standard structure or enum, it has to be added to the list in the corresponding view first:
After importing, the structure or enum can be used in the disassembly view.
When a type library is loaded, functions with name matching the prototypes present in the library will have their prototypes applied in the database. Alternatively, you can rename functions after loading the library, like we described last week.