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.

45 lines
2.0 KiB

  1. /***
  2. *seccook.c - defines buffer overrun security cookie
  3. *
  4. * Copyright (c) 2000-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Defines per-module global variable __security_cookie, which is used
  8. * by the /GS compile switch to detect local buffer variable overrun
  9. * bugs/attacks.
  10. *
  11. * When compiling /GS, the compiler injects code to detect when a local
  12. * array variable has been overwritten, potentially overwriting the
  13. * return address (on machines like x86 where the return address is on
  14. * the stack). A local variable is allocated directly before the return
  15. * address and initialized on entering the function. When exiting the
  16. * function, the compiler inserts code to verify that the local variable
  17. * has not been modified. If it has, then an error reporting routine
  18. * is called.
  19. *
  20. * NOTE: The ATLMINCRT library includes a version of this file. If any
  21. * changes are made here, they should be duplicated in the ATL version.
  22. *
  23. *Revision History:
  24. * 01-24-00 PML Created.
  25. * 08-09-00 PML Preserve EAX on non-failure case (VS7#147203). Also
  26. * make sure failure case never returns.
  27. * 08-29-00 PML Rename handlers, add extra parameters. Move most of
  28. * system CRT version over to seclocf.c.
  29. * 09-16-00 PML Initialize global cookie earlier, and give it a nonzero
  30. * static initialization (vs7#162619).
  31. * 03-07-02 PML Split into seccook.c and secchk.c.
  32. *
  33. *******************************************************************************/
  34. #include <internal.h>
  35. #include <windows.h>
  36. /*
  37. * The global security cookie. This name is known to the compiler.
  38. * Initialize to a garbage non-zero value just in case we have a buffer overrun
  39. * in any code that gets run before __security_init_cookie() has a chance to
  40. * initialize the cookie to the final value.
  41. */
  42. DECLSPEC_SELECTANY DWORD_PTR __security_cookie = DEFAULT_SECURITY_COOKIE;