Ignore:
Timestamp:
Feb 10, 2003, 5:05:39 PM (23 years ago)
Author:
sandervl
Message:

Touch all stack pages we skip in the out of stack workaround for 16 bits code. Jumping over the guard page causes a protection violation exception

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/exceptutil.asm

    r9754 r9780  
    1 ; $Id: exceptutil.asm,v 1.22 2003-02-05 14:04:33 sandervl Exp $
     1; $Id: exceptutil.asm,v 1.23 2003-02-10 16:05:39 sandervl Exp $
    22
    33;/*
     
    161161
    162162;We're asking for problems if our stack start near a 64kb boundary
    163 ;Some OS/2 thunking procedures can choke on misaligned stack addresses
     163;Some OS/2 thunking procedures can choke if there's not enough stack left
    164164        mov     eax, esp
    165165        and     eax, 0FFFFh
     
    167167        jge     @goodthreadstack
    168168
    169         ;set ESP to the top of the next 64kb block
    170         add     eax, 16
    171         sub     esp, eax
     169        ;set ESP to the top of the next 64kb block and touch each
     170        ;page to make sure the guard page exception handler commits
     171        ;those pages
     172        mov     edx, esp
     173        sub     edx, eax
     174
     175        and     esp, 0FFFFF000h
     176        dec     esp
     177
     178@touchthreadstackpages:
     179        mov     al, byte ptr [esp]
     180
     181        sub     esp, 1000h
     182
     183        cmp     esp, edx
     184        jg      @touchthreadstackpages
     185
     186        mov     esp, edx
     187        sub     esp, 16
     188
    172189@goodthreadstack:
    173190
     
    187204
    188205;We're asking for problems if our stack start near a 64kb boundary
    189 ;Some OS/2 thunking procedures can choke on misaligned stack addresses
     206;Some OS/2 thunking procedures can choke if there's not enough stack left
    190207        mov     eax, esp
    191208        and     eax, 0FFFFh
    192209        cmp     eax, 0E000h
    193         jge     @goodstack
    194 
    195         add     eax, 1000h
    196         sub     esp, eax
    197 @goodstack:
     210        jge     @goodmainstack
     211
     212        ;set ESP to the top of the next 64kb block and touch each
     213        ;page to make sure the guard page exception handler commits
     214        ;those pages
     215        mov     edx, esp
     216        sub     edx, eax
     217
     218        and     esp, 0FFFFF000h
     219        dec     esp
     220
     221@touchmainstackpages:
     222        mov     al, byte ptr [esp]
     223
     224        sub     esp, 1000h
     225
     226        cmp     esp, edx
     227        jg      @touchmainstackpages
     228
     229        mov     esp, edx
     230        sub     esp, 16
     231
     232@goodmainstack:
    198233
    199234        mov     eax, esp
Note: See TracChangeset for help on using the changeset viewer.