How to protect the stack

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: How to protect the stack

Post 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...
Post Reply