User Manual

(the manual describes the build 181105)

Hex-Rays interactive operation: Force new variable

Hotkey: Shift-F

Sometimes a stack slot is used for two completely different purposes during the lifetime of a function. While for unaliased part of the stack frame the decompiler can usually sort things out, it cannot do much for the aliased part of the stack frame. For the aliased part it will create just one variable even if the corresponding stack slot is used for multiple different purposes. It happens so because the decompiler cannot prove that the variable is used for a different purpose starting from a certain point.

The force new variable command is designed to solve exactly this problem.

This command allows the user to force the decompier to allocate a new variable starting from the current point. If the current expression is a local variable, all its subsequent occurrences will be replaced by a new variable up to the end of the function or to the next forced variable at the same stack slot. If the cursor does not point to a local variable, the decompiler will ask the user about the variable to replace.

In the current statement only the write accesses to the variable will be replaced. In the subsequent statements all occurrences of the variable will be replaced. We need this logic to handle the following situation:

        func(var, &var);
where only the second occurence of the variable should be replaced.

Please note that in the presence of loops in the control flow graph it is possible that even the occurrences before the current expression will be replaced by the new variable. If this is not desired, the user should force a new variable somewhere else.

The very first and the very last occurrences of a variable cannot be used to force a new variable because it is not useful.

The decompiler does not verify the validity of the new variable. A wrong variable allocation point may render the decompiler output incorrect.

Currently only aliasable stack variables can be forced.

A forced variable can be deleted by right clicking on it and selecting 'Delete forced variable'.

See also: interactive operation