When working on a binary, you often recover types used in it from many sources:
- creating structures manually, from data, or using decompiler;
- parsing header files;
- importing them from type libraries or debug information;
However, it may happen that eventually you discover duplicates. For example, you find out that the “custom” structure you’ve been building up is actually a well-known type and you found the correct definition in debug info or header files. Or, after analyzing two different functions, you only find out later that two structures are, in fact, one and the same. Of course, you can go and replace all references to the “wrong” one manually, which is doable if you discover this early, but if you already have hundreds of functions or other types referring to it, the process can become tedious.
To map a type to another, open the Local Types window (Shift–F1), and choose “Map to another type…” from the context menu on the type you want to map.
After choosing the type to replace it, the original type is deleted and all references to it are redirected to the new one. This is indicated by the arrow sign pointing to the new type’s definition.
All uses of the old type in the function prototypes, local variable types etc. are replaced by the new type automatically.
Article Link: Igor’s Tip of the Week #142: Mapping local types – Hex Rays