I'd like to get the inferred value of a register at a particular point in the disassembly listing in a Ghidra script.
In my case the target instruction is a rdmsr
or wrmsr
instruction, which reads or writes the MSR at ecx
. While I could walk back through the previous instructions and look for a simple mov ecx, const
pattern, there are significantly more ways to set ecx
to some known value that the decompiler is capable of inferring.
I've tried calling getRegisterValue
on the rdmsr
instruction, passing in a Register
type describing ecx
, but this just returns None
. Is there a way to infer register values at a particular instruction?
Here's the disassembly:
And the decompiled result:
Here's the P-Code:
None
for a case where it should be obvious, but adding an image would make this clearer.getRegisterValue
method are you talking about specifically? IDE tells me there are 11 methods with that name, with varying signatures on different classes, none of them available by default in the Jython context (which I assume you are using because you sayNone
instead ofnull
)Instruction
one and theProgramContext
one.