2 * 16-bit and 32-bit mode stack frame layout
4 * Copyright 1995, 1998 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_STACKFRAME_H
22 #define __WINE_STACKFRAME_H
25 #define NTOS_MODE_USER
26 #include <ndk/umtypes.h>
27 #include <ndk/extypes.h>
28 #include <ndk/rtlfuncs.h>
30 #define SELECTOROF(ptr) (HIWORD(ptr))
31 #define OFFSETOF(ptr) (LOWORD(ptr))
35 /* 32-bit stack layout after CallTo16() */
36 typedef struct _STACK32FRAME
38 DWORD restore_addr
; /* 00 return address for restoring code selector */
39 DWORD codeselector
; /* 04 code selector to restore */
40 EXCEPTION_REGISTRATION_RECORD frame
; /* 08 Exception frame */
41 SEGPTR frame16
; /* 10 16-bit frame from last CallFrom16() */
42 DWORD edi
; /* 14 saved registers */
45 DWORD ebp
; /* 20 saved 32-bit frame pointer */
46 DWORD retaddr
; /* 24 return address */
47 DWORD target
; /* 28 target address / CONTEXT86 pointer */
48 DWORD nb_args
; /* 2c number of 16-bit argument bytes */
51 /* 16-bit stack layout after CallFrom16() */
52 typedef struct _STACK16FRAME
54 STACK32FRAME
*frame32
; /* 00 32-bit frame from last CallTo16() */
55 DWORD edx
; /* 04 saved registers */
62 DWORD callfrom_ip
; /* 18 callfrom tail IP */
63 DWORD module_cs
; /* 1c module code segment */
64 DWORD relay
; /* 20 relay function address */
65 WORD entry_ip
; /* 22 entry point IP */
66 DWORD entry_point
; /* 26 API entry point to call, reused as mutex count */
67 WORD bp
; /* 2a 16-bit stack frame chain */
68 WORD ip
; /* 2c return address */
74 static inline int MapSL(int size
)
79 #define CURRENT_STACK16 ((STACK16FRAME*)MapSL(NtCurrentTeb()->cur_stack))
80 #define CURRENT_DS (CURRENT_STACK16->ds)
83 #endif /* __WINE_STACKFRAME_H */