If I have C program called A with the following code:
int main()
{
int x=5;
int *pX=&x;
return 0;
}
pX
point to address of x
, Let's say is 0x123456
.
And I have another program called B:
int main()
{
int y=5;
return 0;
}
And let's say the address of y
is 0x123488
how does the mechanism (virtual memory) that prevent me to change the value of pX
to point on 0x123488
(address of y
) and to read/change the value of y
from program A if I know the address of y
work?
NOTE: Let's assume I debug both programs and I know the current address for each value.