source: trunk/include/win/stackframe.h

Last change on this file was 4, checked in by ktk, 26 years ago

Import

File size: 3.2 KB
Line 
1/* $Id: stackframe.h,v 1.1 1999-05-24 20:19:19 ktk Exp $ */
2
3/*
4 * 16-bit and 32-bit mode stack frame layout
5 *
6 * Copyright 1995, 1998 Alexandre Julliard
7 */
8
9#ifndef __WINE_STACKFRAME_H
10#define __WINE_STACKFRAME_H
11
12#include "ldt.h"
13#include "thread.h"
14
15#include "pshpack1.h"
16
17 /* 32-bit stack layout after CallTo16() */
18typedef struct _STACK32FRAME
19{
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;
32
33 /* 16-bit stack layout after CallFrom16() */
34typedef struct
35{
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;
49
50#include "poppack.h"
51
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)
55
56/* varargs lists on the 16-bit stack */
57
58typedef void *VA_LIST16;
59
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)
67
68/* Push bytes on the 16-bit stack of a thread;
69 * return a segptr to the first pushed byte
70 */
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)))
76
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))
82
83/* Push a DWORD on the 32-bit stack */
84#define STACK32_PUSH(context,val) (*--((DWORD *)ESP_reg(context)) = (val))
85
86/* Pop a DWORD from the 32-bit stack */
87#define STACK32_POP(context) (*((DWORD *)ESP_reg(context))++)
88
89/* Win32 register functions */
90#define REGS_ENTRYPOINT(name) void WINAPI __regs_##name( CONTEXT *context )
91
92#endif /* __WINE_STACKFRAME_H */
Note: See TracBrowser for help on using the repository browser.