Igor’s Tip of the Week #153: Copying pseudocode to disassembly

When using the decompiler, you probably spend most of the time in the Pseudocode view. In case you need to consult the corresponding disassembly, it’s a quick Tab away. However, if you actually prefer the disassembly, there is another option you can try.

Copy to assembly

This action is available in the pseudocode view’s context menu when right-clicking outside of the decompiled code:

Because the decompiler uses disassembly comments for this feature, it warns you that the action will destroy any existing ones:

Copying pseudocode to disassembly listing will destroy
existing anterior and posterior comments.
Do you want to continue?

After confirmation, comments with pseudocode lines are added to the disassembly:

You can see these comments even in the graph view:

In fact, you can make use of this feature even without switching to pseudocode. While in disassembly, use Edit > Comments > Copy pseudocode to disassembly, or the shortcut /

 

Note that unlike pseudocode itself, these comments are static and do not change when you make changes in the pseudocode (e.g. rename variables). To update the comments, you need to trigger the action again.

In case you changed your mind and want to clean up the function, use “Delete pseudocode comments” from the same menu.

 

See also:

Hex-Rays interactive operation: Copy to assembly

Igor’s tip of the week #14: Comments in IDA