Moved most of the real-mode stuff to dlls/winedos.
[wine] / include / callback.h
1 /*
2  * Callback functions
3  *
4  * Copyright 1995 Alexandre Julliard
5  */
6
7 #ifndef __WINE_CALLBACK_H
8 #define __WINE_CALLBACK_H
9
10 #include "windef.h"
11 #include "winnt.h"
12 #include "wingdi.h"
13 #include "wine/winuser16.h"
14
15 extern void SYSDEPS_SwitchToThreadStack( void (*func)(void) ) WINE_NORETURN;
16
17 typedef void (*RELAY)();
18 extern FARPROC THUNK_Alloc( FARPROC16 func, RELAY relay );
19 extern void THUNK_Free( FARPROC thunk );
20 extern BOOL THUNK_Init(void);
21 extern void THUNK_InitCallout(void);
22
23
24 typedef struct
25 {
26     WORD WINAPI     (*UserSignalProc)( UINT, DWORD, DWORD, HMODULE16 );
27     WORD WINAPI     (*DestroyIcon32)( HGLOBAL16, UINT16 );
28 }  CALLOUT_TABLE;
29
30 extern CALLOUT_TABLE Callout;
31
32
33 typedef struct {
34     void WINAPI             (*LoadDosExe)( LPCSTR filename, HANDLE hFile );
35
36     /* DPMI functions */
37     void WINAPI             (*CallRMInt)( CONTEXT86 *context );
38     void WINAPI             (*CallRMProc)( CONTEXT86 *context, int iret );
39     void WINAPI             (*AllocRMCB)( CONTEXT86 *context );
40     void WINAPI             (*FreeRMCB)( CONTEXT86 *context );
41
42     /* I/O functions */
43     void WINAPI             (*SetTimer)( unsigned ticks );
44     unsigned WINAPI         (*GetTimer)( void );
45     BOOL WINAPI             (*inport)( int port, int size, DWORD *res );
46     BOOL WINAPI             (*outport)( int port, int size, DWORD val );
47     void WINAPI             (*ASPIHandler)( CONTEXT86 *context );
48 } DOSVM_TABLE;
49
50 extern DOSVM_TABLE Dosvm;
51
52
53 #include "pshpack1.h"
54
55 typedef struct tagTHUNK
56 {
57     BYTE             popl_eax;           /* 0x58  popl  %eax (return address)*/
58     BYTE             pushl_func;         /* 0x68  pushl $proc */
59     FARPROC16        proc WINE_PACKED;
60     BYTE             pushl_eax;          /* 0x50  pushl %eax */
61     BYTE             jmp;                /* 0xe9  jmp   relay (relative jump)*/
62     RELAY            relay WINE_PACKED;
63     struct tagTHUNK *next WINE_PACKED;
64     DWORD            magic;
65 } THUNK;
66
67 #include "poppack.h"
68
69 #define CALLTO16_THUNK_MAGIC 0x54484e4b   /* "THNK" */
70
71 #define DECL_THUNK(aname,aproc,arelay) \
72     THUNK aname; \
73     aname.popl_eax = 0x58; \
74     aname.pushl_func = 0x68; \
75     aname.proc = (FARPROC16) (aproc); \
76     aname.pushl_eax = 0x50; \
77     aname.jmp = 0xe9; \
78     aname.relay = (RELAY)((char *)(arelay) - (char *)(&(aname).next)); \
79     aname.next = NULL; \
80     aname.magic = CALLTO16_THUNK_MAGIC;
81
82 #endif /* __WINE_CALLBACK_H */