ReactOS 0.4.16-dev-297-gc569aee
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
27void _chkesp_failed(void)
28{
29 ERR("stack got corrupted!\n");
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 ERR(fmt,...)
Definition: precomp.h:57
#define CDECL
Definition: compat.h:29
unsigned long DWORD
Definition: ntddk_ex.h:95
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define PAGE_GUARD
Definition: nt_native.h:1310
int CDECL _resetstkoflw(void)
Definition: stack.c:38
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:135