2 * Function callbacks for the library
4 * Copyright 1997 Alexandre Julliard
12 #include "cursoricon.h"
19 /**********************************************************************
20 * CALLBACK_CallWndProc
22 static LRESULT WINAPI
CALLBACK_CallWndProc( WNDPROC16 proc
, HWND16 hwnd
,
23 UINT16 msg
, WPARAM16 wParam
,
29 /* To avoid any deadlocks, all the locks on the windows structures
30 must be suspended before the control is passed to the application */
31 iWndsLocks
= WIN_SuspendWndsLock();
32 retvalue
= proc( hwnd
, msg
, wParam
, lParam
);
33 WIN_RestoreWndsLock(iWndsLocks
);
38 /**********************************************************************
39 * CALLBACK_CallRegisterProc
41 static LONG WINAPI
CALLBACK_CallRegisterProc( CONTEXT
*context
, INT offset
)
43 ERR(relay
, "Cannot call a register proc in Winelib\n" );
49 /**********************************************************************
50 * CALLBACK_CallDriverProc
52 static LRESULT WINAPI
CALLBACK_CallDriverProc( DRIVERPROC16 proc
, DWORD dwId
,
53 HDRVR16 hdrvr
, UINT16 msg
,
54 LPARAM lp1
, LPARAM lp2
)
56 return proc( dwId
, hdrvr
, msg
, lp1
, lp2
);
60 /**********************************************************************
61 * CALLBACK_CallDriverCallback
63 static LRESULT WINAPI
CALLBACK_CallDriverCallback( FARPROC16 proc
,
64 HANDLE16 hDev
, UINT16 msg
,
65 DWORD dwUser
, LPARAM lp1
,
68 return proc( hDev
, msg
, dwUser
, lp1
, lp2
);
72 /**********************************************************************
73 * CALLBACK_CallTimeFuncProc
75 static LRESULT WINAPI
CALLBACK_CallTimeFuncProc( FARPROC16 proc
, WORD id
,
76 UINT16 msg
, DWORD dwUser
,
77 LPARAM lp1
, LPARAM lp2
)
79 return proc( id
, msg
, dwUser
, lp1
, lp2
);
83 /**********************************************************************
84 * CALLBACK_CallWindowsExitProc
86 static INT16 WINAPI
CALLBACK_CallWindowsExitProc( FARPROC16 proc
, INT16 type
)
92 /**********************************************************************
93 * CALLBACK_CallWordBreakProc
95 static INT16 WINAPI
CALLBACK_CallWordBreakProc( EDITWORDBREAKPROC16 proc
,
96 SEGPTR text
, INT16 word
,
97 INT16 len
, INT16 action
)
99 return proc( (LPSTR
)text
, word
, len
, action
);
103 /**********************************************************************
104 * CALLBACK_CallBootAppProc
106 static void WINAPI
CALLBACK_CallBootAppProc( FARPROC16 proc
, HANDLE16 module
,
109 proc( module
, file
);
113 /**********************************************************************
114 * CALLBACK_CallLoadAppSegProc
116 static WORD WINAPI
CALLBACK_CallLoadAppSegProc( FARPROC16 proc
,
117 HANDLE16 module
, HFILE16 file
,
120 return proc( module
, file
, seg
);
124 /**********************************************************************
125 * CALLBACK_CallLocalNotifyFunc
127 static WORD WINAPI
CALLBACK_CallLocalNotifyFunc( FARPROC16 proc
,
128 WORD wMsg
, HLOCAL16 hMem
,
131 return proc( wMsg
, hMem
, wArg
);
135 /**********************************************************************
136 * CALLBACK_CallResourceHandlerProc
138 static HGLOBAL16 WINAPI
CALLBACK_CallResourceHandlerProc( FARPROC16 proc
,
143 ERR( relay
, "Cannot call a 16-bit resource handler in Winelib\n" );
149 /**********************************************************************
150 * CALLBACK_CallASPIPostProc
152 static LRESULT WINAPI
CALLBACK_CallASPIPostProc( FARPROC16 proc
, SEGPTR ptr
)
158 /**********************************************************************
159 * CALLBACK_CallWOWCallbackProc
161 static DWORD WINAPI
CALLBACK_CallWOWCallbackProc( FARPROC16 proc
, DWORD dw
)
166 /**********************************************************************
167 * CALLBACK_CallWOWCallback16Ex
169 * WCB16_MAX_CBARGS (16) is the maximum number of args.
171 * Can call functions using CDECL or PASCAL calling conventions. The CDECL
172 * ones are reversed (not 100% sure about that).
174 static BOOL WINAPI
CALLBACK_CallWOWCallback16Ex(
175 FARPROC16 proc
, DWORD dwFlags
, DWORD cbArgs
, LPVOID xargs
,LPDWORD pdwret
177 LPDWORD args
= (LPDWORD
)xargs
;
180 if (dwFlags
== WCB16_CDECL
) {
181 /* swap the arguments */
182 args
= HeapAlloc(GetProcessHeap(),0,cbArgs
*sizeof(DWORD
));
183 for (i
=0;i
<cbArgs
;i
++)
184 args
[i
] = ((DWORD
*)xargs
)[cbArgs
-i
-1];
187 case 0: ret
= proc();break;
188 case 1: ret
= proc(args
[0]);break;
189 case 2: ret
= proc(args
[0],args
[1]);break;
190 case 3: ret
= proc(args
[0],args
[1],args
[2]);break;
191 case 4: ret
= proc(args
[0],args
[1],args
[2],args
[3]);break;
192 case 5: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4]);break;
193 case 6: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5]);
195 case 7: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
199 case 8: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
203 case 9: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
204 args
[6],args
[7],args
[8]
207 case 10:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
208 args
[6],args
[7],args
[8],args
[9]
211 case 11:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
212 args
[6],args
[7],args
[8],args
[9],args
[10]
215 case 12:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
216 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11]
219 case 13:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
220 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
224 case 14:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
225 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
229 case 15:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
230 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
231 args
[12],args
[13],args
[14]
234 case 16:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
235 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
236 args
[12],args
[13],args
[14],args
[15]
240 WARN(relay
,"(%ld) arguments not supported.\n",cbArgs
);
241 if (dwFlags
== WCB16_CDECL
)
242 HeapFree(GetProcessHeap(),0,args
);
245 if (dwFlags
== WCB16_CDECL
)
246 HeapFree(GetProcessHeap(),0,args
);
252 /**********************************************************************
253 * CALLBACK_CallUTProc
255 static DWORD WINAPI
CALLBACK_CallUTProc( FARPROC16 proc
, DWORD w1
, DWORD w2
)
257 ERR( relay
, "Cannot call a UT thunk proc in Winelib\n" );
262 /**********************************************************************
263 * CALLBACK_CallTaskRescheduleProc
265 static BOOL WINAPI
CALLBACK_CallTaskRescheduleProc( void )
269 SYSLEVEL_EnterWin16Lock();
270 pending
= TASK_Reschedule();
271 SYSLEVEL_LeaveWin16Lock();
277 /**********************************************************************
278 * CALLBACK_WinelibTable
280 * The callbacks function table for Winelib
282 static const CALLBACKS_TABLE CALLBACK_WinelibTable
=
284 CALLBACK_CallRegisterProc
, /* CallRegisterShortProc */
285 CALLBACK_CallRegisterProc
, /* CallRegisterLongProc */
286 CALLBACK_CallTaskRescheduleProc
, /* CallTaskRescheduleProc */
287 NULL
, /* CallFrom16WndProc */
288 CALLBACK_CallWndProc
, /* CallWndProc */
289 CALLBACK_CallDriverProc
, /* CallDriverProc */
290 CALLBACK_CallDriverCallback
, /* CallDriverCallback */
291 CALLBACK_CallTimeFuncProc
, /* CallTimeFuncProc */
292 CALLBACK_CallWindowsExitProc
, /* CallWindowsExitProc */
293 CALLBACK_CallWordBreakProc
, /* CallWordBreakProc */
294 CALLBACK_CallBootAppProc
, /* CallBootAppProc */
295 CALLBACK_CallLoadAppSegProc
, /* CallLoadAppSegProc */
296 CALLBACK_CallLocalNotifyFunc
, /* CallLocalNotifyFunc */
297 CALLBACK_CallResourceHandlerProc
, /* CallResourceHandlerProc */
298 CALLBACK_CallWOWCallbackProc
, /* CallWOWCallbackProc */
299 CALLBACK_CallWOWCallback16Ex
, /* CallWOWCallback16Ex */
300 CALLBACK_CallUTProc
, /* CallUTProc */
301 CALLBACK_CallASPIPostProc
, /* CallASPIPostProc */
302 /* The graphics driver callbacks are never used in Winelib */
303 NULL
, /* CallDrvControlProc */
304 NULL
, /* CallDrvEnableProc */
305 NULL
, /* CallDrvEnumDFontsProc */
306 NULL
, /* CallDrvEnumObjProc */
307 NULL
, /* CallDrvOutputProc */
308 NULL
, /* CallDrvRealizeProc */
309 NULL
, /* CallDrvStretchBltProc */
310 NULL
, /* CallDrvExtTextOutProc */
311 NULL
, /* CallDrvGetCharWidth */
312 NULL
/* CallDrvAbortProc */
315 const CALLBACKS_TABLE
*Callbacks
= &CALLBACK_WinelibTable
;
318 /**********************************************************************
321 * The callout function table for Winelib
324 CALLOUT_TABLE Callout
=
326 PeekMessage16
, PeekMessageA
, PeekMessageW
,
327 GetMessage16
, GetMessageA
, GetMessageW
,
328 SendMessage16
, SendMessageA
, SendMessageW
,
329 PostMessage16
, PostMessageA
, PostMessageW
,
330 PostAppMessage16
, PostThreadMessageA
, PostThreadMessageW
,
331 TranslateMessage16
, TranslateMessage
,
332 DispatchMessage16
, DispatchMessageA
, DispatchMessageW
,
333 RedrawWindow16
, RedrawWindow
,