【发布时间】:2014-03-18 12:19:53
【问题描述】:
所以我正在阅读有关如何创建结构的手册..
一开始是这样的:
struc point X, Y
{
.X dw X
.Y dw Y
}
section '.code' code readable executable
main:
push ebp
mov ebp,esp
PP Point 0, 0 ;Crashes here..
mov esp, ebp
pop ebp
mov eax, 0x0
ret
所以我想得很好,因为它是一个局部变量,我需要 sub esp, sizeof(Point) 并且我做到了,但它仍然崩溃了..
所以我在 Point 结构中完成了它,而不是崩溃,它现在被删除了:
section '.data' data readable writeable
Response db 13, 10, "Value: %d", 13, 10, 0
struc Point X, Y
{
sub esp, 0x8
mov dword[esp + 0x00], X
mov dword[esp + 0x04], Y
}
section '.code' code readable executable
main:
push ebp
mov ebp,esp
PP Point 0, 0 ;create a point
push PP
call Point_Valid
add esp, 0x04
mov esp, ebp
pop ebx
call [getchar]
mov eax, 0x00
ret
Point_Valid:
push ebp
mov ebp, esp
mov eax, [ebp + 0x8]
push eax ;Not sure how to get Point from eax or Point.X..
push Response
call [printf]
add esp, 0x08
mov esp, ebp
pop ebp
ret
但是,上面不仅失败了,还触发了这个:
从 Malware Defender for Windows 8.1 中
我不明白为什么 :S 但只有当我在结构中使用 sub esp 时才会发生这种情况。如果我使用.X dw X,它只会崩溃但不会触发恶意软件防御者。
任何想法如何实现将点传递给函数?还是创建一个本地点并将其传递给函数并访问其字段?
【问题讨论】:
标签: assembly structure local-variables fasm