Hi guys im doing some work with buffer overflows, and I've been scratching my head for a while with this one. I have little experience in C, I can read some source adn get a general idea of what each bit does, however i'm required to grab the current address that the stack pointer is looking at.<br>
<br>I've been given this bit of source:<br><br><br><br><br><br><pre>3. The Stack Pointer<br> =================<br><br><br>Every program has a stack pointer which is the address of the beginning of the stack. We can<br>
find the stack pointer for a system using the following code:<br><br><br>unsigned long sp(void)<br>{<br>        __asm__("movl %esp, %eax");<br>}<br><br>void main(void)<br>{<br>        printf("0x%x\n", sp());<br>}<br>
<br><br>The function sp() contains the assembly instruction movl which copies the value of the stack<br>pointer to the return buffer for the function, so it is returned to the main function and<br>displayed.<br><br>$ ./sp<br>
<br>0xbfbffbc8<br></pre><br clear="all">however after adding the correct headers, it still wont compile....<br><br><br>I understand the Assembly language instruction, ESP holds the address of where the stack pointer is currently pointing, movl esp eax moves it to the eax register, for returning. If anyone could help it would be great. its the last bit of work i need to do to finish my project.<br>
-- <br><br><br>Nick Walker<br>Vice President : The Linux Society<br>UAD Ethical Hacker<br>