2 * 16-bit and 32-bit mode stack frame layout
4 * Copyright 1995, 1998 Alexandre Julliard
7 #ifndef __WINE_STACKFRAME_H
8 #define __WINE_STACKFRAME_H
15 /* 32-bit stack layout after CallTo16() */
16 typedef struct _STACK32FRAME
18 SEGPTR frame16; /* 00 16-bit frame from last CallFrom16() */
19 DWORD restore_addr; /* 04 return address for restoring code selector */
20 DWORD codeselector; /* 08 code selector to restore */
21 DWORD edi; /* 0c saved registers */
26 DWORD ebp; /* 20 saved 32-bit frame pointer */
27 DWORD retaddr; /* 24 actual return address */
28 DWORD args[1]; /* 28 arguments to 16-bit function */
31 /* 16-bit stack layout after CallFrom16() */
34 STACK32FRAME *frame32; /* 00 32-bit frame from last CallTo16() */
35 DWORD ebp; /* 04 full 32-bit content of ebp */
36 WORD mutex_count; /* 08 Win16Mutex recursion count */
38 WORD entry_ip; /* 0c ip of entry point */
40 WORD entry_cs; /* 10 cs of entry point */
42 DWORD entry_point; /* 14 32-bit entry point to call */
43 WORD bp; /* 18 16-bit bp */
44 WORD ip; /* 1a return address */
50 #define THREAD_STACK16(thdb) ((STACK16FRAME*)PTR_SEG_TO_LIN((thdb)->cur_stack))
51 #define CURRENT_STACK16 (THREAD_STACK16(THREAD_Current()))
52 #define CURRENT_DS (CURRENT_STACK16->ds)
54 /* varargs lists on the 16-bit stack */
56 typedef void *VA_LIST16;
58 #define __VA_ROUNDED16(type) \
59 ((sizeof(type) + sizeof(WORD) - 1) / sizeof(WORD) * sizeof(WORD))
60 #define VA_START16(list) ((list) = (VA_LIST16)(CURRENT_STACK16 + 1))
61 #define VA_ARG16(list,type) \
62 (((list) = (VA_LIST16)((char *)(list) + __VA_ROUNDED16(type))), \
63 *((type *)(void *)((char *)(list) - __VA_ROUNDED16(type))))
64 #define VA_END16(list) ((void)0)
66 /* Push bytes on the 16-bit stack of a thread;
67 * return a segptr to the first pushed byte
69 #define STACK16_PUSH(thdb,size) \
70 (memmove((char*)THREAD_STACK16(thdb)-(size),THREAD_STACK16(thdb), \
71 sizeof(STACK16FRAME)), \
72 (thdb)->cur_stack -= (size), \
73 (SEGPTR)((thdb)->cur_stack + sizeof(STACK16FRAME)))
75 /* Pop bytes from the 16-bit stack of a thread */
76 #define STACK16_POP(thdb,size) \
77 (memmove((char*)THREAD_STACK16(thdb)+(size),THREAD_STACK16(thdb), \
78 sizeof(STACK16FRAME)), \
79 (thdb)->cur_stack += (size))
81 /* Push a DWORD on the 32-bit stack */
82 #define STACK32_PUSH(context,val) (*--(*(DWORD **)&ESP_reg(context)) = (val))
84 /* Pop a DWORD from the 32-bit stack */
85 #define STACK32_POP(context) (*(*(DWORD **)&ESP_reg(context))++)
87 /* Win32 register functions */
88 #define REGS_FUNC(name) __regs_##name
90 #endif /* __WINE_STACKFRAME_H */