[align=center][size=large][b]C++ 代码修改(struct)[/b][/size][/align]
代码:
a3= 0012FF5C
*(_DWORD *)(a2 + 4)= 12450 (0x0012FF50)
a3->location = 0012FF50
*(_DWORD *)a2= 1244996 (0x0012FF44)
a3->cnode_addr = 0012FF44
*(a3->cnode_addr)= 6
*(a3->location)= 5
这个结构体里的变量是指针变量:*(_DWORD *)(a2 + 4)代表a3->location的地址,其中a3->location =(int*)v14;表示把v14的地址赋给a3->location,这是a3->location 地址所指向的值等于v14的值,这里是间接的赋值给*location。
a2 代表struct的首地址,struct内的变量也是指针,这样就构成双重指针
代码:
#include<iostream>
using namespace std;
struct InsertInfo
{
int *cnode_addr;
int *location;
};
typedef int _DWORD;
int main(void)
{
InsertInfo v119_insInfo; // [sp+58h] [bp-40h]@38
int a = 5,b = 6;
int v14,v15;
v14 = (int)&a;
v15 = (int)&b;
int a2 = (int)&v119_insInfo;
InsertInfo *a3 ;
a3 = &v119_insInfo;
*(_DWORD *)(a2 + 4) = v14;
a3->location =(int*)v14;
*(_DWORD *)a2 = (int)v15;
a3->cnode_addr = (int*)v15;
cout << "a3= " << a3 << endl;
cout << "*(_DWORD *)(a2 + 4)= " << *(_DWORD *)(a2 + 4) << endl;
cout << "a3->location = " << a3->location << endl;
cout << "*(_DWORD *)a2= " << *(_DWORD *)a2 << endl;
cout << "a3->cnode_addr = " << a3->cnode_addr << endl;
cout << "*(a3->cnode_addr)= " << *(a3->cnode_addr) << endl;
cout << "*(a3->location)= " << *(a3->location) << endl;
return 0;
}
a3= 0012FF5C
*(_DWORD *)(a2 + 4)= 12450 (0x0012FF50)
a3->location = 0012FF50
*(_DWORD *)a2= 1244996 (0x0012FF44)
a3->cnode_addr = 0012FF44
*(a3->cnode_addr)= 6
*(a3->location)= 5
这个结构体里的变量是指针变量:*(_DWORD *)(a2 + 4)代表a3->location的地址,其中a3->location =(int*)v14;表示把v14的地址赋给a3->location,这是a3->location 地址所指向的值等于v14的值,这里是间接的赋值给*location。
a2 代表struct的首地址,struct内的变量也是指针,这样就构成双重指针