数据结构
数据结构:
如:typedef struct _WNDCLASS{
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
} WNDCLASS, *PWNDCLASS;
这个数据结构用汇编来表示:
WNDCLASS struct
style DWORD ?
lpfnWndProc DWORD ?
cbClsExtra DWORD ?
WNDCLASS ends
使用数据结构在数据段中定义数据的方法如下:
.data?
stWndClass WNDCLASS <>
或者:
.data
stWndClass WNDCLASS <1,1,1>
这个就是定义了一个以WNDCLASS为结构的变量stWndClass ,第一种方法是未初始化的方法,第二种方法是定义的同时初始化了值。
在汇编中,数据结构的引用方法有好几种:
1,最直接的: mov eax, stWndClass.lpfnWndProc
假设stWndClass在内存中的地址是403000h,此指令会被编译成 mov eax,[403004h],因为LpfnWndProc是stWndClass中的第二个字段,第一个字段是dword,已经占用了4字节的空间。
2.使用指针:
mov esi,offset stWndClass
mov eax,[esi + WNDCLASS.lpfnWndProc]
注意第二句是[esi + WNDCLASS.lpfnWndProc]而不是[esi + stWndClass.lpfnWndProc].
3.用assume伪指令:
mov esi, offset stWndClass
assume esi:ptr WNDCLASS
mov eax,[esi].lpfnWndProc
assume esi:noting
如:typedef struct _WNDCLASS{
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
} WNDCLASS, *PWNDCLASS;
这个数据结构用汇编来表示:
WNDCLASS struct
style DWORD ?
lpfnWndProc DWORD ?
cbClsExtra DWORD ?
WNDCLASS ends
使用数据结构在数据段中定义数据的方法如下:
.data?
stWndClass WNDCLASS <>
或者:
.data
stWndClass WNDCLASS <1,1,1>
这个就是定义了一个以WNDCLASS为结构的变量stWndClass ,第一种方法是未初始化的方法,第二种方法是定义的同时初始化了值。
在汇编中,数据结构的引用方法有好几种:
1,最直接的: mov eax, stWndClass.lpfnWndProc
假设stWndClass在内存中的地址是403000h,此指令会被编译成 mov eax,[403004h],因为LpfnWndProc是stWndClass中的第二个字段,第一个字段是dword,已经占用了4字节的空间。
2.使用指针:
mov esi,offset stWndClass
mov eax,[esi + WNDCLASS.lpfnWndProc]
注意第二句是[esi + WNDCLASS.lpfnWndProc]而不是[esi + stWndClass.lpfnWndProc].
3.用assume伪指令:
mov esi, offset stWndClass
assume esi:ptr WNDCLASS
mov eax,[esi].lpfnWndProc
assume esi:noting