2 * Function callbacks for the library
4 * Copyright 1997 Alexandre Julliard
14 /**********************************************************************
15 * CALLBACK_CallWndProc
17 static LRESULT WINAPI
CALLBACK_CallWndProc( WNDPROC16 proc
, HWND16 hwnd
,
18 UINT16 msg
, WPARAM16 wParam
,
21 return proc( hwnd
, msg
, wParam
, lParam
);
25 /**********************************************************************
26 * CALLBACK_CallRegisterProc
28 static LONG WINAPI
CALLBACK_CallRegisterProc( CONTEXT
*context
, INT32 offset
)
30 fprintf( stderr
, "Cannot call a register proc in Winelib\n" );
36 /**********************************************************************
37 * CALLBACK_CallDriverProc
39 static LRESULT WINAPI
CALLBACK_CallDriverProc( DRIVERPROC16 proc
, DWORD dwId
,
40 HDRVR16 hdrvr
, UINT16 msg
,
41 LPARAM lp1
, LPARAM lp2
)
43 return proc( dwId
, hdrvr
, msg
, lp1
, lp2
);
47 /**********************************************************************
48 * CALLBACK_CallDriverCallback
50 static LRESULT WINAPI
CALLBACK_CallDriverCallback( FARPROC16 proc
,
51 HANDLE16 hDev
, UINT16 msg
,
52 DWORD dwUser
, LPARAM lp1
,
55 return proc( hDev
, msg
, dwUser
, lp1
, lp2
);
59 /**********************************************************************
60 * CALLBACK_CallTimeFuncProc
62 static LRESULT WINAPI
CALLBACK_CallTimeFuncProc( FARPROC16 proc
, WORD id
,
63 UINT16 msg
, DWORD dwUser
,
64 LPARAM lp1
, LPARAM lp2
)
66 return proc( id
, msg
, dwUser
, lp1
, lp2
);
70 /**********************************************************************
71 * CALLBACK_CallWindowsExitProc
73 static INT16 WINAPI
CALLBACK_CallWindowsExitProc( FARPROC16 proc
, INT16 type
)
79 /**********************************************************************
80 * CALLBACK_CallWordBreakProc
82 static INT16 WINAPI
CALLBACK_CallWordBreakProc( EDITWORDBREAKPROC16 proc
,
83 SEGPTR text
, INT16 word
,
84 INT16 len
, INT16 action
)
86 return proc( (LPSTR
)text
, word
, len
, action
);
90 /**********************************************************************
91 * CALLBACK_CallBootAppProc
93 static void WINAPI
CALLBACK_CallBootAppProc( FARPROC16 proc
, HANDLE16 module
,
100 /**********************************************************************
101 * CALLBACK_CallLoadAppSegProc
103 static WORD WINAPI
CALLBACK_CallLoadAppSegProc( FARPROC16 proc
,
104 HANDLE16 module
, HFILE16 file
,
107 return proc( module
, file
, seg
);
111 /**********************************************************************
112 * CALLBACK_CallSystemTimerProc
114 static void WINAPI
CALLBACK_CallSystemTimerProc( FARPROC16 proc
)
120 /**********************************************************************
121 * CALLBACK_CallASPIPostProc
123 static LRESULT WINAPI
CALLBACK_CallASPIPostProc( FARPROC16 proc
, SEGPTR ptr
)
129 /**********************************************************************
130 * CALLBACK_CallWOWCallbackProc
132 static DWORD WINAPI
CALLBACK_CallWOWCallbackProc( FARPROC16 proc
, DWORD dw
)
137 /**********************************************************************
138 * CALLBACK_CallWOWCallback16Ex
140 * WCB16_MAX_CBARGS (16) is the maximum number of args.
142 * Can call functions using CDECL or PASCAL calling conventions. The CDECL
143 * ones are reversed (not 100% sure about that).
145 static BOOL32 WINAPI
CALLBACK_CallWOWCallback16Ex(
146 FARPROC16 proc
, DWORD dwFlags
, DWORD cbArgs
, LPVOID xargs
,LPDWORD pdwret
148 LPDWORD args
= (LPDWORD
)xargs
;
151 if (dwFlags
== WCB16_CDECL
) {
152 /* swap the arguments */
153 args
= HeapAlloc(GetProcessHeap(),0,cbArgs
*sizeof(DWORD
));
154 for (i
=0;i
<cbArgs
;i
++)
155 args
[i
] = ((DWORD
*)xargs
)[cbArgs
-i
-1];
158 case 0: ret
= proc();break;
159 case 1: ret
= proc(args
[0]);break;
160 case 2: ret
= proc(args
[0],args
[1]);break;
161 case 3: ret
= proc(args
[0],args
[1],args
[2]);break;
162 case 4: ret
= proc(args
[0],args
[1],args
[2],args
[3]);break;
163 case 5: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4]);break;
164 case 6: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5]);
166 case 7: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
170 case 8: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
174 case 9: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
175 args
[6],args
[7],args
[8]
178 case 10:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
179 args
[6],args
[7],args
[8],args
[9]
182 case 11:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
183 args
[6],args
[7],args
[8],args
[9],args
[10]
186 case 12:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
187 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11]
190 case 13:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
191 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
195 case 14:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
196 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
200 case 15:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
201 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
202 args
[12],args
[13],args
[14]
205 case 16:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
206 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
207 args
[12],args
[13],args
[14],args
[15]
211 fprintf(stderr
,"CALLBACK_CallWOWCallback16Ex(), %ld arguments not supported.!n",cbArgs
);
212 if (dwFlags
== WCB16_CDECL
)
213 HeapFree(GetProcessHeap(),0,args
);
216 if (dwFlags
== WCB16_CDECL
)
217 HeapFree(GetProcessHeap(),0,args
);
223 /**********************************************************************
224 * CALLBACK_WinelibTable
226 * The callbacks function table for Winelib
228 static const CALLBACKS_TABLE CALLBACK_WinelibTable
=
230 CALLBACK_CallRegisterProc
, /* CallRegisterShortProc */
231 CALLBACK_CallRegisterProc
, /* CallRegisterLongProc */
232 TASK_Reschedule
, /* CallTaskRescheduleProc */
233 NULL
, /* CallFrom16WndProc */
234 CALLBACK_CallWndProc
, /* CallWndProc */
235 CALLBACK_CallDriverProc
, /* CallDriverProc */
236 CALLBACK_CallDriverCallback
, /* CallDriverCallback */
237 CALLBACK_CallTimeFuncProc
, /* CallTimeFuncProc */
238 CALLBACK_CallWindowsExitProc
, /* CallWindowsExitProc */
239 CALLBACK_CallWordBreakProc
, /* CallWordBreakProc */
240 CALLBACK_CallBootAppProc
, /* CallBootAppProc */
241 CALLBACK_CallLoadAppSegProc
, /* CallLoadAppSegProc */
242 CALLBACK_CallSystemTimerProc
, /* CallSystemTimerProc */
243 CALLBACK_CallWOWCallbackProc
, /* CallWOWCallbackProc */
244 CALLBACK_CallWOWCallback16Ex
, /* CallWOWCallback16Ex */
245 CALLBACK_CallASPIPostProc
, /* CallASPIPostProc */
246 /* The graphics driver callbacks are never used in Winelib */
247 NULL
, /* CallDrvControlProc */
248 NULL
, /* CallDrvEnableProc */
249 NULL
, /* CallDrvEnumDFontsProc */
250 NULL
, /* CallDrvEnumObjProc */
251 NULL
, /* CallDrvOutputProc */
252 NULL
, /* CallDrvRealizeProc */
253 NULL
, /* CallDrvStretchBltProc */
254 NULL
, /* CallDrvExtTextOutProc */
255 NULL
/* CallDrvGetCharWidth */
258 const CALLBACKS_TABLE
*Callbacks
= &CALLBACK_WinelibTable
;