Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>esp</code> is as you say it is, the top of the stack.</p> <p><code>ebp</code> is usually set to <code>esp</code> at the start of the function. Function parameters and local variables are accessed by adding and subtracting, respectively, a constant offset from <code>ebp</code>. All x86 calling conventions define <code>ebp</code> as being preserved across function calls. <code>ebp</code> itself actually points to the previous frame's base pointer, which enables stack walking in a debugger and viewing other frames local variables to work. </p> <p>Most function prologs look something like:</p> <pre class="lang-none prettyprint-override"><code>push ebp ; Preserve current frame pointer mov ebp, esp ; Create new frame pointer pointing to current stack top sub esp, 20 ; allocate 20 bytes worth of locals on stack. </code></pre> <p>Then later in the function you may have code like (presuming both local variables are 4 bytes)</p> <pre class="lang-none prettyprint-override"><code>mov [ebp-4], eax ; Store eax in first local mov ebx, [ebp - 8] ; Load ebx from second local </code></pre> <p>FPO or <em>frame pointer omission</em> optimization which you can enable will actually eliminate this and use <code>ebp</code> as another register and access locals directly off of <code>esp</code>, but this makes debugging a bit more difficult since the debugger can no longer directly access the stack frames of earlier function calls.</p> <p>EDIT:</p> <p>For your updated question, the missing two entries in the stack are:</p> <pre class="lang-none prettyprint-override"><code>var_C = dword ptr -0Ch var_8 = dword ptr -8 var_4 = dword ptr -4 *savedFramePointer = dword ptr 0* *return address = dword ptr 4* hInstance = dword ptr 8h PrevInstance = dword ptr 0C hlpCmdLine = dword ptr 10h nShowCmd = dword ptr 14h </code></pre> <p>This is because the flow of the function call is:</p> <ul> <li>Push parameters (<code>hInstance</code>, etc.)</li> <li>Call function, which pushes return address</li> <li>Push <code>ebp</code></li> <li>Allocate space for locals</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload