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.

67 lines
1.7 KiB

  1. ;***
  2. ;sehprolog.asm - defines __SEH_prolog and __SEH_epilog
  3. ;
  4. ; Copyright (c) 1994-2001, Microsoft Corporation. All rights reserved.
  5. ;
  6. ;Purpose:
  7. ; SEH prolog/epilog helper function. Sets up the frame for a function
  8. ; with SEH try block.
  9. ;
  10. ;Revision History:
  11. ; 03-28-2000 LL Module created.
  12. ;
  13. ;*******************************************************************************
  14. title sehprolog.asm
  15. .386P
  16. .model FLAT
  17. ASSUME FS: FLAT
  18. PUBLIC __SEH_prolog
  19. PUBLIC __SEH_epilog
  20. EXTRN __except_handler3:DWORD
  21. _TEXT SEGMENT
  22. ; First argument: local frame size
  23. ; Second argument: address of SEH try table
  24. __SEH_prolog PROC NEAR
  25. push OFFSET FLAT:__except_handler3 ; push address of SEH handler
  26. mov eax, DWORD PTR fs:0
  27. push eax ; push previous except list head
  28. mov DWORD PTR fs:0, esp ; link this node to except list
  29. mov eax, DWORD PTR [esp+16] ; load frame size
  30. mov DWORD PTR [esp+16], ebp ; save off EBP
  31. lea ebp, [esp+16] ; setup base pointer
  32. sub esp, eax ; allocate frame
  33. push ebx ; push callee save regs
  34. push esi
  35. push edi
  36. mov eax, DWORD PTR [ebp-8] ; load return address
  37. mov DWORD PTR [ebp-24], esp ; save off ESP in except record
  38. push eax ; push back return address
  39. mov eax, DWORD PTR [ebp-4] ; load SEH table address
  40. mov DWORD PTR [ebp-4], -1 ; initialize SEH state index
  41. mov DWORD PTR [ebp-8], eax ; Move SEH table addr to the right place
  42. ret 0
  43. __SEH_prolog ENDP
  44. __SEH_epilog PROC NEAR
  45. mov ecx, DWORD PTR [ebp-16] ; unlink from except list
  46. mov DWORD PTR fs:0, ecx
  47. pop ecx ; pop return address
  48. pop edi ; pop callee save regs
  49. pop esi
  50. pop ebx
  51. leave
  52. push ecx ; push back return address
  53. ret 0
  54. __SEH_epilog ENDP
  55. _TEXT ENDS
  56. END