Leaked source code of windows server 2003
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.

76 lines
1.5 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. * 07-15-01 PML Remove all ALPHA, MIPS, and PPC code
  11. *
  12. ****/
  13. #ifndef _RTC
  14. #error RunTime Check support not enabled!
  15. #endif
  16. #include "rtcpriv.h"
  17. /* Stack Checking Calls */
  18. void
  19. __declspec(naked)
  20. _RTC_CheckEsp()
  21. {
  22. __asm
  23. {
  24. jne esperror ;
  25. ret
  26. esperror:
  27. ; function prolog
  28. push ebp
  29. mov ebp, esp
  30. sub esp, __LOCAL_SIZE
  31. push eax ; save the old return value
  32. push edx
  33. push ebx
  34. push esi
  35. push edi
  36. }
  37. _RTC_Failure(_ReturnAddress(), _RTC_CHKSTK);
  38. __asm
  39. {
  40. ; function epilog
  41. pop edi
  42. pop esi
  43. pop ebx
  44. pop edx ; restore the old return value
  45. pop eax
  46. mov esp, ebp
  47. pop ebp
  48. ret
  49. }
  50. }
  51. void __fastcall
  52. _RTC_CheckStackVars(void *frame, _RTC_framedesc *v)
  53. {
  54. int i;
  55. for (i = 0; i < v->varCount; i++)
  56. {
  57. int *head = (int *)(((char *)frame) + v->variables[i].addr + v->variables[i].size);
  58. int *tail = (int *)(((char *)frame) + v->variables[i].addr - sizeof(int));
  59. if (*tail != 0xcccccccc || *head != 0xcccccccc)
  60. _RTC_StackFailure(_ReturnAddress(), v->variables[i].name);
  61. }
  62. }