Mark function argument as not spoiled

Hello,

I have scenario when function A calls function B, and then A calls function C.

Assuming x64, when calling function B RCX is prepared, then B doesn’t spoil RCX so the compiler keep uses RCX in the call for function C. The decompiler is getting confused and not sure where the argument comes from.

Can I mark function B as “not spoiling RCX” in any way?

What you can do is use the __spoils<reg1,reg2,...> specifier and mention only the actually spoiled registers, without RCX. For more info: Igor’s tip of the week #51: Custom calling conventions – Hex Rays.

You can tell IDA/Hex-Rays that a function doesn’t spoil certain registers using the __spoils<…> specifier — just list only the registers that are spoiled and omit the ones you want preserved (like RCX).

Thank you very much :slight_smile: