So I was reading the manual on how to create structures..
At first, I did:
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
So I thought well since its a local variable, I need to sub esp, sizeof(Point)
and I did and it still crashed..
and so I did it within the Point structure and instead of crashing, it now gets deleted:
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
However, not only does the above fail, it also triggers this:
From within Malware Defender for Windows 8.1
I do not understand why :S But it only happens when I use the sub esp
within the struct. If I use the .X dw X
it just crashes but does not trigger malware defender.
Any ideas how I can achieve passing a point to a function? Or creating a local point and passing it to a function as well as accessing its fields?