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:




Nonefor a case where it should be obvious, but adding an image would make this clearer. – Florian Magin Dec 01 '20 at 12:34getRegisterValuemethod 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 sayNoneinstead ofnull) – Florian Magin Dec 01 '20 at 12:44Instructionone and theProgramContextone. – Polynomial Dec 01 '20 at 16:15