1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
;***
;setjmp.asm
;
; Copyright (C) 1993 - 1994 Microsoft Corporation. All rights reserved.
;
;Purpose:
; Contains setjmp() & raisex() routines;
; split from exsup.asm for granularity purposes.
;
;Notes:
;
;Revision History:
; 04-13-93 JWM Module created.
; 10-14-93 GJF Merged in NT verson.
; 01-12-94 PML Added C9.0 generic EH callback for unwind. Split
; into setjmp.asm, setjmp3.asm, and longjmp.asm.
; 02-10-94 GJF -1 is the end-of-exception-handler chain marker, not
; 0.
;
;*******************************************************************************
;hnt = -D_WIN32_ -Dsmall32 -Dflat32 -Mx $this;
;Define small32 and flat32 since these are not defined in the NT build process
small32 equ 1
flat32 equ 1
.xlist
include pversion.inc
?DFDATA = 1
?NODATA = 1
include cmacros.mas
include exsup.inc
.list
assumes DS,DATA
assumes FS,DATA
BeginCODE
if @Version LT 600
;this needs to go here to work around a masm5 bug. (emits wrong fixup)
assumes CS,FLAT
endif
; Following symbol defined in exsup.asm
extrn __except_list:near
; int
; _setjmp (
; OUT jmp_buf env)
;
; Routine Description:
;
; (Old) implementation of setjmp intrinsic. Saves the current
; nonvolatile register state in the specified jump buffer and returns
; a function value of zero.
;
; Saves the callee-save registers, stack pointer and return address.
; Also saves the exception registration list head.
;
; This code is only present for old apps that link to the DLL runtimes,
; or old object files compiles with C8.0. It intentionally duplicates
; the old setjmp bugs, blindly assuming that the topmost EH node is a
; C8.0 SEH node.
;
; Arguments:
;
; env - Address of the buffer for storing the state information
;
; Return Value:
;
; A value of zero is returned.
public __setjmp
__setjmp PROC NEAR
mov edx, [esp+4]
mov [edx.saved_ebp], ebp ; old bp and the rest
mov [edx.saved_ebx], ebx
mov [edx.saved_edi], edi
mov [edx.saved_esi], esi
mov [edx.saved_esp], esp
mov eax, [esp] ; return address
mov [edx.saved_return], eax
mov eax, dword ptr fs:__except_list
mov [edx.saved_xregistration], eax
cmp eax, -1 ; -1 means no higher-level handler
jnz short _sj_save_trylevel
mov dword ptr [edx.saved_trylevel], -1 ;something invalid
jmp short _sj_done
_sj_save_trylevel:
mov eax, [eax + C8_TRYLEVEL]
mov [edx.saved_trylevel], eax
_sj_done:
sub eax, eax
ret
__setjmp ENDP
; void
; raisex (
; IN PEXCEPTION_RECORD pxr)
;
; Routine Description:
;
; Unknown. This seems to duplicate the RaiseException API (sort of),
; but I'm not sure what it's doing here. It's not documented, but
; it's in the reserved ANSI namespace. Here it stays, in case someone
; really counts on it.
;
; Arguments:
;
; pxr - Pointer to EXCEPTION_RECORD buffer
;
; Return Value:
;
; None.
cProc raisex,<C,PUBLIC>
parmDP pxr
cBegin
pushfd
pushad
mov esi, dword ptr pxr
mov ebx, dword ptr fs:__except_list
_r_top:
or ebx, ebx
je short _r_error
push ebx ;pass address of the registration record
push esi ;pass the exception record
call [ebx.handler] ;execute language handler for this proc
add esp, 8
cmp eax, DISPOSITION_DISMISS
je short _r_dismiss
cmp eax, DISPOSITION_CONTINUE_SEARCH
jne short _r_error
mov ebx, [ebx.prev]
jmp short _r_top
_r_error:
;assert(UNREACHED); exit(-1);
_r_dismiss:
popad
popfd
cEnd
EndCODE
END
|