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.

160 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. Except.c
  5. Abstract:
  6. This module implements the exception handling for the NetWare
  7. redirector called by the dispatch driver.
  8. Author:
  9. Colin Watson [ColinW] 19-Dec-1992
  10. Revision History:
  11. --*/
  12. #include "Procs.h"
  13. //
  14. // The debug trace level
  15. //
  16. #define Dbg (DEBUG_TRACE_CATCH_EXCEPTIONS)
  17. #if 0 // Not pageable
  18. NwExceptionFilter
  19. NwProcessException
  20. #endif
  21. LONG
  22. NwExceptionFilter (
  23. IN PIRP Irp,
  24. IN PEXCEPTION_POINTERS ExceptionPointer
  25. )
  26. /*++
  27. Routine Description:
  28. This routine is used to decide if we should or should not handle
  29. an exception status that is being raised. It inserts the status
  30. into the IrpContext and either indicates that we should handle
  31. the exception or bug check the system.
  32. Arguments:
  33. ExceptionCode - Supplies the exception code to being checked.
  34. Return Value:
  35. ULONG - returns EXCEPTION_EXECUTE_HANDLER or bugchecks
  36. --*/
  37. {
  38. NTSTATUS ExceptionCode;
  39. #ifdef NWDBG
  40. PVOID ExceptionAddress;
  41. ExceptionAddress = ExceptionPointer->ExceptionRecord->ExceptionAddress;
  42. #endif
  43. ExceptionCode = ExceptionPointer->ExceptionRecord->ExceptionCode;
  44. DebugTrace(0, DEBUG_TRACE_UNWIND, "NwExceptionFilter %X\n", ExceptionCode);
  45. #ifdef NWDBG
  46. DebugTrace(0, DEBUG_TRACE_UNWIND, " %X\n", ExceptionAddress);
  47. #endif
  48. //
  49. // If the exception is STATUS_IN_PAGE_ERROR, get the I/O error code
  50. // from the exception record.
  51. //
  52. if (ExceptionCode == STATUS_IN_PAGE_ERROR) {
  53. if (ExceptionPointer->ExceptionRecord->NumberParameters >= 3) {
  54. ExceptionCode = (NTSTATUS) ExceptionPointer->ExceptionRecord->ExceptionInformation[2];
  55. }
  56. }
  57. if (FsRtlIsNtstatusExpected( ExceptionCode )) {
  58. DebugTrace(0, DEBUG_TRACE_UNWIND, "Exception expected\n", 0);
  59. return EXCEPTION_EXECUTE_HANDLER;
  60. } else {
  61. return EXCEPTION_CONTINUE_SEARCH;
  62. }
  63. }
  64. NTSTATUS
  65. NwProcessException (
  66. IN PIRP_CONTEXT IrpContext,
  67. IN NTSTATUS ExceptionCode
  68. )
  69. /*++
  70. Routine Description:
  71. This routine process an exception. It either completes the request
  72. with the saved exception status or it sends it off to IoRaiseHardError()
  73. Arguments:
  74. IrpContext - Supplies the Irp being processed
  75. ExceptionCode - Supplies the normalized exception status being handled
  76. Return Value:
  77. NTSTATUS - Returns the results of either posting the Irp or the
  78. saved completion status.
  79. --*/
  80. {
  81. NTSTATUS Status;
  82. PIRP Irp;
  83. DebugTrace(0, Dbg, "NwProcessException\n", 0);
  84. Irp = IrpContext->pOriginalIrp;
  85. Irp->IoStatus.Status = ExceptionCode;
  86. //
  87. // If the error is a hard error, or verify required, then we will complete
  88. // it if this is a recursive Irp, or with a top-level Irp, either send
  89. // it to the Fsp for verification, or send it to IoRaiseHardError, who
  90. // will deal with it.
  91. //
  92. if (ExceptionCode == STATUS_CANT_WAIT) {
  93. Status = NwPostToFsp( IrpContext, TRUE );
  94. } else {
  95. //
  96. // We got an error, so zero out the information field before
  97. // completing the request if this was an input operation.
  98. // Otherwise IopCompleteRequest will try to copy to the user's buffer.
  99. //
  100. if ( FlagOn(Irp->Flags, IRP_INPUT_OPERATION) ) {
  101. Irp->IoStatus.Information = 0;
  102. }
  103. Status = ExceptionCode;
  104. }
  105. return Status;
  106. }