Release 950522
[wine.git] / if1632 / callback.c
blob2587ee6d5de3afd1270ded95b3f6813155abeee6
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 "stddebug.h"
14 #include "debug.h"
18 /**********************************************************************
19 * CallWindowProc (USER.122)
21 LONG CallWindowProc( WNDPROC func, HWND hwnd, WORD message,
22 WORD wParam, LONG lParam )
24 WND *wndPtr = WIN_FindWndPtr( hwnd );
26 if (!wndPtr) return 0;
27 SpyMessage(hwnd, message, wParam, lParam);
28 return CallWndProc( (FARPROC)func, wndPtr->hInstance,
29 hwnd, message, wParam, lParam );
33 /**********************************************************************
34 * Catch (KERNEL.55)
36 int Catch( LPCATCHBUF lpbuf )
38 STACK16FRAME *pFrame = CURRENT_STACK16;
40 dprintf_catch( stddeb, "Catch: buf=%p ss:sp=%04x:%04x\n",
41 lpbuf, IF1632_Saved16_ss, IF1632_Saved16_sp );
43 /* Note: we don't save the current ss, as the catch buffer is */
44 /* only 9 words long. Hopefully no one will have the silly */
45 /* idea to change the current stack before calling Throw()... */
47 lpbuf[0] = IF1632_Saved16_sp;
48 lpbuf[1] = LOWORD(IF1632_Saved32_esp);
49 lpbuf[2] = HIWORD(IF1632_Saved32_esp);
50 lpbuf[3] = pFrame->saved_ss;
51 lpbuf[4] = pFrame->saved_sp;
52 lpbuf[5] = pFrame->ds;
53 lpbuf[6] = pFrame->bp;
54 lpbuf[7] = pFrame->ip;
55 lpbuf[8] = pFrame->cs;
56 return 0;
60 /**********************************************************************
61 * Throw (KERNEL.56)
63 int Throw( LPCATCHBUF lpbuf, int retval )
65 STACK16FRAME *pFrame;
67 dprintf_catch( stddeb, "Throw: buf=%p val=%04x ss:sp=%04x:%04x\n",
68 lpbuf, retval, IF1632_Saved16_ss, IF1632_Saved16_sp );
70 IF1632_Saved16_sp = lpbuf[0] - sizeof(WORD);
71 IF1632_Saved32_esp = MAKELONG( lpbuf[1], lpbuf[2] );
72 pFrame = CURRENT_STACK16;
73 pFrame->saved_ss = lpbuf[3];
74 pFrame->saved_sp = lpbuf[4];
75 pFrame->ds = lpbuf[5];
76 pFrame->bp = lpbuf[6];
77 pFrame->ip = lpbuf[7];
78 pFrame->cs = lpbuf[8];
79 return retval;
83 #endif /* !WINELIB */