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.

197 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. frsexcpt.c
  5. Abstract:
  6. Temporary -- This routine will be replaced with the standard
  7. exception handling functions.
  8. Author:
  9. Billy J. Fuller 25-Mar-1997
  10. Environment
  11. User mode winnt
  12. --*/
  13. #include <ntreppch.h>
  14. #pragma hdrstop
  15. #define DEBSUB "FRSEXCPT:"
  16. #include <frs.h>
  17. static DWORD LastCode = 0;
  18. static ULONG_PTR LastInfo = 0;
  19. static BOOL Quiet = FALSE;
  20. DWORD
  21. FrsExceptionLastCode(
  22. VOID
  23. )
  24. /*++
  25. Routine Description:
  26. For testing, return the exception code from the last exception
  27. Arguments:
  28. None.
  29. Return Value:
  30. The exception code from the last exception, if any.
  31. --*/
  32. {
  33. return LastCode;
  34. }
  35. ULONG_PTR
  36. FrsExceptionLastInfo(
  37. VOID
  38. )
  39. /*++
  40. Routine Description:
  41. For testing, return the information word from the last exception
  42. Arguments:
  43. None.
  44. Return Value:
  45. The information word from the last exception, if any.
  46. --*/
  47. {
  48. return LastInfo;
  49. }
  50. VOID
  51. FrsExceptionQuiet(
  52. BOOL Desired
  53. )
  54. /*++
  55. Routine Description:
  56. For testing, disable/enable printing exception messages
  57. Arguments:
  58. Desired - TRUE disables messages; FALSE enables
  59. Return Value:
  60. None.
  61. --*/
  62. {
  63. Quiet = Desired;
  64. }
  65. #define FRS_NUM_EXCEPTION_INFO (1)
  66. VOID
  67. FrsRaiseException(
  68. FRS_ERROR_CODE FrsError,
  69. ULONG_PTR Err
  70. )
  71. /*++
  72. Routine Description:
  73. Fill in the exception info and raise the specified exception
  74. Arguments:
  75. FrsError - enum specifying the exception number
  76. Err - Additional info about the exception
  77. Return Value:
  78. None.
  79. --*/
  80. {
  81. ULONG_PTR ExceptInfo[FRS_NUM_EXCEPTION_INFO];
  82. ExceptInfo[0] = Err;
  83. RaiseException(FrsError, 0, FRS_NUM_EXCEPTION_INFO, ExceptInfo);
  84. }
  85. ULONG
  86. FrsException(
  87. EXCEPTION_POINTERS *ExceptionPointers
  88. )
  89. /*++
  90. Routine Description:
  91. This is an expression in an except command. Handle the specified exception.
  92. If the exception is catastrophic (e.g., access violation), kick the problem
  93. upstream to the next exception handler.
  94. Arguments:
  95. ExceptionPointers - returned by GetExceptionInformation
  96. Return Value:
  97. EXCEPTION_CONTIUE_SEARCH - catastrophic exception; kick it upstairs
  98. EXCEPTION_EXECUTE_HANDLER - frs will handle this exception
  99. --*/
  100. {
  101. ULONG ExceptionCode;
  102. ULONG_PTR ExceptionInfo;
  103. EXCEPTION_RECORD *ExceptionRecord;
  104. //
  105. // Pull the exception code and the additional error code (if any)
  106. //
  107. ExceptionRecord = ExceptionPointers->ExceptionRecord;
  108. ExceptionCode = ExceptionRecord->ExceptionCode;
  109. ExceptionInfo = ExceptionRecord->ExceptionInformation[0];
  110. //
  111. // For testing
  112. //
  113. LastCode = ExceptionCode;
  114. LastInfo = ExceptionInfo;
  115. //
  116. // Don't log exceptions
  117. //
  118. if (Quiet) {
  119. switch (ExceptionCode) {
  120. case EXCEPTION_ACCESS_VIOLATION: // these exceptions are not handled
  121. case EXCEPTION_BREAKPOINT:
  122. case EXCEPTION_SINGLE_STEP:
  123. case EXCEPTION_DATATYPE_MISALIGNMENT: // (added to trap JET problems)
  124. return EXCEPTION_CONTINUE_SEARCH;
  125. default:
  126. return EXCEPTION_EXECUTE_HANDLER;
  127. }
  128. }
  129. switch (ExceptionCode) {
  130. case EXCEPTION_ACCESS_VIOLATION: // these exceptions are not handled
  131. case EXCEPTION_BREAKPOINT:
  132. case EXCEPTION_SINGLE_STEP:
  133. case EXCEPTION_DATATYPE_MISALIGNMENT: // (added to trap JET problems)
  134. LogException(ExceptionCode, L"Hardware Exception is not handled");
  135. return EXCEPTION_CONTINUE_SEARCH;
  136. // case FRS_ERROR_MALLOC:
  137. // LogFrsException(FRS_ERROR_MALLOC, 0, L"Out of Memory");
  138. // return EXCEPTION_EXECUTE_HANDLER;
  139. case FRS_ERROR_PROTSEQ:
  140. LogFrsException(FRS_ERROR_PROTSEQ, ExceptionInfo, L"Can't use RPC ncacn_ip_tcp (TCP/IP); error");
  141. return EXCEPTION_EXECUTE_HANDLER;
  142. case FRS_ERROR_REGISTERIF:
  143. LogFrsException(FRS_ERROR_REGISTERIF, ExceptionInfo, L"Can't register RPC interface; error");
  144. return EXCEPTION_EXECUTE_HANDLER;
  145. case FRS_ERROR_INQ_BINDINGS:
  146. LogFrsException(FRS_ERROR_INQ_BINDINGS, ExceptionInfo, L"Can't get RPC interface bindings; error");
  147. return EXCEPTION_EXECUTE_HANDLER;
  148. case FRS_ERROR_REGISTEREP:
  149. LogFrsException(FRS_ERROR_REGISTEREP, ExceptionInfo, L"Can't register dynamic RPC endpoints; error");
  150. return EXCEPTION_EXECUTE_HANDLER;
  151. case FRS_ERROR_LISTEN:
  152. LogFrsException(FRS_ERROR_LISTEN, ExceptionInfo, L"Can't listen for RPC clients; error");
  153. return EXCEPTION_EXECUTE_HANDLER;
  154. default:
  155. LogException(ExceptionCode, L"Hardware Exception is handled");
  156. return EXCEPTION_EXECUTE_HANDLER;
  157. }
  158. }