Search code examples
c++visual-studioassemblyx86reverse-engineering

Get value of all FPU registers, even "empty" ones


I am writing an extension for a software and certain important values are in the FPU registers. Some of those registers are marked as empty, but they still contain important values. Because those registers are marked as empty, everytime I try to use something like fxch in order to get the value in, let's say, st(6) to st(0), so I can store it in memory, it automatically gets changed to NaN.

Is there any way to change the status from empty to valid or to read those registers in any way? I know debuggers can see them, but I need to do it programatically with either C++ or x86 ASM.

Edit: As some of you might know, there is a TAG register marking some FPU registers as "empty". This happens for example, when FINNIT is called, however the actual value bits are not changed by that, it's basically just telling the system, that those spots in the FPU stacks are now free. I want to read those values from the FPU stack, but because they are marked as "empty" or you could say "invalid" it doesn't work with the normal instructions. I realize, that it's not a common use-case, but I need those registers because of reverse engineering.

To be specific: how can I print all FPU registers on Windows, 32 bit, even if they are marked as "empty"?


Solution

  • Like Michael Petch suggested I was able to save all registers using FSAVE. Then I only had to access the memory, where I saved the registers and convert them from the extended precision representation to a normal 32bit float.