2 * Function callbacks for the library
4 * Copyright 1997 Alexandre Julliard
15 /**********************************************************************
16 * CALLBACK_CallWndProc
18 static LRESULT WINAPI
CALLBACK_CallWndProc( WNDPROC16 proc
, HWND16 hwnd
,
19 UINT16 msg
, WPARAM16 wParam
,
22 return proc( hwnd
, msg
, wParam
, lParam
);
26 /**********************************************************************
27 * CALLBACK_CallRegisterProc
29 static LONG WINAPI
CALLBACK_CallRegisterProc( CONTEXT
*context
, INT32 offset
)
31 ERR(relay
, "Cannot call a register proc in Winelib\n" );
37 /**********************************************************************
38 * CALLBACK_CallDriverProc
40 static LRESULT WINAPI
CALLBACK_CallDriverProc( DRIVERPROC16 proc
, DWORD dwId
,
41 HDRVR16 hdrvr
, UINT16 msg
,
42 LPARAM lp1
, LPARAM lp2
)
44 return proc( dwId
, hdrvr
, msg
, lp1
, lp2
);
48 /**********************************************************************
49 * CALLBACK_CallDriverCallback
51 static LRESULT WINAPI
CALLBACK_CallDriverCallback( FARPROC16 proc
,
52 HANDLE16 hDev
, UINT16 msg
,
53 DWORD dwUser
, LPARAM lp1
,
56 return proc( hDev
, msg
, dwUser
, lp1
, lp2
);
60 /**********************************************************************
61 * CALLBACK_CallTimeFuncProc
63 static LRESULT WINAPI
CALLBACK_CallTimeFuncProc( FARPROC16 proc
, WORD id
,
64 UINT16 msg
, DWORD dwUser
,
65 LPARAM lp1
, LPARAM lp2
)
67 return proc( id
, msg
, dwUser
, lp1
, lp2
);
71 /**********************************************************************
72 * CALLBACK_CallWindowsExitProc
74 static INT16 WINAPI
CALLBACK_CallWindowsExitProc( FARPROC16 proc
, INT16 type
)
80 /**********************************************************************
81 * CALLBACK_CallWordBreakProc
83 static INT16 WINAPI
CALLBACK_CallWordBreakProc( EDITWORDBREAKPROC16 proc
,
84 SEGPTR text
, INT16 word
,
85 INT16 len
, INT16 action
)
87 return proc( (LPSTR
)text
, word
, len
, action
);
91 /**********************************************************************
92 * CALLBACK_CallBootAppProc
94 static void WINAPI
CALLBACK_CallBootAppProc( FARPROC16 proc
, HANDLE16 module
,
101 /**********************************************************************
102 * CALLBACK_CallLoadAppSegProc
104 static WORD WINAPI
CALLBACK_CallLoadAppSegProc( FARPROC16 proc
,
105 HANDLE16 module
, HFILE16 file
,
108 return proc( module
, file
, seg
);
112 /**********************************************************************
113 * CALLBACK_CallSystemTimerProc
115 static void WINAPI
CALLBACK_CallSystemTimerProc( FARPROC16 proc
)
120 /**********************************************************************
121 * CALLBACK_CallResourceHandlerProc
123 static HGLOBAL16 WINAPI
CALLBACK_CallResourceHandlerProc( FARPROC16 proc
,
128 return proc( hMemObj
, hModule
, hRsrc
);
132 /**********************************************************************
133 * CALLBACK_CallASPIPostProc
135 static LRESULT WINAPI
CALLBACK_CallASPIPostProc( FARPROC16 proc
, SEGPTR ptr
)
141 /**********************************************************************
142 * CALLBACK_CallWOWCallbackProc
144 static DWORD WINAPI
CALLBACK_CallWOWCallbackProc( FARPROC16 proc
, DWORD dw
)
149 /**********************************************************************
150 * CALLBACK_CallWOWCallback16Ex
152 * WCB16_MAX_CBARGS (16) is the maximum number of args.
154 * Can call functions using CDECL or PASCAL calling conventions. The CDECL
155 * ones are reversed (not 100% sure about that).
157 static BOOL32 WINAPI
CALLBACK_CallWOWCallback16Ex(
158 FARPROC16 proc
, DWORD dwFlags
, DWORD cbArgs
, LPVOID xargs
,LPDWORD pdwret
160 LPDWORD args
= (LPDWORD
)xargs
;
163 if (dwFlags
== WCB16_CDECL
) {
164 /* swap the arguments */
165 args
= HeapAlloc(GetProcessHeap(),0,cbArgs
*sizeof(DWORD
));
166 for (i
=0;i
<cbArgs
;i
++)
167 args
[i
] = ((DWORD
*)xargs
)[cbArgs
-i
-1];
170 case 0: ret
= proc();break;
171 case 1: ret
= proc(args
[0]);break;
172 case 2: ret
= proc(args
[0],args
[1]);break;
173 case 3: ret
= proc(args
[0],args
[1],args
[2]);break;
174 case 4: ret
= proc(args
[0],args
[1],args
[2],args
[3]);break;
175 case 5: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4]);break;
176 case 6: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5]);
178 case 7: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
182 case 8: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
186 case 9: ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
187 args
[6],args
[7],args
[8]
190 case 10:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
191 args
[6],args
[7],args
[8],args
[9]
194 case 11:ret
= proc(args
[0],args
[1],args
[2],args
[3],args
[4],args
[5],
195 args
[6],args
[7],args
[8],args
[9],args
[10]
198 case 12: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],args
[11]
202 case 13: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],
207 case 14: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 15: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],
214 args
[12],args
[13],args
[14]
217 case 16: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],args
[15]
223 WARN(relay
,"(%ld) arguments not supported.\n",cbArgs
);
224 if (dwFlags
== WCB16_CDECL
)
225 HeapFree(GetProcessHeap(),0,args
);
228 if (dwFlags
== WCB16_CDECL
)
229 HeapFree(GetProcessHeap(),0,args
);
235 /**********************************************************************
236 * CALLBACK_CallTaskRescheduleProc
238 static void WINAPI
CALLBACK_CallTaskRescheduleProc( void )
240 SYSLEVEL_EnterWin16Lock();
242 SYSLEVEL_LeaveWin16Lock();
246 /**********************************************************************
247 * CALLBACK_WinelibTable
249 * The callbacks function table for Winelib
251 static const CALLBACKS_TABLE CALLBACK_WinelibTable
=
253 CALLBACK_CallRegisterProc
, /* CallRegisterShortProc */
254 CALLBACK_CallRegisterProc
, /* CallRegisterLongProc */
255 CALLBACK_CallTaskRescheduleProc
, /* CallTaskRescheduleProc */
256 NULL
, /* CallFrom16WndProc */
257 CALLBACK_CallWndProc
, /* CallWndProc */
258 CALLBACK_CallDriverProc
, /* CallDriverProc */
259 CALLBACK_CallDriverCallback
, /* CallDriverCallback */
260 CALLBACK_CallTimeFuncProc
, /* CallTimeFuncProc */
261 CALLBACK_CallWindowsExitProc
, /* CallWindowsExitProc */
262 CALLBACK_CallWordBreakProc
, /* CallWordBreakProc */
263 CALLBACK_CallBootAppProc
, /* CallBootAppProc */
264 CALLBACK_CallLoadAppSegProc
, /* CallLoadAppSegProc */
265 CALLBACK_CallSystemTimerProc
, /* CallSystemTimerProc */
266 CALLBACK_CallResourceHandlerProc
, /* CallResourceHandlerProc */
267 NULL
, /* CallPostAppMessageProc */
268 CALLBACK_CallWOWCallbackProc
, /* CallWOWCallbackProc */
269 CALLBACK_CallWOWCallback16Ex
, /* CallWOWCallback16Ex */
270 CALLBACK_CallASPIPostProc
, /* CallASPIPostProc */
271 /* The graphics driver callbacks are never used in Winelib */
272 NULL
, /* CallDrvControlProc */
273 NULL
, /* CallDrvEnableProc */
274 NULL
, /* CallDrvEnumDFontsProc */
275 NULL
, /* CallDrvEnumObjProc */
276 NULL
, /* CallDrvOutputProc */
277 NULL
, /* CallDrvRealizeProc */
278 NULL
, /* CallDrvStretchBltProc */
279 NULL
, /* CallDrvExtTextOutProc */
280 NULL
, /* CallDrvGetCharWidth */
281 NULL
/* CallDrvAbortProc */
284 const CALLBACKS_TABLE
*Callbacks
= &CALLBACK_WinelibTable
;