3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: Stack checker
6 * FILE: lib/ntdll/rtl/i386/chkstk.s
7 * PROGRAMER: KJK::Hyperion <noog@libero.it>
13 #define PAGE_SIZE 4096
17 PUBLIC __alloca_probe_16
20 /* 16 byte aligned alloca probe
21 * EAX = size to be allocated */
23 /* save the ECX register */
26 /* ecx = top of the previous stack frame */
29 /* Calculate end of allocation */
32 /* Get the misalignment */
35 /* Add the misalignment to the original alloc size */
38 /* Check for overflow */
41 /* Set maximum value */
42 mov eax, HEX(0ffffffff)
46 /* Fall through to __chkstk */
49 _chkstk() is called by all stack allocations of more than 4 KB. It grows the
50 stack in areas of 4 KB each, trying to access each area. This ensures that the
51 guard page for the stack is hit, and the stack growing triggered
56 /* EAX = size to be allocated */
57 /* save the ECX register */
60 /* ECX = top of the previous stack frame */
63 /* probe the desired memory, page by page */
69 /* raise the top of the stack by a page and probe */
73 /* loop if still more than a page must be probed */
80 /* raise the top of the stack by EAX bytes (size % 4096) and probe */
84 /* EAX = top of the stack */
87 /* allocate the memory */
93 /* restore the return address */