2 * Function callbacks for the library
4 * Copyright 1997 Alexandre Julliard
16 /**********************************************************************
17 * CALLBACK_CallWndProc
19 static LRESULT WINAPI
CALLBACK_CallWndProc( WNDPROC16 proc
, HWND16 hwnd
,
20 UINT16 msg
, WPARAM16 wParam
,
23 return proc( hwnd
, msg
, wParam
, lParam
);
27 /**********************************************************************
28 * CALLBACK_CallRegisterProc
30 static LONG WINAPI
CALLBACK_CallRegisterProc( CONTEXT
*context
, INT32 offset
)
32 ERR(relay
, "Cannot call a register proc in Winelib\n" );
38 /**********************************************************************
39 * CALLBACK_CallDriverProc
41 static LRESULT WINAPI
CALLBACK_CallDriverProc( DRIVERPROC16 proc
, DWORD dwId
,
42 HDRVR16 hdrvr
, UINT16 msg
,
43 LPARAM lp1
, LPARAM lp2
)
45 return proc( dwId
, hdrvr
, msg
, lp1
, lp2
);
49 /**********************************************************************
50 * CALLBACK_CallDriverCallback
52 static LRESULT WINAPI
CALLBACK_CallDriverCallback( FARPROC16 proc
,
53 HANDLE16 hDev
, UINT16 msg
,
54 DWORD dwUser
, LPARAM lp1
,
57 return proc( hDev
, msg
, dwUser
, lp1
, lp2
);
61 /**********************************************************************
62 * CALLBACK_CallTimeFuncProc
64 static LRESULT WINAPI
CALLBACK_CallTimeFuncProc( FARPROC16 proc
, WORD id
,
65 UINT16 msg
, DWORD dwUser
,
66 LPARAM lp1
, LPARAM lp2
)
68 return proc( id
, msg
, dwUser
, lp1
, lp2
);
72 /**********************************************************************
73 * CALLBACK_CallWindowsExitProc
75 static INT16 WINAPI
CALLBACK_CallWindowsExitProc( FARPROC16 proc
, INT16 type
)
81 /**********************************************************************
82 * CALLBACK_CallWordBreakProc
84 static INT16 WINAPI
CALLBACK_CallWordBreakProc( EDITWORDBREAKPROC16 proc
,
85 SEGPTR text
, INT16 word
,
86 INT16 len
, INT16 action
)
88 return proc( (LPSTR
)text
, word
, len
, action
);
92 /**********************************************************************
93 * CALLBACK_CallBootAppProc
95 static void WINAPI
CALLBACK_CallBootAppProc( FARPROC16 proc
, HANDLE16 module
,
102 /**********************************************************************
103 * CALLBACK_CallLoadAppSegProc
105 static WORD WINAPI
CALLBACK_CallLoadAppSegProc( FARPROC16 proc
,
106 HANDLE16 module
, HFILE16 file
,
109 return proc( module
, file
, seg
);
113 /**********************************************************************
114 * CALLBACK_CallLocalNotifyFunc
116 static WORD WINAPI
CALLBACK_CallLocalNotifyFunc( FARPROC16 proc
,
117 WORD wMsg
, HLOCAL16 hMem
,
120 return proc( wMsg
, hMem
, wArg
);
124 /**********************************************************************
125 * CALLBACK_CallResourceHandlerProc
127 static HGLOBAL16 WINAPI
CALLBACK_CallResourceHandlerProc( FARPROC16 proc
,
132 return proc( hMemObj
, hModule
, hRsrc
);
136 /**********************************************************************
137 * CALLBACK_CallASPIPostProc
139 static LRESULT WINAPI
CALLBACK_CallASPIPostProc( FARPROC16 proc
, SEGPTR ptr
)
145 /**********************************************************************
146 * CALLBACK_CallWOWCallbackProc
148 static DWORD WINAPI
CALLBACK_CallWOWCallbackProc( FARPROC16 proc
, DWORD dw
)
153 /**********************************************************************
154 * CALLBACK_CallWOWCallback16Ex
156 * WCB16_MAX_CBARGS (16) is the maximum number of args.
158 * Can call functions using CDECL or PASCAL calling conventions. The CDECL
159 * ones are reversed (not 100% sure about that).
161 static BOOL32 WINAPI
CALLBACK_CallWOWCallback16Ex(
162 FARPROC16 proc
, DWORD dwFlags
, DWORD cbArgs
, LPVOID xargs
,LPDWORD pdwret
164 LPDWORD args
= (LPDWORD
)xargs
;
167 if (dwFlags
== WCB16_CDECL
) {
168 /* swap the arguments */
169 args
= HeapAlloc(GetProcessHeap(),0,cbArgs
*sizeof(DWORD
));
170 for (i
=0;i
<cbArgs
;i
++)
171 args
[i
] = ((DWORD
*)xargs
)[cbArgs
-i
-1];
174 case 0: ret
= proc();break;
175 case 1: ret
= proc(args
[0]);break;
176 case 2: ret
= proc(args
[0],args
[1]);break;
177 case 3: ret
= proc(args
[0],args
[1],args
[2]);break;
178 case 4: ret
= proc(args
[0],args
[1],args
[2],args
[3]);break;
179 case 5: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4]);break;
180 case 6: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5]);
182 case 7: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
186 case 8: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
190 case 9: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
191 args
[6],args
[7],args
[8]
194 case 10:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
195 args
[6],args
[7],args
[8],args
[9]
198 case 11:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
199 args
[6],args
[7],args
[8],args
[9],args
[10]
202 case 12:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
203 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11]
206 case 13:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
207 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
211 case 14: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],args
[11],
216 case 15:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
217 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
218 args
[12],args
[13],args
[14]
221 case 16: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],
223 args
[12],args
[13],args
[14],args
[15]
227 WARN(relay
,"(%ld) arguments not supported.\n",cbArgs
);
228 if (dwFlags
== WCB16_CDECL
)
229 HeapFree(GetProcessHeap(),0,args
);
232 if (dwFlags
== WCB16_CDECL
)
233 HeapFree(GetProcessHeap(),0,args
);
239 /**********************************************************************
240 * CALLBACK_CallTaskRescheduleProc
242 static BOOL32 WINAPI
CALLBACK_CallTaskRescheduleProc( void )
246 SYSLEVEL_EnterWin16Lock();
247 pending
= TASK_Reschedule();
248 SYSLEVEL_LeaveWin16Lock();
254 /**********************************************************************
255 * CALLBACK_WinelibTable
257 * The callbacks function table for Winelib
259 static const CALLBACKS_TABLE CALLBACK_WinelibTable
=
261 CALLBACK_CallRegisterProc
, /* CallRegisterShortProc */
262 CALLBACK_CallRegisterProc
, /* CallRegisterLongProc */
263 CALLBACK_CallTaskRescheduleProc
, /* CallTaskRescheduleProc */
264 NULL
, /* CallFrom16WndProc */
265 CALLBACK_CallWndProc
, /* CallWndProc */
266 CALLBACK_CallDriverProc
, /* CallDriverProc */
267 CALLBACK_CallDriverCallback
, /* CallDriverCallback */
268 CALLBACK_CallTimeFuncProc
, /* CallTimeFuncProc */
269 CALLBACK_CallWindowsExitProc
, /* CallWindowsExitProc */
270 CALLBACK_CallWordBreakProc
, /* CallWordBreakProc */
271 CALLBACK_CallBootAppProc
, /* CallBootAppProc */
272 CALLBACK_CallLoadAppSegProc
, /* CallLoadAppSegProc */
273 CALLBACK_CallLocalNotifyFunc
, /* CallLocalNotifyFunc */
274 CALLBACK_CallResourceHandlerProc
, /* CallResourceHandlerProc */
275 CALLBACK_CallWOWCallbackProc
, /* CallWOWCallbackProc */
276 CALLBACK_CallWOWCallback16Ex
, /* CallWOWCallback16Ex */
277 CALLBACK_CallASPIPostProc
, /* CallASPIPostProc */
278 /* The graphics driver callbacks are never used in Winelib */
279 NULL
, /* CallDrvControlProc */
280 NULL
, /* CallDrvEnableProc */
281 NULL
, /* CallDrvEnumDFontsProc */
282 NULL
, /* CallDrvEnumObjProc */
283 NULL
, /* CallDrvOutputProc */
284 NULL
, /* CallDrvRealizeProc */
285 NULL
, /* CallDrvStretchBltProc */
286 NULL
, /* CallDrvExtTextOutProc */
287 NULL
, /* CallDrvGetCharWidth */
288 NULL
/* CallDrvAbortProc */
291 const CALLBACKS_TABLE
*Callbacks
= &CALLBACK_WinelibTable
;
294 /**********************************************************************
297 * The callout function table for Winelib
300 CALLOUT_TABLE Callout
=
302 PeekMessage16
, PeekMessage32A
, PeekMessage32W
,
303 GetMessage16
, GetMessage32A
, GetMessage32W
,
304 SendMessage16
, SendMessage32A
, SendMessage32W
,
305 PostMessage16
, PostMessage32A
, PostMessage32W
,
306 PostAppMessage16
, PostThreadMessage32A
, PostThreadMessage32W
,
307 TranslateMessage16
, TranslateMessage32
,
308 DispatchMessage16
, DispatchMessage32A
, DispatchMessage32W
,
309 RedrawWindow16
, RedrawWindow32
,