I write this code in Visual Studio, but i don't know why it get access violation at mov [edx], al. Can anyone help me to explain it?
int main()
{
char z[10] = "banana";
_asm
{
lea ecx, z;
mov edx, [ecx];
inc edx;
mov [ecx], edx;
dec edx;
mov al, 31;
mov [edx], al;
mov eax, 31;
and eax, 0FFh
}
}
EDX
holds the first 4 bytes ofz
(mov edx, [ecx]
) not the address ofz
. If you "cast"EDX
to an address with square brackets you point to anywhere but surely not to correct memory. I can't show a working code because I don't know what you want do.Looking at your last post I guess you wanted to do something like this: