Leaked source code of windows server 2003
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.

69 lines
1.8 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. ; 10-17-2001 PML VS7#313643 Don't set FS:0 until frame set up
  13. ;
  14. ;*******************************************************************************
  15. title sehprolog.asm
  16. .386P
  17. .model FLAT
  18. ASSUME FS: FLAT
  19. PUBLIC __SEH_prolog
  20. PUBLIC __SEH_epilog
  21. EXTRN __except_handler3:DWORD
  22. _TEXT SEGMENT
  23. ; First argument: local frame size
  24. ; Second argument: address of SEH try table
  25. __SEH_prolog PROC NEAR
  26. push OFFSET FLAT:__except_handler3 ; push address of SEH handler
  27. mov eax, DWORD PTR fs:0
  28. push eax ; push previous except list head
  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. lea eax, [ebp-16] ; link this node to except list
  43. mov DWORD PTR fs:0, eax
  44. ret 0
  45. __SEH_prolog ENDP
  46. __SEH_epilog PROC NEAR
  47. mov ecx, DWORD PTR [ebp-16] ; unlink from except list
  48. mov DWORD PTR fs:0, ecx
  49. pop ecx ; pop return address
  50. pop edi ; pop callee save regs
  51. pop esi
  52. pop ebx
  53. leave
  54. push ecx ; push back return address
  55. ret 0
  56. __SEH_epilog ENDP
  57. _TEXT ENDS
  58. END