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.
Asked
Active
Viewed 1,658 times
1

Matthew Gaston
- 13
- 3
2 Answers
1
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();
}
}

Joseph Sible-Reinstate Monica
- 45,431
- 5
- 48
- 98
0
Ok this is going to be quite the breakdown
The expression is:
(func0(param_1 + 1), param_1 + 1 == 0x32)
Thus, call func0 with param_1 + 1
, throw away the result, and compare param_1 + 1
to 0x32
.
This code is unnatural; I would normally expect to find param_1 == 0x31
.
I'm guessing that this isn't a C binary and the decompiler can't express pass by value return, which is what ancient basic used. The documentation says it's pass by reference, but it is not. I found out the hard way by passing a global to a function that mutated the global.

Joshua
- 40,822
- 8
- 72
- 132