2 * Function callbacks for the library
4 * Copyright 1997 Alexandre Julliard
12 #include "cursoricon.h"
17 /**********************************************************************
18 * CALLBACK_CallWndProc
20 static LRESULT WINAPI
CALLBACK_CallWndProc( WNDPROC16 proc
, HWND16 hwnd
,
21 UINT16 msg
, WPARAM16 wParam
,
24 return proc( hwnd
, msg
, wParam
, lParam
);
28 /**********************************************************************
29 * CALLBACK_CallRegisterProc
31 static LONG WINAPI
CALLBACK_CallRegisterProc( CONTEXT
*context
, INT offset
)
33 ERR(relay
, "Cannot call a register proc in Winelib\n" );
39 /**********************************************************************
40 * CALLBACK_CallDriverProc
42 static LRESULT WINAPI
CALLBACK_CallDriverProc( DRIVERPROC16 proc
, DWORD dwId
,
43 HDRVR16 hdrvr
, UINT16 msg
,
44 LPARAM lp1
, LPARAM lp2
)
46 return proc( dwId
, hdrvr
, msg
, lp1
, lp2
);
50 /**********************************************************************
51 * CALLBACK_CallDriverCallback
53 static LRESULT WINAPI
CALLBACK_CallDriverCallback( FARPROC16 proc
,
54 HANDLE16 hDev
, UINT16 msg
,
55 DWORD dwUser
, LPARAM lp1
,
58 return proc( hDev
, msg
, dwUser
, lp1
, lp2
);
62 /**********************************************************************
63 * CALLBACK_CallTimeFuncProc
65 static LRESULT WINAPI
CALLBACK_CallTimeFuncProc( FARPROC16 proc
, WORD id
,
66 UINT16 msg
, DWORD dwUser
,
67 LPARAM lp1
, LPARAM lp2
)
69 return proc( id
, msg
, dwUser
, lp1
, lp2
);
73 /**********************************************************************
74 * CALLBACK_CallWindowsExitProc
76 static INT16 WINAPI
CALLBACK_CallWindowsExitProc( FARPROC16 proc
, INT16 type
)
82 /**********************************************************************
83 * CALLBACK_CallWordBreakProc
85 static INT16 WINAPI
CALLBACK_CallWordBreakProc( EDITWORDBREAKPROC16 proc
,
86 SEGPTR text
, INT16 word
,
87 INT16 len
, INT16 action
)
89 return proc( (LPSTR
)text
, word
, len
, action
);
93 /**********************************************************************
94 * CALLBACK_CallBootAppProc
96 static void WINAPI
CALLBACK_CallBootAppProc( FARPROC16 proc
, HANDLE16 module
,
103 /**********************************************************************
104 * CALLBACK_CallLoadAppSegProc
106 static WORD WINAPI
CALLBACK_CallLoadAppSegProc( FARPROC16 proc
,
107 HANDLE16 module
, HFILE16 file
,
110 return proc( module
, file
, seg
);
114 /**********************************************************************
115 * CALLBACK_CallLocalNotifyFunc
117 static WORD WINAPI
CALLBACK_CallLocalNotifyFunc( FARPROC16 proc
,
118 WORD wMsg
, HLOCAL16 hMem
,
121 return proc( wMsg
, hMem
, wArg
);
125 /**********************************************************************
126 * CALLBACK_CallResourceHandlerProc
128 static HGLOBAL16 WINAPI
CALLBACK_CallResourceHandlerProc( FARPROC16 proc
,
133 return proc( hMemObj
, hModule
, hRsrc
);
137 /**********************************************************************
138 * CALLBACK_CallASPIPostProc
140 static LRESULT WINAPI
CALLBACK_CallASPIPostProc( FARPROC16 proc
, SEGPTR ptr
)
146 /**********************************************************************
147 * CALLBACK_CallWOWCallbackProc
149 static DWORD WINAPI
CALLBACK_CallWOWCallbackProc( FARPROC16 proc
, DWORD dw
)
154 /**********************************************************************
155 * CALLBACK_CallWOWCallback16Ex
157 * WCB16_MAX_CBARGS (16) is the maximum number of args.
159 * Can call functions using CDECL or PASCAL calling conventions. The CDECL
160 * ones are reversed (not 100% sure about that).
162 static BOOL WINAPI
CALLBACK_CallWOWCallback16Ex(
163 FARPROC16 proc
, DWORD dwFlags
, DWORD cbArgs
, LPVOID xargs
,LPDWORD pdwret
165 LPDWORD args
= (LPDWORD
)xargs
;
168 if (dwFlags
== WCB16_CDECL
) {
169 /* swap the arguments */
170 args
= HeapAlloc(GetProcessHeap(),0,cbArgs
*sizeof(DWORD
));
171 for (i
=0;i
<cbArgs
;i
++)
172 args
[i
] = ((DWORD
*)xargs
)[cbArgs
-i
-1];
175 case 0: ret
= proc();break;
176 case 1: ret
= proc(args
[0]);break;
177 case 2: ret
= proc(args
[0],args
[1]);break;
178 case 3: ret
= proc(args
[0],args
[1],args
[2]);break;
179 case 4: ret
= proc(args
[0],args
[1],args
[2],args
[3]);break;
180 case 5: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4]);break;
181 case 6: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5]);
183 case 7: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
187 case 8: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
191 case 9: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
192 args
[6],args
[7],args
[8]
195 case 10:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
196 args
[6],args
[7],args
[8],args
[9]
199 case 11:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
200 args
[6],args
[7],args
[8],args
[9],args
[10]
203 case 12:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
204 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11]
207 case 13:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
208 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
212 case 14:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
213 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
217 case 15: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],
219 args
[12],args
[13],args
[14]
222 case 16:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
223 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
224 args
[12],args
[13],args
[14],args
[15]
228 WARN(relay
,"(%ld) arguments not supported.\n",cbArgs
);
229 if (dwFlags
== WCB16_CDECL
)
230 HeapFree(GetProcessHeap(),0,args
);
233 if (dwFlags
== WCB16_CDECL
)
234 HeapFree(GetProcessHeap(),0,args
);
240 /**********************************************************************
241 * CALLBACK_CallTaskRescheduleProc
243 static BOOL WINAPI
CALLBACK_CallTaskRescheduleProc( void )
247 SYSLEVEL_EnterWin16Lock();
248 pending
= TASK_Reschedule();
249 SYSLEVEL_LeaveWin16Lock();
255 /**********************************************************************
256 * CALLBACK_WinelibTable
258 * The callbacks function table for Winelib
260 static const CALLBACKS_TABLE CALLBACK_WinelibTable
=
262 CALLBACK_CallRegisterProc
, /* CallRegisterShortProc */
263 CALLBACK_CallRegisterProc
, /* CallRegisterLongProc */
264 CALLBACK_CallTaskRescheduleProc
, /* CallTaskRescheduleProc */
265 NULL
, /* CallFrom16WndProc */
266 CALLBACK_CallWndProc
, /* CallWndProc */
267 CALLBACK_CallDriverProc
, /* CallDriverProc */
268 CALLBACK_CallDriverCallback
, /* CallDriverCallback */
269 CALLBACK_CallTimeFuncProc
, /* CallTimeFuncProc */
270 CALLBACK_CallWindowsExitProc
, /* CallWindowsExitProc */
271 CALLBACK_CallWordBreakProc
, /* CallWordBreakProc */
272 CALLBACK_CallBootAppProc
, /* CallBootAppProc */
273 CALLBACK_CallLoadAppSegProc
, /* CallLoadAppSegProc */
274 CALLBACK_CallLocalNotifyFunc
, /* CallLocalNotifyFunc */
275 CALLBACK_CallResourceHandlerProc
, /* CallResourceHandlerProc */
276 CALLBACK_CallWOWCallbackProc
, /* CallWOWCallbackProc */
277 CALLBACK_CallWOWCallback16Ex
, /* CallWOWCallback16Ex */
278 CALLBACK_CallASPIPostProc
, /* CallASPIPostProc */
279 /* The graphics driver callbacks are never used in Winelib */
280 NULL
, /* CallDrvControlProc */
281 NULL
, /* CallDrvEnableProc */
282 NULL
, /* CallDrvEnumDFontsProc */
283 NULL
, /* CallDrvEnumObjProc */
284 NULL
, /* CallDrvOutputProc */
285 NULL
, /* CallDrvRealizeProc */
286 NULL
, /* CallDrvStretchBltProc */
287 NULL
, /* CallDrvExtTextOutProc */
288 NULL
, /* CallDrvGetCharWidth */
289 NULL
/* CallDrvAbortProc */
292 const CALLBACKS_TABLE
*Callbacks
= &CALLBACK_WinelibTable
;
295 /**********************************************************************
298 * The callout function table for Winelib
301 CALLOUT_TABLE Callout
=
303 PeekMessage16
, PeekMessageA
, PeekMessageW
,
304 GetMessage16
, GetMessageA
, GetMessageW
,
305 SendMessage16
, SendMessageA
, SendMessageW
,
306 PostMessage16
, PostMessageA
, PostMessageW
,
307 PostAppMessage16
, PostThreadMessageA
, PostThreadMessageW
,
308 TranslateMessage16
, TranslateMessage
,
309 DispatchMessage16
, DispatchMessageA
, DispatchMessageW
,
310 RedrawWindow16
, RedrawWindow
,