Question

How to put the contents of a 32 bit CPU register in a byte array?

Was it helpful?

Solution

Basically you need to write inline assembly to read contents of some register. For example - to read ESP register into some int variable (Windows & Visual Studio) - you would do something like this:

int stackpointer = 0;
    __asm {
        mov stackpointer, esp
    }
    printf("stack pointer: %i\n", stackpointer);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top