/* * Function callbacks for the library * * Copyright 1997 Alexandre Julliard */ #include #include "winuser.h" #include "callback.h" #include "task.h" #include "syslevel.h" #include "cursoricon.h" #include "user.h" #include "queue.h" #include "debugtools.h" #include "win.h" DEFAULT_DEBUG_CHANNEL(relay) /********************************************************************** * CALLBACK_CallWndProc */ static LRESULT WINAPI CALLBACK_CallWndProc( WNDPROC16 proc, HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam ) { LRESULT retvalue; int iWndsLocks; /* To avoid any deadlocks, all the locks on the windows structures must be suspended before the control is passed to the application */ iWndsLocks = WIN_SuspendWndsLock(); retvalue = proc( hwnd, msg, wParam, lParam ); WIN_RestoreWndsLock(iWndsLocks); return retvalue; } /********************************************************************** * CALLBACK_CallRegisterProc */ static LONG WINAPI CALLBACK_CallRegisterProc( CONTEXT86 *context, INT offset) { ERR("Cannot call a register proc in Winelib\n" ); assert( FALSE ); return 0; } /********************************************************************** * CALLBACK_CallDriverProc */ static LRESULT WINAPI CALLBACK_CallDriverProc( DRIVERPROC16 proc, DWORD dwId, HDRVR16 hdrvr, UINT16 msg, LPARAM lp1, LPARAM lp2 ) { return proc( dwId, hdrvr, msg, lp1, lp2 ); } /********************************************************************** * CALLBACK_CallDriverCallback */ static LRESULT WINAPI CALLBACK_CallDriverCallback( FARPROC16 proc, HANDLE16 hDev, UINT16 msg, DWORD dwUser, LPARAM lp1, LPARAM lp2 ) { return proc( hDev, msg, dwUser, lp1, lp2 ); } /********************************************************************** * CALLBACK_CallTimeFuncProc */ static LRESULT WINAPI CALLBACK_CallTimeFuncProc( FARPROC16 proc, WORD id, UINT16 msg, DWORD dwUser, LPARAM lp1, LPARAM lp2 ) { return proc( id, msg, dwUser, lp1, lp2 ); } /********************************************************************** * CALLBACK_CallWindowsExitProc */ static INT16 WINAPI CALLBACK_CallWindowsExitProc( FARPROC16 proc, INT16 type) { return proc( type ); } /********************************************************************** * CALLBACK_CallWordBreakProc */ static INT16 WINAPI CALLBACK_CallWordBreakProc( EDITWORDBREAKPROC16 proc, SEGPTR text, INT16 word, INT16 len, INT16 action ) { return proc( (LPSTR)text, word, len, action ); } /********************************************************************** * CALLBACK_CallBootAppProc */ static void WINAPI CALLBACK_CallBootAppProc( FARPROC16 proc, HANDLE16 module, HFILE16 file ) { proc( module, file ); } /********************************************************************** * CALLBACK_CallLoadAppSegProc */ static WORD WINAPI CALLBACK_CallLoadAppSegProc( FARPROC16 proc, HANDLE16 module, HFILE16 file, WORD seg ) { return proc( module, file, seg ); } /********************************************************************** * CALLBACK_CallLocalNotifyFunc */ static WORD WINAPI CALLBACK_CallLocalNotifyFunc( FARPROC16 proc, WORD wMsg, HLOCAL16 hMem, WORD wArg ) { return proc( wMsg, hMem, wArg ); } /********************************************************************** * CALLBACK_CallResourceHandlerProc */ static HGLOBAL16 WINAPI CALLBACK_CallResourceHandlerProc( FARPROC16 proc, HGLOBAL16 hMemObj, HMODULE16 hModule, HRSRC16 hRsrc ) { ERR("Cannot call a 16-bit resource handler in Winelib\n" ); assert( FALSE ); return 0; } /********************************************************************** * CALLBACK_CallASPIPostProc */ static LRESULT WINAPI CALLBACK_CallASPIPostProc( FARPROC16 proc, SEGPTR ptr ) { return proc( ptr ); } /********************************************************************** * CALLBACK_CallWOWCallbackProc */ static DWORD WINAPI CALLBACK_CallWOWCallbackProc( FARPROC16 proc, DWORD dw ) { return proc( dw ); } /********************************************************************** * CALLBACK_CallWOWCallback16Ex * * WCB16_MAX_CBARGS (16) is the maximum number of args. * * Can call functions using CDECL or PASCAL calling conventions. The CDECL * ones are reversed (not 100% sure about that). */ static BOOL WINAPI CALLBACK_CallWOWCallback16Ex( FARPROC16 proc, DWORD dwFlags, DWORD cbArgs, LPVOID xargs,LPDWORD pdwret ) { LPDWORD args = (LPDWORD)xargs; DWORD ret,i; if (dwFlags == WCB16_CDECL) { /* swap the arguments */ args = HeapAlloc(GetProcessHeap(),0,cbArgs*sizeof(DWORD)); for (i=0;i