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

;***
;sehprolog.asm - defines __SEH_prolog and __SEH_epilog
;
; Copyright (c) 1994-2001, Microsoft Corporation. All rights reserved.
;
;Purpose:
; SEH prolog/epilog helper function. Sets up the frame for a function
; with SEH try block.
;
;Revision History:
; 03-28-2000 LL Module created.
; 10-17-2001 PML VS7#313643 Don't set FS:0 until frame set up
;
;*******************************************************************************
title sehprolog.asm
.386P
.model FLAT
ASSUME FS: FLAT
PUBLIC __SEH_prolog
PUBLIC __SEH_epilog
EXTRN __except_handler3:DWORD
_TEXT SEGMENT
; First argument: local frame size
; Second argument: address of SEH try table
__SEH_prolog PROC NEAR
push OFFSET FLAT:__except_handler3 ; push address of SEH handler
mov eax, DWORD PTR fs:0
push eax ; push previous except list head
mov eax, DWORD PTR [esp+16] ; load frame size
mov DWORD PTR [esp+16], ebp ; save off EBP
lea ebp, [esp+16] ; setup base pointer
sub esp, eax ; allocate frame
push ebx ; push callee save regs
push esi
push edi
mov eax, DWORD PTR [ebp-8] ; load return address
mov DWORD PTR [ebp-24], esp ; save off ESP in except record
push eax ; push back return address
mov eax, DWORD PTR [ebp-4] ; load SEH table address
mov DWORD PTR [ebp-4], -1 ; initialize SEH state index
mov DWORD PTR [ebp-8], eax ; Move SEH table addr to the right place
lea eax, [ebp-16] ; link this node to except list
mov DWORD PTR fs:0, eax
ret 0
__SEH_prolog ENDP
__SEH_epilog PROC NEAR
mov ecx, DWORD PTR [ebp-16] ; unlink from except list
mov DWORD PTR fs:0, ecx
pop ecx ; pop return address
pop edi ; pop callee save regs
pop esi
pop ebx
leave
push ecx ; push back return address
ret 0
__SEH_epilog ENDP
_TEXT ENDS
END