[PSEH3]
[reactos.git] / reactos / lib / pseh / i386 / pseh3_i386.S
1 /*
2 * PROJECT: ReactOS system libraries
3 * LICENSE: GNU GPL - See COPYING in the top level directory
4 * PURPOSE: Support library for PSEH3
5 * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
6 */
7
8 #include "pseh3_asmdef.h"
9
10 .intel_syntax noprefix
11
12 .text
13
14
15 .extern __SEH3$_except_handler
16
17 /*
18 * void
19 * _SEH3$_RegisterFrame(
20 * PSEH_REGISTRATION_FRAME RegistrationRecord<ecx>,
21 * PSEH_DATA_TABLE DataTable<eax>);
22 */
23 .global __SEH3$_RegisterFrame
24 __SEH3$_RegisterFrame:
25
26 /* Save the address of the static data table */
27 mov [ecx + SEH3_REGISTRATION_FRAME_ScopeTable], eax
28
29 /* Set the handler address */
30 mov dword ptr [ecx + SEH3_REGISTRATION_FRAME_Handler], offset __SEH3$_except_handler
31
32 /* Set this as the end of the internal chain */
33 mov dword ptr [ecx + SEH3_REGISTRATION_FRAME_EndOfChain], ecx
34
35 /* Register the frame in the TEB */
36 mov eax, dword ptr fs:[0]
37 mov [ecx + SEH3_REGISTRATION_FRAME_Next], eax
38 mov dword ptr fs:[0], ecx
39
40 /* Save the registers */
41 mov [ecx + SEH3_REGISTRATION_FRAME_Esp], esp
42 mov [ecx + SEH3_REGISTRATION_FRAME_Ebp], ebp
43
44 ret
45
46
47 .global __SEH3$_RegisterTryLevel
48 __SEH3$_RegisterTryLevel:
49
50 /* Save the address of the static data table */
51 mov [ecx + SEH3_REGISTRATION_FRAME_ScopeTable], eax
52
53 /* Set the handler address to NULL as identification */
54 and dword ptr [ecx + SEH3_REGISTRATION_FRAME_Handler], 0
55
56 /* Get the current registered frame */
57 mov eax, dword ptr fs:[0]
58
59 /* Get the current end of the chain and set this as Next */
60 mov edx, [eax + SEH3_REGISTRATION_FRAME_EndOfChain]
61 mov [ecx + SEH3_REGISTRATION_FRAME_Next], edx
62
63 /* Set this as the end of the internal chain */
64 mov dword ptr [eax + SEH3_REGISTRATION_FRAME_EndOfChain], ecx
65
66 /* Save the registers */
67 mov [ecx + SEH3_REGISTRATION_FRAME_Esp], esp
68 mov [ecx + SEH3_REGISTRATION_FRAME_Ebp], ebp
69
70 ret
71
72