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.

147 lines
3.1 KiB

  1. /***
  2. *user.cxx - E.H. functions only called by the client programs
  3. *
  4. * Copyright (c) 1993-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Exception handling functions only called by the client programs,
  8. * not by the C/C++ runtime itself.
  9. *
  10. * Entry Points:
  11. * * set_terminate
  12. * * set_unexpected
  13. * * _set_seh_translator
  14. * * _set_inconsistency
  15. *
  16. *Revision History:
  17. * ??-??-93 BS Module created
  18. * 10-17-94 BWT Disable code for PPC.
  19. * 02-06-95 CFW Test only for debug build.
  20. * 02-09-95 JWM Mac merge.
  21. * 05-17-99 PML Remove all Macintosh support.
  22. *
  23. ****/
  24. #include <stddef.h>
  25. #include <windows.h>
  26. #include <mtdll.h>
  27. #include <ehassert.h>
  28. #include <eh.h>
  29. #include <ehhooks.h>
  30. #pragma hdrstop
  31. /////////////////////////////////////////////////////////////////////////////
  32. //
  33. // set_terminate - install a new terminate handler (ANSI Draft 17.1.2.1.3)
  34. //
  35. _CRTIMP terminate_function __cdecl
  36. set_terminate( terminate_function pNew )
  37. {
  38. terminate_function pOld = NULL;
  39. #if defined(_DEBUG)
  40. #pragma warning(disable:4191)
  41. if ( (pNew == NULL) || _ValidateExecute( (FARPROC) pNew ) )
  42. #pragma warning(default:4191)
  43. #endif
  44. {
  45. pOld = __pTerminate;
  46. __pTerminate = pNew;
  47. }
  48. return pOld;
  49. }
  50. /////////////////////////////////////////////////////////////////////////////
  51. //
  52. // set_unexpected - install a new unexpected handler (ANSI Draft 17.1.2.1.3)
  53. //
  54. _CRTIMP unexpected_function __cdecl
  55. set_unexpected( unexpected_function pNew )
  56. {
  57. unexpected_function pOld = NULL;
  58. #if defined(_DEBUG)
  59. #pragma warning(disable:4191)
  60. if ( (pNew == NULL) || _ValidateExecute( (FARPROC) pNew ) )
  61. #pragma warning(default:4191)
  62. #endif
  63. {
  64. pOld = __pUnexpected;
  65. __pUnexpected = pNew;
  66. }
  67. return pOld;
  68. }
  69. /////////////////////////////////////////////////////////////////////////////
  70. //
  71. // _set_se_translator - install a new SE to C++ EH translator.
  72. //
  73. // The 'new' seh translator may be NULL, because the default one is.
  74. //
  75. _CRTIMP _se_translator_function __cdecl
  76. _set_se_translator( _se_translator_function pNew )
  77. {
  78. _se_translator_function pOld = NULL;
  79. #ifdef _DEBUG
  80. #pragma warning(disable:4191)
  81. if ( (pNew == NULL) || _ValidateExecute( (FARPROC)pNew ) )
  82. #pragma warning(default:4191)
  83. #endif
  84. {
  85. pOld = __pSETranslator;
  86. __pSETranslator = pNew;
  87. }
  88. return pOld;
  89. }
  90. /////////////////////////////////////////////////////////////////////////////
  91. //
  92. // _set_inconsistency - install a new inconsistency handler(Internal Error)
  93. //
  94. // (This function is currently not documented for end-users. At some point,
  95. // it might be advantageous to allow end-users to "catch" internal errors
  96. // from the EH CRT, but for now, they will terminate(). )
  97. _inconsistency_function __cdecl
  98. __set_inconsistency( _inconsistency_function pNew)
  99. {
  100. _inconsistency_function pOld = NULL;
  101. #if defined(_DEBUG)
  102. #pragma warning(disable:4191)
  103. if ( (pNew == NULL) || _ValidateExecute( (FARPROC)pNew ) )
  104. #pragma warning(default:4191)
  105. #endif
  106. {
  107. pOld = __pInconsistency;
  108. __pInconsistency = pNew;
  109. }
  110. return pOld;
  111. }