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.

102 lines
2.5 KiB

  1. title "Set Jump Buffer"
  2. ;++
  3. ;
  4. ; Copyright (c) 2000 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; setjmpex.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements the AMD64 specific routine to perform safe set
  13. ; jump.
  14. ;
  15. ; Author:
  16. ;
  17. ; David N. Cutler (davec) 3-Nov-2000
  18. ;
  19. ; Environment:
  20. ;
  21. ; Any mode.
  22. ;
  23. ;--
  24. include ksamd64.inc
  25. ;
  26. ; Define variable that will cause setjmp/longjmp to be safe or unsafe with
  27. ; respect to structured exception handling.
  28. ;
  29. _setjmp_ segment para common 'DATA'
  30. dq _setjmpex ;
  31. _setjmp_ ends
  32. subttl "Safe Set Jump"
  33. ;++
  34. ;
  35. ; int
  36. ; _setjmpex (
  37. ; IN jmp_buf JumpBuffer,
  38. ; IN ULONG64 FrameBase
  39. ; )
  40. ;
  41. ; Routine Description:
  42. ;
  43. ; This function saves the current nonvolatile register state in the
  44. ; specified jump buffer and returns a function vlaue of zero.
  45. ;
  46. ; Arguments:
  47. ;
  48. ; JumpBuffer (rcx) - Supplies a pointer to a jump buffer.
  49. ;
  50. ; FrameBase (rdx) - Supplies the base address of the caller frame.
  51. ;
  52. ; Return Value:
  53. ;
  54. ; A value of zero is returned.
  55. ;
  56. ;--
  57. LEAF_ENTRY _setjmpex, _TEXT$00
  58. ;
  59. ; Save the nonvolatile register state so these registers to be restored to
  60. ; their value at the call to setjmp. If these registers were not saved, then
  61. ; they would be restored to their current value in the target function which
  62. ; would be incorrect.
  63. ;
  64. mov JbFrame[rcx], rdx ; set frame base
  65. mov JbRbx[rcx], rbx ; save nonvolatile integer registers
  66. mov JbRbp[rcx], rbp ;
  67. mov JbRsi[rcx], rsi ;
  68. mov JbRdi[rcx], rdi ;
  69. mov JbR12[rcx], r12 ;
  70. mov JbR13[rcx], r13 ;
  71. mov JbR14[rcx], r14 ;
  72. mov JbR15[rcx], r15 ;
  73. lea r8, 8[rsp] ; save caller stack pointer
  74. mov JbRsp[rcx], r8 ;
  75. mov r8, [rsp] ; save caller return address
  76. mov JbRip[rcx], r8 ;
  77. movdqa JbXmm6[rcx], xmm6 ; save nonvolatile floating registers
  78. movdqa JbXmm7[rcx], xmm7 ;
  79. movdqa JbXmm8[rcx], xmm8 ;
  80. movdqa JbXmm9[rcx], xmm9 ;
  81. movdqa JbXmm10[rcx], xmm10 ;
  82. movdqa JbXmm11[rcx], xmm11 ;
  83. movdqa JbXmm12[rcx], xmm12 ;
  84. movdqa JbXmm13[rcx], xmm13 ;
  85. movdqa JbXmm14[rcx], xmm14 ;
  86. movdqa JbXmm15[rcx], xmm15 ;
  87. xor eax, eax ; set return value
  88. ret ; return
  89. LEAF_END _setjmpex, _TEXT$00
  90. end