Currently you can “Copy to assembly” in the Pseudocode window, but there is no option to do the opposite for user created comments.
Usecase:
- Open foobar program version 1.0.0 in IDA.
- Goto “loadoptions” function.
- Add comments in the IDA-View window.
- Decompile.
- “Copy assembly comments to pseudeocode” to document the Pseudocode window.
- Push the functions metadata to Lumina (or Lumen).
- Save the IDB and close the version 1.0.0 file.
- Open foobar program version 1.0.1 in IDA.
- Pull metadata from Lumina (or Lumen).
- Goto “loadoptions” function.
- Decompile.
- “Copy assembly comments to pseudeocode”
- See comments in Pseudocode code window you made for version 1.0.0
This can save a lot of time if you want to document the Pseudocode output for multiple versions of a program.
IDA View - Text Mode with comments added by me:
.text:00498FB7 loadoptions proc near ; CODE XREF: loadini+C58↓p
.text:00498FB7 push ebx
.text:00498FB8 push esi
.text:00498FB9 push edi
.text:00498FBA push ebp
// snip...
.text:00499006 call nextval
.text:0049900B mov dword_557890, eax ; 01 - Example 1
.text:00499010 push 0
.text:00499012 call nextval
.text:00499017 mov dword_557904, eax ; 02 - Foobar
.text:0049901C push 0
.text:0049901E call nextval
.text:00499023 mov dword_5578F8, eax ; 03
.text:00499028 push 0
.text:0049902A call nextval
.text:0049902F mov dword_551F68, eax ; 04
.text:00499034 push 0
.text:00499036 call nextval
.text:0049903B mov dword_551D40, eax ; 05
.text:00499040 push 0
.text:00499042 call nextval
.text:00499047 mov dword_557248, eax ; 06
.text:0049904C push 12Ch
.text:00499051 call nextval
.text:00499056 mov dword_54F8BC, eax ; 07
.text:0049905B push 0
.text:0049905D call nextval
.text:00499062 mov dword_557914, eax ; 08
...
Suggested Pseudocode output for “Copy assembly comments to pseudocode”:
int loadoptions()
{
bool v0; // edi
int result; // eax
GetPrivateProfileStringA("options", "n0", byte_553647, byte_579826, 0x3E7u, (LPCSTR)"foobar.ini");
dword_553524 = (int)byte_579826;
v0 = byte_579826[0] == 0;
dword_557890 = nextval(0); // 01 - Example 1
dword_557904 = nextval(0); // 02 - Foobar
dword_5578F8 = nextval(0); // 03
dword_551F68 = nextval(0); // 04
dword_551D40 = nextval(0); // 05
dword_557248 = nextval(0); // 06
dword_54F8BC = nextval(300); // 07
dword_557914 = nextval(0); // 08
...
INI file format for reference:
[options]
n0=0,0,0,0,0,0,300,0