2 * PROJECT: MSVC runtime check support library
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * PURPOSE: Provides support functions for MSVC runtime checks
5 * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
13 const char *fmt
, ...);
33 DbgPrint("Invalid stack pointer value caught at %p, error %d\n", retaddr
, errnum
);
42 DbgPrint("Use of uninitialized variable %s!\n", _Varname
);
52 int i
, *guard1
, *guard2
;
54 /* Loop all variables in the descriptor */
55 for (i
= 0; i
< _Fd
->varCount
; i
++)
57 /* Get the 2 guards below and above the variable */
58 guard1
= (int*)((char*)_Esp
+ _Fd
->variables
[i
].addr
- sizeof(*guard1
));
59 guard2
= (int*)((char*)_Esp
+ _Fd
->variables
[i
].addr
+_Fd
->variables
[i
].size
);
61 /* Check if they contain the guard bytes */
62 if ((*guard1
!= 0xCCCCCCCC) || (*guard2
!= 0xCCCCCCCC))
64 DbgPrint("Stack corruption near '%s'\n", _Fd
->variables
[i
].name
);
75 _RTC_ALLOCA_NODE
*_AllocaList
)
77 _RTC_ALLOCA_NODE
*current
;
80 /* Process normal variables */
81 _RTC_CheckStackVars(_Esp
, _Fd
);
83 /* Process the alloca list */
84 for (current
= _AllocaList
; current
!= 0; current
= current
->next
)
86 /* Get the upper guard */
87 guard
= (int*)((char*)current
+ current
->allocaSize
- sizeof(*guard
));
89 /* Check if all guard locations are still ok */
90 if ((current
->guard1
!= 0xCCCCCCCC) ||
91 (current
->guard2
[0] != 0xCCCCCCCC) ||
92 (current
->guard2
[1] != 0xCCCCCCCC) ||
93 (current
->guard2
[2] != 0xCCCCCCCC) ||
94 (*guard
!= 0xCCCCCCCC))
104 _RTC_ALLOCA_NODE
*_PAllocaBase
,
106 _RTC_ALLOCA_NODE
**_PAllocaInfoList
)
110 /* Check if we got any allocation */
111 if ((_PAllocaBase
!= 0) &&
113 (_PAllocaInfoList
!= 0))
115 /* Mark the whole range */
116 char *guard
= (char*)_PAllocaBase
;
117 for (i
= 0; i
< _CbSize
; i
++)
122 /* Initialize the alloca base frame */
123 _PAllocaBase
->allocaSize
= _CbSize
;
125 /* Insert this frame into the alloca list */
126 _PAllocaBase
->next
= *_PAllocaInfoList
;
127 *_PAllocaInfoList
= _PAllocaBase
;