Moved ADVAPI32 files to dlls/advapi32.
[wine/multimedia.git] / include / stackframe.h
blob24cad98bf80431f532446bdb5cb8bd8e565458c4
1 /*
2 * 16-bit and 32-bit mode stack frame layout
4 * Copyright 1995, 1998 Alexandre Julliard
5 */
7 #ifndef __WINE_STACKFRAME_H
8 #define __WINE_STACKFRAME_H
10 #include <string.h>
11 #include "windows.h"
12 #include "ldt.h"
13 #include "thread.h"
15 #pragma pack(1)
17 /* 32-bit stack layout after CallTo16() */
18 typedef struct _STACK32FRAME
20 SEGPTR frame16; /* 00 16-bit frame from last CallFrom16() */
21 DWORD restore_addr; /* 04 return address for restoring code selector */
22 DWORD codeselector; /* 08 code selector to restore */
23 DWORD edi; /* 0c saved registers */
24 DWORD esi; /* 10 */
25 DWORD edx; /* 14 */
26 DWORD ecx; /* 18 */
27 DWORD ebx; /* 1c */
28 DWORD ebp; /* 20 saved 32-bit frame pointer */
29 DWORD retaddr; /* 24 actual return address */
30 DWORD args[1]; /* 28 arguments to 16-bit function */
31 } STACK32FRAME;
33 /* 16-bit stack layout after CallFrom16() */
34 typedef struct
36 STACK32FRAME *frame32; /* 00 32-bit frame from last CallTo16() */
37 DWORD ebp; /* 04 full 32-bit content of ebp */
38 WORD mutex_count; /* 08 Win16Mutex recursion count */
39 WORD fs; /* 0a fs */
40 WORD entry_ip; /* 0c ip of entry point */
41 WORD ds; /* 0e ds */
42 WORD entry_cs; /* 10 cs of entry point */
43 WORD es; /* 12 es */
44 DWORD entry_point; /* 14 32-bit entry point to call */
45 WORD bp; /* 18 16-bit bp */
46 WORD ip; /* 1a return address */
47 WORD cs; /* 1c */
48 } STACK16FRAME;
50 #pragma pack(4)
52 #define THREAD_STACK16(thdb) ((STACK16FRAME*)PTR_SEG_TO_LIN((thdb)->cur_stack))
53 #define CURRENT_STACK16 (THREAD_STACK16(THREAD_Current()))
54 #define CURRENT_DS (CURRENT_STACK16->ds)
56 /* varargs lists on the 16-bit stack */
58 typedef void *VA_LIST16;
60 #define __VA_ROUNDED16(type) \
61 ((sizeof(type) + sizeof(WORD) - 1) / sizeof(WORD) * sizeof(WORD))
62 #define VA_START16(list) ((list) = (VA_LIST16)(CURRENT_STACK16 + 1))
63 #define VA_ARG16(list,type) \
64 (((list) = (VA_LIST16)((char *)(list) + __VA_ROUNDED16(type))), \
65 *((type *)(void *)((char *)(list) - __VA_ROUNDED16(type))))
66 #define VA_END16(list) ((void)0)
68 /* Push bytes on the 16-bit stack of a thread;
69 * return a segptr to the first pushed byte
71 #define STACK16_PUSH(thdb,size) \
72 (memmove((char*)THREAD_STACK16(thdb)-(size),THREAD_STACK16(thdb), \
73 sizeof(STACK16FRAME)), \
74 (thdb)->cur_stack -= (size), \
75 (SEGPTR)((thdb)->cur_stack + sizeof(STACK16FRAME)))
77 /* Pop bytes from the 16-bit stack of a thread */
78 #define STACK16_POP(thdb,size) \
79 (memmove((char*)THREAD_STACK16(thdb)+(size),THREAD_STACK16(thdb), \
80 sizeof(STACK16FRAME)), \
81 (thdb)->cur_stack += (size))
83 /* Push a DWORD on the 32-bit stack */
84 #define STACK32_PUSH(context,val) (*--((DWORD *)ESP_reg(context)) = (val))
86 /* Pop a DWORD from the 32-bit stack */
87 #define STACK32_POP(context) (*((DWORD *)ESP_reg(context))++)
89 /* Win32 register functions */
90 #define REGS_ENTRYPOINT(name) void WINAPI __regs_##name( CONTEXT *context )
92 #endif /* __WINE_STACKFRAME_H */