Use true and false constants for booleans and nullptr constant for null pointers in decompiler

In Hex-Rays decompiler, you can have bool and pointer arguments in a C/C++ function. However, for bool function parameters, the decompiler shows them as 1 and 0 integer constants which may confuse since in the place of, say, 0 can be either a null pointer, a zero integer, or a false boolean value. I request adding true, false and nullptr (or at least NULL) constants for bool and pointer variables and function parameters in Hex-Rays decompiler to avoid ambiguity.

2 Likes

Just to make sure I get this right .. are you asking for a function prototype like this:

BOOL CreateProcessW(LPCWSTR lpApp, LPWSTR lpCmd, LPSECURITY_ATTRIBUTES lpProcAttr,
                    LPSECURITY_ATTRIBUTES lpThreadAttr, BOOL bInheritHandles,
                    DWORD dwFlags, LPVOID lpEnv, LPCWSTR lpCurDir,
                    LPSTARTUPINFOW lpSI, LPPROCESS_INFORMATION lpPI);

currently being rendered like this in the decompiler:

CreateProcessW(L"cmd.exe", 0, 0, 0, 0, 0, 0, 0, &si, &pi);

?

If you don’t have any types available, it’s impossible for the decompiler to establish whether any passed data is null pointer, 0 value or false value, they technically all kind of look the same at the machine code level.

What would be interesting to see if it behaves any different if you look at an invocation of a function with similarly diverse arguments with symbols available (i.e. compile a C file with types and similar function signature). Pretty sure it’ll behave the same though..

Thanks, I like the idea. We will implement it.

As about other enum constants, the decompiler already uses them if the function prototype uses enum types. Unfortunately, this is not the case for CreateProcessW and similar WINAPI functions.

2 Likes