ReactOS  0.4.14-dev-376-gaedba84
stack.c
Go to the documentation of this file.
1 #include <precomp.h>
2 
3 /*********************************************************************
4 * _chkesp (MSVCRT.@)
5 *
6 * Trap to a debugger if the value of the stack pointer has changed.
7 *
8 * PARAMS
9 * None.
10 *
11 * RETURNS
12 * Does not return.
13 *
14 * NOTES
15 * This function is available for iX86 only.
16 *
17 * When VC++ generates debug code, it stores the value of the stack pointer
18 * before calling any external function, and checks the value following
19 * the call. It then calls this function, which will trap if the values are
20 * not the same. Usually this means that the prototype used to call
21 * the function is incorrect. It can also mean that the .spec entry has
22 * the wrong calling convention or parameters.
23 */
24 
25 #ifdef __i386__
26 
27 void _chkesp_failed(void)
28 {
29  ERR("stack got corrupted!\n");
30  __debugbreak();
31 }
32 
33 #endif /* __i386__ */
34 
35 /*********************************************************************
36  * _resetstkoflw (MSVCRT.@)
37  */
39 {
40  int stack_addr;
41  DWORD oldprot;
42 
43  /* causes stack fault that updates NtCurrentTeb()->Tib.StackLimit */
44  return VirtualProtect(&stack_addr, 1, PAGE_GUARD|PAGE_READWRITE, &oldprot);
45 }
#define PAGE_GUARD
Definition: nt_native.h:1310
int CDECL _resetstkoflw(void)
Definition: stack.c:38
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:144
#define ERR(fmt,...)
Definition: debug.h:109
#define CDECL
Definition: compat.h:21
#define PAGE_READWRITE
Definition: nt_native.h:1304