[英]Get variable address using inline assembly
I want a code to get the address of a variable using inline assembly with C++. 我想要一个代码来使用C ++内联汇编来获取变量的地址。
I'm doing this way, but it takes a value and not the address 我这样做,但它需要一个值,而不是地址
#include <stdio.h>
#include <windows.h>
int main()
{
int n = 5;
DWORD addr;
__asm mov ebx, n;
__asm mov addr, ebx;
printf("%x", addr);
return 0;
}
If you really need to do it via assembler, try 如果你真的需要通过汇编程序来做,试试吧
__asm lea ebx, n;
__asm mov addr, ebx;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.