Page 2 of 2

Re: How to protect the stack

Posted: Sat Jun 04, 2011 11:57 am
by bluemoon
Chandra wrote:All the access to the stack segments are made VIA the cpu, so if you could just trick the compiler to access the right segments, may be you'd have some luck.............
I can imagine if you have a local variable on stack, and pass its pointer to another function,
which the compiler may generate code like:

Code: Select all

struct FOO {
  int i;
};

int main() {
  FOO f;
  foo ( &f );
}

; int foo ( struct FOO* foo ) 
mov ebx, [esp+4]   ; ebx -> foo
mov eax, [ebx]       ; try to access foo->i
now, [ebx] uses DS which has base 0, but foo is on the stack and has a different base...