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
28 #include <wine/winbase16.h>
32 /* 32-bit stack layout after CallTo16() */
33 typedef struct _STACK32FRAME
35 DWORD restore_addr
; /* 00 return address for restoring code selector */
36 DWORD codeselector
; /* 04 code selector to restore */
37 EXCEPTION_REGISTRATION_RECORD frame
; /* 08 Exception frame */
38 SEGPTR frame16
; /* 10 16-bit frame from last CallFrom16() */
39 DWORD edi
; /* 14 saved registers */
42 DWORD ebp
; /* 20 saved 32-bit frame pointer */
43 DWORD retaddr
; /* 24 return address */
44 DWORD target
; /* 28 target address / CONTEXT86 pointer */
45 DWORD nb_args
; /* 2c number of 16-bit argument bytes */
48 /* 16-bit stack layout after CallFrom16() */
49 typedef struct _STACK16FRAME
51 STACK32FRAME
*frame32
; /* 00 32-bit frame from last CallTo16() */
52 DWORD edx
; /* 04 saved registers */
59 DWORD callfrom_ip
; /* 18 callfrom tail IP */
60 DWORD module_cs
; /* 1c module code segment */
61 DWORD relay
; /* 20 relay function address */
62 WORD entry_ip
; /* 22 entry point IP */
63 DWORD entry_point
; /* 26 API entry point to call, reused as mutex count */
64 WORD bp
; /* 2a 16-bit stack frame chain */
65 WORD ip
; /* 2c return address */
71 #define CURRENT_STACK16 ((STACK16FRAME*)MapSL(NtCurrentTeb()->cur_stack))
72 #define CURRENT_DS (CURRENT_STACK16->ds)
74 /* Push bytes on the 16-bit stack of a thread;
75 * return a segptr to the first pushed byte
77 static inline SEGPTR WINE_UNUSED
stack16_push( int size
)
79 STACK16FRAME
*frame
= CURRENT_STACK16
;
80 memmove( (char*)frame
- size
, frame
, sizeof(*frame
) );
81 NtCurrentTeb()->cur_stack
-= size
;
82 return (SEGPTR
)(NtCurrentTeb()->cur_stack
+ sizeof(*frame
));
85 /* Pop bytes from the 16-bit stack of a thread */
86 static inline void WINE_UNUSED
stack16_pop( int size
)
88 STACK16FRAME
*frame
= CURRENT_STACK16
;
89 memmove( (char*)frame
+ size
, frame
, sizeof(*frame
) );
90 NtCurrentTeb()->cur_stack
+= size
;
93 #endif /* __WINE_STACKFRAME_H */