wargio / r2dec-js

radare2 plugin - converts asm to pseudo-C code.
514 stars 50 forks source link

if with Array instead of ifgoto #180

Open Maijin opened 5 years ago

Maijin commented 5 years ago

In some binary there is a huge list of if/goto which should be replaced by a if on array elements e.g:

ch15.exe.zip pddi.txt

Current Behavior

    if (arg_ch == 7) {
        eax = arg_8h;
        eax = *(eax);
        if (al != 0x53) {
            goto label_0;
        }
        eax = arg_8h;
        eax++;
        eax = *(eax);
        if (al != 0x50) {
            goto label_0;
        }
...

Expected Behavior

if ( arg_ch == 7 && *a1 == 0x53 && a1[1] == 0x50 && a1[2] == 0x61 && a1[3] == 0x43 && a1[4] == 0x49 && a1[5] == 0x6f && a1[6] == 0x53 )