EvanED
EvanED

Reputation: 957

"Improper operand type" with MSVC __asm

I'm doing some random experimentation and want to print out the address the program is at at a given point. I tried doing the following, but it doesn't work:

void foo() {
    DWORD blah;
    __asm {
        mov blah, eip
    }
    std::cout << blah << "\n";
}

and instead gives "improper operand type" on the mov line.

I've tried several types for blah.

Anyone know what I'm doing wrong?

Upvotes: 0

Views: 772

Answers (1)

Jens Bj&#246;rnhager
Jens Bj&#246;rnhager

Reputation: 5649

There is no mov instruction that can touch the eip register. You'll have to use some kind trick to get its value.

How to check the EIP value with assembly language?

Upvotes: 1

Related Questions