Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C code Ghidra decompile results in syntax I am unfamiliar with

I am working on reversing a simple binary using Ghidra. The decompile results in this line of code

if ((param_1 != 4) && (func0(param_1 + 1), param_1 + 1 == 0x32))
The param_1+1==0x32 section is confusing me as I’m just not familiar with the syntax and am not sure what it is doing inside a boolean expression.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

That’s the comma operator. In this case, it’s just unnecessarily confusing, as an alternative decompilation could have avoided it, e.g., these are equivalent:

if ((param_1 != 4) && (func0(param_1 + 1), param_1 + 1 == 0x32)) {
    doStuff();
}
if (param_1 != 4) {
    func0(param_1 + 1);
    if(param_1 + 1 == 0x32) {
        doStuff();
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use