Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.6 KiB

  1. /***
  2. *stack.cpp - RTC support
  3. *
  4. * Copyright (c) 1998-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *
  7. *Revision History:
  8. * 07-28-98 JWM Module incorporated into CRTs (from KFrei)
  9. * 05-11-99 KBF Error if RTC support define not enabled
  10. *
  11. ****/
  12. #ifndef _RTC
  13. #error RunTime Check support not enabled!
  14. #endif
  15. #include "rtcpriv.h"
  16. /* Stack Checking Calls */
  17. void
  18. #ifndef _M_ALPHA // AXPMOD - No declspec(naked) for us.
  19. __declspec(naked)
  20. #endif
  21. _RTC_CheckEsp()
  22. {
  23. #ifndef _M_ALPHA // AXPMOD - Disable this until we can get the
  24. // assembly written for it.
  25. __asm
  26. {
  27. jne esperror ;
  28. ret
  29. esperror:
  30. ; function prolog
  31. push ebp
  32. mov ebp, esp
  33. sub esp, __LOCAL_SIZE
  34. push eax ; save the old return value
  35. push edx
  36. push ebx
  37. push esi
  38. push edi
  39. }
  40. _RTC_Failure(_ReturnAddress(), _RTC_CHKSTK);
  41. __asm
  42. {
  43. ; function epilog
  44. pop edi
  45. pop esi
  46. pop ebx
  47. pop edx ; restore the old return value
  48. pop eax
  49. mov esp, ebp
  50. pop ebp
  51. ret
  52. }
  53. #endif
  54. }
  55. void __fastcall
  56. _RTC_CheckStackVars(void *frame, _RTC_framedesc *v)
  57. {
  58. int i;
  59. for (i = 0; i < v->varCount; i++)
  60. {
  61. int *head = (int *)(((char *)frame) + v->variables[i].addr + v->variables[i].size);
  62. int *tail = (int *)(((char *)frame) + v->variables[i].addr - sizeof(int));
  63. if (*tail != 0xcccccccc || *head != 0xcccccccc)
  64. _RTC_StackFailure(_ReturnAddress(), v->variables[i].name);
  65. }
  66. }