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 ERR(relay
, "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
)
119 /**********************************************************************
120 * CALLBACK_CallResourceHandlerProc
122 static HGLOBAL16 WINAPI
CALLBACK_CallResourceHandlerProc( FARPROC16 proc
,
127 return proc( hMemObj
, hModule
, hRsrc
);
131 /**********************************************************************
132 * CALLBACK_CallASPIPostProc
134 static LRESULT WINAPI
CALLBACK_CallASPIPostProc( FARPROC16 proc
, SEGPTR ptr
)
140 /**********************************************************************
141 * CALLBACK_CallWOWCallbackProc
143 static DWORD WINAPI
CALLBACK_CallWOWCallbackProc( FARPROC16 proc
, DWORD dw
)
148 /**********************************************************************
149 * CALLBACK_CallWOWCallback16Ex
151 * WCB16_MAX_CBARGS (16) is the maximum number of args.
153 * Can call functions using CDECL or PASCAL calling conventions. The CDECL
154 * ones are reversed (not 100% sure about that).
156 static BOOL32 WINAPI
CALLBACK_CallWOWCallback16Ex(
157 FARPROC16 proc
, DWORD dwFlags
, DWORD cbArgs
, LPVOID xargs
,LPDWORD pdwret
159 LPDWORD args
= (LPDWORD
)xargs
;
162 if (dwFlags
== WCB16_CDECL
) {
163 /* swap the arguments */
164 args
= HeapAlloc(GetProcessHeap(),0,cbArgs
*sizeof(DWORD
));
165 for (i
=0;i
<cbArgs
;i
++)
166 args
[i
] = ((DWORD
*)xargs
)[cbArgs
-i
-1];
169 case 0: ret
= proc();break;
170 case 1: ret
= proc(args
[0]);break;
171 case 2: ret
= proc(args
[0],args
[1]);break;
172 case 3: ret
= proc(args
[0],args
[1],args
[2]);break;
173 case 4: ret
= proc(args
[0],args
[1],args
[2],args
[3]);break;
174 case 5: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4]);break;
175 case 6: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5]);
177 case 7: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
181 case 8: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
185 case 9: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
186 args
[6],args
[7],args
[8]
189 case 10:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
190 args
[6],args
[7],args
[8],args
[9]
193 case 11:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
194 args
[6],args
[7],args
[8],args
[9],args
[10]
197 case 12:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
198 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11]
201 case 13:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
202 args
[6],args
[7],args
[8],args
[9],args
[10],args
[11],
206 case 14: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 15: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],
213 args
[12],args
[13],args
[14]
216 case 16: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],args
[15]
222 WARN(relay
,"(%ld) arguments not supported.\n",cbArgs
);
223 if (dwFlags
== WCB16_CDECL
)
224 HeapFree(GetProcessHeap(),0,args
);
227 if (dwFlags
== WCB16_CDECL
)
228 HeapFree(GetProcessHeap(),0,args
);
234 /**********************************************************************
235 * CALLBACK_WinelibTable
237 * The callbacks function table for Winelib
239 static const CALLBACKS_TABLE CALLBACK_WinelibTable
=
241 CALLBACK_CallRegisterProc
, /* CallRegisterShortProc */
242 CALLBACK_CallRegisterProc
, /* CallRegisterLongProc */
243 TASK_Reschedule
, /* CallTaskRescheduleProc */
244 NULL
, /* CallFrom16WndProc */
245 CALLBACK_CallWndProc
, /* CallWndProc */
246 CALLBACK_CallDriverProc
, /* CallDriverProc */
247 CALLBACK_CallDriverCallback
, /* CallDriverCallback */
248 CALLBACK_CallTimeFuncProc
, /* CallTimeFuncProc */
249 CALLBACK_CallWindowsExitProc
, /* CallWindowsExitProc */
250 CALLBACK_CallWordBreakProc
, /* CallWordBreakProc */
251 CALLBACK_CallBootAppProc
, /* CallBootAppProc */
252 CALLBACK_CallLoadAppSegProc
, /* CallLoadAppSegProc */
253 CALLBACK_CallSystemTimerProc
, /* CallSystemTimerProc */
254 CALLBACK_CallResourceHandlerProc
, /* CallResourceHandlerProc */
255 CALLBACK_CallWOWCallbackProc
, /* CallWOWCallbackProc */
256 CALLBACK_CallWOWCallback16Ex
, /* CallWOWCallback16Ex */
257 CALLBACK_CallASPIPostProc
, /* CallASPIPostProc */
258 /* The graphics driver callbacks are never used in Winelib */
259 NULL
, /* CallDrvControlProc */
260 NULL
, /* CallDrvEnableProc */
261 NULL
, /* CallDrvEnumDFontsProc */
262 NULL
, /* CallDrvEnumObjProc */
263 NULL
, /* CallDrvOutputProc */
264 NULL
, /* CallDrvRealizeProc */
265 NULL
, /* CallDrvStretchBltProc */
266 NULL
, /* CallDrvExtTextOutProc */
267 NULL
/* CallDrvGetCharWidth */
270 const CALLBACKS_TABLE
*Callbacks
= &CALLBACK_WinelibTable
;