2

I have a program which decompiles in Ghidra to include the line

temp_5f2f2f81bc = *(CPedIntelligence **)(&DAT_000010c0 + (longlong)pCVar2);

temp_5f2f2f81bc is a CPedIntelligence*. pCVar2 is a CPed*, and CPed has a CPedIntelligence* located at offset 0x10c0. So this should decompile as temp_5f2f2f81bc = pCVar2->intelligence;. Is there a way to tell Ghidra "no, pCVar2 should not be cast to longlong?"

I've noticed this occurring other times as well, and it generally seems to be associated with a structure stored in a register (here, pCVar2 is stored in R13). In the function's local variables, though, pCVar2 is listed as being stored in HASH:5f32eb8... The register is never used in the function except as the storage for this CPed*, so if I could forcibly tell the decompiler "this register has this type throughout the entire function" then that'd help. I tried using scripting to create a local variable stored in R13, but the decompiler didn't pick up on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.