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.

112 lines
2.6 KiB

  1. //
  2. // Created by TiborL 06/01/97
  3. //
  4. #ifdef WIN32_LEAN_AND_MEAN
  5. #undef WIN32_LEAN_AND_MEAN
  6. #endif
  7. #pragma warning(disable:4102 4700)
  8. extern "C" {
  9. #include <windows.h>
  10. };
  11. #include <mtdll.h>
  12. #include <ehassert.h>
  13. #include <ehdata.h>
  14. #include <trnsctrl.h>
  15. #include <eh.h>
  16. #include <ehhooks.h>
  17. #pragma hdrstop
  18. extern "C" void RtlCaptureContext(CONTEXT*);
  19. extern "C" void _UnwindNestedFrames(
  20. EHRegistrationNode *pFrame, // Unwind up to (but not including) this frame
  21. EHExceptionRecord *pExcept, // The exception that initiated this unwind
  22. CONTEXT *pContext // Context info for current exception
  23. ) {
  24. void *pReturnPoint; // The address we want to return from RtlUnwind
  25. CONTEXT LocalContext; // Create context for this routine to return from RtlUnwind
  26. CONTEXT OriginalContext; // Restore pContext from this
  27. CONTEXT ScratchContext; // Context record to pass to RtlUnwind2 to be used as scratch
  28. //
  29. // set up the return label
  30. //
  31. BASE:
  32. /*
  33. // **** manually added to handlers.s
  34. { .mii
  35. nop.m 0
  36. mov r2=ip
  37. adds r2=$LABEL - $BASE, r2
  38. }
  39. { .mmi
  40. adds r30=pReturnPoint$, sp
  41. st4 [r30]=r2
  42. nop.i 0
  43. }
  44. // ****
  45. */
  46. _MoveContext(&OriginalContext,pContext);
  47. RtlCaptureContext(&LocalContext);
  48. LocalContext.StIIP = (ULONGLONG)pReturnPoint;
  49. _MoveContext(&ScratchContext,&LocalContext);
  50. _SaveUnwindContext(&LocalContext);
  51. RtlUnwind2(*pFrame, pReturnPoint, (PEXCEPTION_RECORD)pExcept, NULL, &ScratchContext);
  52. LABEL:
  53. _MoveContext(pContext,&OriginalContext);
  54. _SaveUnwindContext(0);
  55. PER_FLAGS(pExcept) &= ~EXCEPTION_UNWINDING;
  56. }
  57. /*
  58. //++
  59. //
  60. //extern "C"
  61. //PVOID
  62. //__Cxx_ExecuteHandler (
  63. // ULONGLONG MemoryStack,
  64. // ULONGLONG BackingStore,
  65. // ULONGLONG Handler,
  66. // ULONGLONG GlobalPointer
  67. // );
  68. //
  69. //Routine Description:
  70. //
  71. // This function scans the scope tables associated with the specified
  72. // procedure and calls exception and termination handlers as necessary.
  73. //
  74. //Arguments:
  75. //
  76. // MemoryStack (r32) - memory stack pointer of establisher frame
  77. //
  78. // BackingStore (r33) - backing store pointer of establisher frame
  79. //
  80. // Handler (r34) - Entry point of handler
  81. //
  82. // GlobalPointer (r35) - GP of termination handler
  83. //
  84. //Return Value:
  85. //
  86. // Returns the continuation point
  87. //
  88. //--
  89. .global __Cxx_ExecuteHandler#
  90. .proc __Cxx_ExecuteHandler#
  91. .align 32
  92. __Cxx_ExecuteHandler:
  93. alloc r2=0, 0, 2, 0
  94. mov gp = r35 // set new GP
  95. mov b6 = r34 // handler address
  96. br b6 // branch to handler
  97. nop.b 0
  98. nop.b 0
  99. .endp __Cxx_ExecuteHandler#
  100. */