简体   繁体   中英

How to store register values using assembly to C++ variables?

int my_var;
void __declspec(naked) stuff()
{
    __asm
    {
        lea edx, [ecx + edi + 0x0000111]
    }
}

How to store the value from the address [ecx + edi + 0x0000111] in the c++ variable "my_var" above.

From the Microsoft docs :

An __asm block can refer to any symbols, including variable names, that are in scope where the block appears.

Therefore you could do this:

int my_var;
void __declspec(naked) stuff()
{
    __asm
    {
        lea edx, [ecx + edi + 0x0000111]
        mov my_var, edx
        ret

    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM