blob: 3ca005248355037f364f2419ad0f1351ffd70a05 [file] [log] [blame]
Alexandre Julliard121bd981993-07-08 17:37:25 +00001/*
Alexandre Julliardca22b331996-07-12 19:02:39 +00002 * Callback functions
Alexandre Julliardfa68b751995-04-03 16:55:37 +00003 *
4 * Copyright 1995 Alexandre Julliard
Alexandre Julliard121bd981993-07-08 17:37:25 +00005 */
6
Alexandre Julliardf1aa3031996-08-05 17:42:43 +00007#ifndef __WINE_CALLBACK_H
8#define __WINE_CALLBACK_H
Alexandre Julliard121bd981993-07-08 17:37:25 +00009
Jim Aston2e1cafa1999-03-14 16:35:05 +000010#include "windef.h"
Alexandre Julliard21979011997-03-05 08:22:35 +000011#include "winnt.h"
Jeremy Whited3e22d92000-02-10 19:03:02 +000012#include "wingdi.h"
Michael Vekslerca1bc861999-01-01 18:57:33 +000013#include "wine/winuser16.h"
Alexandre Julliard121bd981993-07-08 17:37:25 +000014
Ulrich Weigand7e85ea72000-06-04 01:35:43 +000015extern void SYSDEPS_SwitchToThreadStack( void (*func)(void) ) WINE_NORETURN;
16extern int SYSDEPS_CallOnLargeStack( int (*func)(void *), void *arg );
Alexandre Julliard670cdc41997-08-24 16:00:30 +000017
Ulrich Weigand7e85ea72000-06-04 01:35:43 +000018#define CALL_LARGE_STACK( func, arg ) \
19 SYSDEPS_CallOnLargeStack( (int (*)(void *))(func), (void *)(arg) )
Alexandre Julliarda2f2e011995-06-06 16:40:35 +000020
Huw D M Davies304d9a41999-09-13 15:15:45 +000021typedef void (*RELAY)();
22extern FARPROC THUNK_Alloc( FARPROC16 func, RELAY relay );
23extern void THUNK_Free( FARPROC thunk );
Alexandre Julliardb4459522000-04-15 21:00:55 +000024extern BOOL THUNK_Init(void);
25extern void THUNK_InitCallout(void);
26
Alexandre Julliard491502b1997-11-01 19:08:16 +000027typedef struct
28{
Francois Gougetae41e8c2000-06-11 20:07:58 +000029 LONG CALLBACK (*CallRegisterShortProc)( CONTEXT86 *, INT );
30 LONG CALLBACK (*CallRegisterLongProc)( CONTEXT86 *, INT );
31 INT16 CALLBACK (*CallWindowsExitProc)( FARPROC16, INT16 );
32 INT16 CALLBACK (*CallWordBreakProc)( EDITWORDBREAKPROC16, SEGPTR, INT16,
Alexandre Julliard491502b1997-11-01 19:08:16 +000033 INT16, INT16 );
Francois Gougetae41e8c2000-06-11 20:07:58 +000034 VOID CALLBACK (*CallBootAppProc)( FARPROC16, HANDLE16, HFILE16 );
35 WORD CALLBACK (*CallLoadAppSegProc)( FARPROC16, HANDLE16, HFILE16, WORD );
36 WORD CALLBACK (*CallLocalNotifyFunc)( FARPROC16, WORD, HLOCAL16, WORD );
37 HGLOBAL16 CALLBACK (*CallResourceHandlerProc)( FARPROC16, HGLOBAL16, HMODULE16, HRSRC16 );
38 DWORD CALLBACK (*CallUTProc)( FARPROC16, DWORD, DWORD );
39 LRESULT CALLBACK (*CallASPIPostProc)( FARPROC16, SEGPTR );
Alexandre Julliard491502b1997-11-01 19:08:16 +000040} CALLBACKS_TABLE;
Alexandre Julliard121bd981993-07-08 17:37:25 +000041
Alexandre Julliard491502b1997-11-01 19:08:16 +000042extern const CALLBACKS_TABLE *Callbacks;
Alexandre Julliardfa68b751995-04-03 16:55:37 +000043
Ulrich Weigand61439d21998-12-24 15:12:20 +000044typedef struct
45{
46 BOOL16 WINAPI (*PeekMessage16)( LPMSG16 msg, HWND16 hwnd,
47 UINT16 first, UINT16 last, UINT16 flags );
Alexandre Julliarda3960291999-02-26 11:11:13 +000048 BOOL WINAPI (*PeekMessageA)( LPMSG lpmsg, HWND hwnd,
49 UINT min, UINT max, UINT wRemoveMsg );
50 BOOL WINAPI (*PeekMessageW)( LPMSG lpmsg, HWND hwnd,
51 UINT min, UINT max, UINT wRemoveMsg );
Ulrich Weigand61439d21998-12-24 15:12:20 +000052
53 BOOL16 WINAPI (*GetMessage16)( SEGPTR msg, HWND16 hwnd,
54 UINT16 first, UINT16 last );
Alexandre Julliarda3960291999-02-26 11:11:13 +000055 BOOL WINAPI (*GetMessageA)( MSG* lpmsg, HWND hwnd,
56 UINT min, UINT max );
57 BOOL WINAPI (*GetMessageW)( MSG* lpmsg, HWND hwnd,
58 UINT min, UINT max );
Ulrich Weigand61439d21998-12-24 15:12:20 +000059
60 LRESULT WINAPI (*SendMessage16)( HWND16 hwnd, UINT16 msg,
61 WPARAM16 wParam, LPARAM lParam );
Alexandre Julliarda3960291999-02-26 11:11:13 +000062 LRESULT WINAPI (*SendMessageA)( HWND hwnd, UINT msg,
63 WPARAM wParam, LPARAM lParam );
64 LRESULT WINAPI (*SendMessageW)( HWND hwnd, UINT msg,
65 WPARAM wParam, LPARAM lParam );
Ulrich Weigand61439d21998-12-24 15:12:20 +000066
67 BOOL16 WINAPI (*PostMessage16)( HWND16 hwnd, UINT16 message,
68 WPARAM16 wParam, LPARAM lParam );
Alexandre Julliarda3960291999-02-26 11:11:13 +000069 BOOL WINAPI (*PostMessageA)( HWND hwnd, UINT message,
70 WPARAM wParam, LPARAM lParam );
71 BOOL WINAPI (*PostMessageW)( HWND hwnd, UINT message,
72 WPARAM wParam, LPARAM lParam );
Ulrich Weigand61439d21998-12-24 15:12:20 +000073
74 BOOL16 WINAPI (*PostAppMessage16)( HTASK16 hTask, UINT16 message,
75 WPARAM16 wParam, LPARAM lParam );
Alexandre Julliarda3960291999-02-26 11:11:13 +000076 BOOL WINAPI (*PostThreadMessageA)( DWORD idThread , UINT message,
77 WPARAM wParam, LPARAM lParam );
78 BOOL WINAPI (*PostThreadMessageW)( DWORD idThread , UINT message,
79 WPARAM wParam, LPARAM lParam );
Ulrich Weigand61439d21998-12-24 15:12:20 +000080
81 BOOL16 WINAPI (*TranslateMessage16)( const MSG16 *msg );
Alexandre Julliarda3960291999-02-26 11:11:13 +000082 BOOL WINAPI (*TranslateMessage)( const MSG *msg );
Ulrich Weigand61439d21998-12-24 15:12:20 +000083
84 LONG WINAPI (*DispatchMessage16)( const MSG16* msg );
Alexandre Julliarda3960291999-02-26 11:11:13 +000085 LONG WINAPI (*DispatchMessageA)( const MSG* msg );
86 LONG WINAPI (*DispatchMessageW)( const MSG* msg );
Ulrich Weigand61439d21998-12-24 15:12:20 +000087
88 BOOL16 WINAPI (*RedrawWindow16)( HWND16 hwnd, const RECT16 *rectUpdate,
89 HRGN16 hrgnUpdate, UINT16 flags );
90
Alexandre Julliarda3960291999-02-26 11:11:13 +000091 BOOL WINAPI (*RedrawWindow)( HWND hwnd, const RECT *rectUpdate,
92 HRGN hrgnUpdate, UINT flags );
Ulrich Weigand61439d21998-12-24 15:12:20 +000093
Ulrich Weigande392a0c1999-04-01 11:44:52 +000094 WORD WINAPI (*UserSignalProc)( UINT uCode, DWORD dwThreadOrProcessID,
95 DWORD dwFlags, HMODULE16 hModule );
Ulrich Weigand98c30531999-07-27 17:10:06 +000096 void WINAPI (*FinalUserInit16)( void );
Ulrich Weigande392a0c1999-04-01 11:44:52 +000097
Ulrich Weigand73663071999-04-10 16:32:45 +000098 INT16 WINAPI (*InitApp16)( HINSTANCE16 hInst );
Alexandre Julliarda3960291999-02-26 11:11:13 +000099 HQUEUE16 WINAPI (*InitThreadInput16)( WORD unknown, WORD flags );
100 void WINAPI (*UserYield16)( void );
Ulrich Weigande5624531999-03-10 14:06:53 +0000101 WORD WINAPI (*DestroyIcon32)( HGLOBAL16 handle, UINT16 flags );
Peter Ganten6619f5a2000-01-01 22:38:20 +0000102 DWORD WINAPI (*WaitForInputIdle)( HANDLE hProcess, DWORD dwTimeOut );
Alexandre Julliardd6c0d862000-03-24 21:38:30 +0000103
104 INT WINAPI (*MessageBoxA)( HWND hWnd, LPCSTR text, LPCSTR title, UINT type );
105 INT WINAPI (*MessageBoxW)( HWND hwnd, LPCWSTR text, LPCWSTR title, UINT type );
Ulrich Weigand61439d21998-12-24 15:12:20 +0000106
107} CALLOUT_TABLE;
108
109extern CALLOUT_TABLE Callout;
110
Alexandre Julliardd6c0d862000-03-24 21:38:30 +0000111#include "pshpack1.h"
112
113typedef struct tagTHUNK
114{
115 BYTE popl_eax; /* 0x58 popl %eax (return address)*/
116 BYTE pushl_func; /* 0x68 pushl $proc */
117 FARPROC16 proc WINE_PACKED;
118 BYTE pushl_eax; /* 0x50 pushl %eax */
119 BYTE jmp; /* 0xe9 jmp relay (relative jump)*/
120 RELAY relay WINE_PACKED;
121 struct tagTHUNK *next WINE_PACKED;
122 DWORD magic;
123} THUNK;
124
125#include "poppack.h"
126
127#define CALLTO16_THUNK_MAGIC 0x54484e4b /* "THNK" */
128
129#define DECL_THUNK(aname,aproc,arelay) \
130 THUNK aname; \
131 aname.popl_eax = 0x58; \
132 aname.pushl_func = 0x68; \
133 aname.proc = (FARPROC) (aproc); \
134 aname.pushl_eax = 0x50; \
135 aname.jmp = 0xe9; \
136 aname.relay = (RELAY)((char *)(arelay) - (char *)(&(aname).next)); \
137 aname.next = NULL; \
138 aname.magic = CALLTO16_THUNK_MAGIC;
Ulrich Weigand61439d21998-12-24 15:12:20 +0000139
Alexandre Julliardf1aa3031996-08-05 17:42:43 +0000140#endif /* __WINE_CALLBACK_H */