Release 960114
[wine/gsoc-2012-control.git] / if1632 / callback.c
blob27d236c510a719da88f65e167b676f08da384255
1 #ifndef WINELIB
2 /*
3 static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
4 static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "windows.h"
10 #include "callback.h"
11 #include "stackframe.h"
12 #include "win.h"
13 #include "alias.h"
14 #include "relay32.h"
15 #include "stddebug.h"
16 #include "debug.h"
19 /**********************************************************************
20 * CallWindowProc (USER.122)
22 LONG CallWindowProc( WNDPROC func, HWND hwnd, WORD message,
23 WORD wParam, LONG lParam )
25 FUNCTIONALIAS *a;
26 WND *wndPtr = WIN_FindWndPtr( hwnd );
28 if (!wndPtr) return 0;
30 /* check if we have something better than 16 bit relays */
31 if(!ALIAS_UseAliases || !(a=ALIAS_LookupAlias((DWORD)func)) ||
32 (!a->wine && !a->win32))
33 return CallWndProc( (FARPROC)func, wndPtr->hInstance,
34 hwnd, message, wParam, lParam );
35 if(a->wine)
36 return ((LONG(*)(WORD,WORD,WORD,LONG))(a->wine))
37 (hwnd,message,wParam,lParam);
38 if(!a->win32)
39 fprintf(stderr,"Where is the Win32 callback?\n");
40 if (UsesLParamPtr(message))
41 return RELAY32_CallWindowProc(a->win32,hwnd,message,wParam,lParam ? PTR_SEG_TO_LIN(lParam): 0);
42 else
43 return RELAY32_CallWindowProc(a->win32,hwnd,message,wParam,lParam);
46 /**********************************************************************
47 * Catch (KERNEL.55)
49 int Catch( LPCATCHBUF lpbuf )
51 STACK16FRAME *pFrame = CURRENT_STACK16;
53 dprintf_catch( stddeb, "Catch: buf=%p ss:sp=%04x:%04x\n",
54 lpbuf, IF1632_Saved16_ss, IF1632_Saved16_sp );
56 /* Note: we don't save the current ss, as the catch buffer is */
57 /* only 9 words long. Hopefully no one will have the silly */
58 /* idea to change the current stack before calling Throw()... */
60 lpbuf[0] = IF1632_Saved16_sp;
61 lpbuf[1] = LOWORD(IF1632_Saved32_esp);
62 lpbuf[2] = HIWORD(IF1632_Saved32_esp);
63 lpbuf[3] = pFrame->saved_ss;
64 lpbuf[4] = pFrame->saved_sp;
65 lpbuf[5] = pFrame->ds;
66 lpbuf[6] = pFrame->bp;
67 lpbuf[7] = pFrame->ip;
68 lpbuf[8] = pFrame->cs;
69 return 0;
73 /**********************************************************************
74 * Throw (KERNEL.56)
76 int Throw( LPCATCHBUF lpbuf, int retval )
78 STACK16FRAME *pFrame;
80 dprintf_catch( stddeb, "Throw: buf=%p val=%04x ss:sp=%04x:%04x\n",
81 lpbuf, retval, IF1632_Saved16_ss, IF1632_Saved16_sp );
83 IF1632_Saved16_sp = lpbuf[0] - sizeof(WORD);
84 IF1632_Saved32_esp = MAKELONG( lpbuf[1], lpbuf[2] );
85 pFrame = CURRENT_STACK16;
86 pFrame->saved_ss = lpbuf[3];
87 pFrame->saved_sp = lpbuf[4];
88 pFrame->ds = lpbuf[5];
89 pFrame->bp = lpbuf[6];
90 pFrame->ip = lpbuf[7];
91 pFrame->cs = lpbuf[8];
92 pFrame->es = 0;
93 return retval;
97 #endif /* !WINELIB */