2 * Function callbacks for the library
4 * Copyright 1997 Alexandre Julliard
12 #include "cursoricon.h"
18 DEFAULT_DEBUG_CHANNEL(relay)
21 /**********************************************************************
22 * CALLBACK_CallWndProc
24 static LRESULT WINAPI CALLBACK_CallWndProc( WNDPROC16 proc, HWND16 hwnd,
25 UINT16 msg, WPARAM16 wParam,
31 /* To avoid any deadlocks, all the locks on the windows structures
32 must be suspended before the control is passed to the application */
33 iWndsLocks = WIN_SuspendWndsLock();
34 retvalue = proc( hwnd, msg, wParam, lParam );
35 WIN_RestoreWndsLock(iWndsLocks);
40 /**********************************************************************
41 * CALLBACK_CallRegisterProc
43 static LONG WINAPI CALLBACK_CallRegisterProc( CONTEXT *context, INT offset)
45 ERR(relay, "Cannot call a register proc in Winelib\n" );
51 /**********************************************************************
52 * CALLBACK_CallDriverProc
54 static LRESULT WINAPI CALLBACK_CallDriverProc( DRIVERPROC16 proc, DWORD dwId,
55 HDRVR16 hdrvr, UINT16 msg,
56 LPARAM lp1, LPARAM lp2 )
58 return proc( dwId, hdrvr, msg, lp1, lp2 );
62 /**********************************************************************
63 * CALLBACK_CallDriverCallback
65 static LRESULT WINAPI CALLBACK_CallDriverCallback( FARPROC16 proc,
66 HANDLE16 hDev, UINT16 msg,
67 DWORD dwUser, LPARAM lp1,
70 return proc( hDev, msg, dwUser, lp1, lp2 );
74 /**********************************************************************
75 * CALLBACK_CallTimeFuncProc
77 static LRESULT WINAPI CALLBACK_CallTimeFuncProc( FARPROC16 proc, WORD id,
78 UINT16 msg, DWORD dwUser,
79 LPARAM lp1, LPARAM lp2 )
81 return proc( id, msg, dwUser, lp1, lp2 );
85 /**********************************************************************
86 * CALLBACK_CallWindowsExitProc
88 static INT16 WINAPI CALLBACK_CallWindowsExitProc( FARPROC16 proc, INT16 type)
94 /**********************************************************************
95 * CALLBACK_CallWordBreakProc
97 static INT16 WINAPI CALLBACK_CallWordBreakProc( EDITWORDBREAKPROC16 proc,
98 SEGPTR text, INT16 word,
99 INT16 len, INT16 action )
101 return proc( (LPSTR)text, word, len, action );
105 /**********************************************************************
106 * CALLBACK_CallBootAppProc
108 static void WINAPI CALLBACK_CallBootAppProc( FARPROC16 proc, HANDLE16 module,
111 proc( module, file );
115 /**********************************************************************
116 * CALLBACK_CallLoadAppSegProc
118 static WORD WINAPI CALLBACK_CallLoadAppSegProc( FARPROC16 proc,
119 HANDLE16 module, HFILE16 file,
122 return proc( module, file, seg );
126 /**********************************************************************
127 * CALLBACK_CallLocalNotifyFunc
129 static WORD WINAPI CALLBACK_CallLocalNotifyFunc( FARPROC16 proc,
130 WORD wMsg, HLOCAL16 hMem,
133 return proc( wMsg, hMem, wArg );
137 /**********************************************************************
138 * CALLBACK_CallResourceHandlerProc
140 static HGLOBAL16 WINAPI CALLBACK_CallResourceHandlerProc( FARPROC16 proc,
145 ERR( relay, "Cannot call a 16-bit resource handler in Winelib\n" );
151 /**********************************************************************
152 * CALLBACK_CallASPIPostProc
154 static LRESULT WINAPI CALLBACK_CallASPIPostProc( FARPROC16 proc, SEGPTR ptr )
160 /**********************************************************************
161 * CALLBACK_CallWOWCallbackProc
163 static DWORD WINAPI CALLBACK_CallWOWCallbackProc( FARPROC16 proc, DWORD dw )
168 /**********************************************************************
169 * CALLBACK_CallWOWCallback16Ex
171 * WCB16_MAX_CBARGS (16) is the maximum number of args.
173 * Can call functions using CDECL or PASCAL calling conventions. The CDECL
174 * ones are reversed (not 100% sure about that).
176 static BOOL WINAPI CALLBACK_CallWOWCallback16Ex(
177 FARPROC16 proc, DWORD dwFlags, DWORD cbArgs, LPVOID xargs,LPDWORD pdwret
179 LPDWORD args = (LPDWORD)xargs;
182 if (dwFlags == WCB16_CDECL) {
183 /* swap the arguments */
184 args = HeapAlloc(GetProcessHeap(),0,cbArgs*sizeof(DWORD));
185 for (i=0;i<cbArgs;i++)
186 args[i] = ((DWORD*)xargs)[cbArgs-i-1];
189 case 0: ret = proc();break;
190 case 1: ret = proc(args[0]);break;
191 case 2: ret = proc(args[0],args[1]);break;
192 case 3: ret = proc(args[0],args[1],args[2]);break;
193 case 4: ret = proc(args[0],args[1],args[2],args[3]);break;
194 case 5: ret = proc(args[0],args[1],args[2],args[3],args[4]);break;
195 case 6: ret = proc(args[0],args[1],args[2],args[3],args[4],args[5]);
197 case 7: ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
201 case 8: ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
205 case 9: ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
206 args[6],args[7],args[8]
209 case 10:ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
210 args[6],args[7],args[8],args[9]
213 case 11:ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
214 args[6],args[7],args[8],args[9],args[10]
217 case 12:ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
218 args[6],args[7],args[8],args[9],args[10],args[11]
221 case 13:ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
222 args[6],args[7],args[8],args[9],args[10],args[11],
226 case 14:ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
227 args[6],args[7],args[8],args[9],args[10],args[11],
231 case 15:ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
232 args[6],args[7],args[8],args[9],args[10],args[11],
233 args[12],args[13],args[14]
236 case 16:ret = proc(args[0],args[1],args[2],args[3],args[4],args[5],
237 args[6],args[7],args[8],args[9],args[10],args[11],
238 args[12],args[13],args[14],args[15]
242 WARN(relay,"(%ld) arguments not supported.\n",cbArgs);
243 if (dwFlags == WCB16_CDECL)
244 HeapFree(GetProcessHeap(),0,args);
247 if (dwFlags == WCB16_CDECL)
248 HeapFree(GetProcessHeap(),0,args);
254 /**********************************************************************
255 * CALLBACK_CallUTProc
257 static DWORD WINAPI CALLBACK_CallUTProc( FARPROC16 proc, DWORD w1, DWORD w2 )
259 ERR( relay, "Cannot call a UT thunk proc in Winelib\n" );
264 /**********************************************************************
265 * CALLBACK_CallTaskRescheduleProc
267 static BOOL WINAPI CALLBACK_CallTaskRescheduleProc( void )
271 SYSLEVEL_EnterWin16Lock();
272 pending = TASK_Reschedule();
273 SYSLEVEL_LeaveWin16Lock();
279 /**********************************************************************
280 * CALLBACK_WinelibTable
282 * The callbacks function table for Winelib
284 static const CALLBACKS_TABLE CALLBACK_WinelibTable =
286 CALLBACK_CallRegisterProc, /* CallRegisterShortProc */
287 CALLBACK_CallRegisterProc, /* CallRegisterLongProc */
288 CALLBACK_CallTaskRescheduleProc, /* CallTaskRescheduleProc */
289 NULL, /* CallFrom16WndProc */
290 CALLBACK_CallWndProc, /* CallWndProc */
291 CALLBACK_CallDriverProc, /* CallDriverProc */
292 CALLBACK_CallDriverCallback, /* CallDriverCallback */
293 CALLBACK_CallTimeFuncProc, /* CallTimeFuncProc */
294 CALLBACK_CallWindowsExitProc, /* CallWindowsExitProc */
295 CALLBACK_CallWordBreakProc, /* CallWordBreakProc */
296 CALLBACK_CallBootAppProc, /* CallBootAppProc */
297 CALLBACK_CallLoadAppSegProc, /* CallLoadAppSegProc */
298 CALLBACK_CallLocalNotifyFunc, /* CallLocalNotifyFunc */
299 CALLBACK_CallResourceHandlerProc, /* CallResourceHandlerProc */
300 CALLBACK_CallWOWCallbackProc, /* CallWOWCallbackProc */
301 CALLBACK_CallWOWCallback16Ex, /* CallWOWCallback16Ex */
302 CALLBACK_CallUTProc, /* CallUTProc */
303 CALLBACK_CallASPIPostProc, /* CallASPIPostProc */
304 /* The graphics driver callbacks are never used in Winelib */
305 NULL, /* CallDrvControlProc */
306 NULL, /* CallDrvEnableProc */
307 NULL, /* CallDrvEnumDFontsProc */
308 NULL, /* CallDrvEnumObjProc */
309 NULL, /* CallDrvOutputProc */
310 NULL, /* CallDrvRealizeProc */
311 NULL, /* CallDrvStretchBltProc */
312 NULL, /* CallDrvExtTextOutProc */
313 NULL, /* CallDrvGetCharWidth */
314 NULL /* CallDrvAbortProc */
317 const CALLBACKS_TABLE *Callbacks = &CALLBACK_WinelibTable;
320 /**********************************************************************
323 * The callout function table for Winelib
326 CALLOUT_TABLE Callout =
328 PeekMessage16, PeekMessageA, PeekMessageW,
329 GetMessage16, GetMessageA, GetMessageW,
330 SendMessage16, SendMessageA, SendMessageW,
331 PostMessage16, PostMessageA, PostMessageW,
332 PostAppMessage16, PostThreadMessageA, PostThreadMessageW,
333 TranslateMessage16, TranslateMessage,
334 DispatchMessage16, DispatchMessageA, DispatchMessageW,
335 RedrawWindow16, RedrawWindow,
337 InitApp16, InitThreadInput16,