Release 950606
[wine] / if1632 / callback.c
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 */
6
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"
15
16
17
18 /**********************************************************************
19  *           CallWindowProc    (USER.122)
20  */
21 LONG CallWindowProc( WNDPROC func, HWND hwnd, WORD message,
22                      WORD wParam, LONG lParam )
23 {
24     WND *wndPtr = WIN_FindWndPtr( hwnd );
25
26     if (!wndPtr) return 0;
27     SpyMessage(hwnd, message, wParam, lParam);
28     return CallWndProc( (FARPROC)func, wndPtr->hInstance, 
29                         hwnd, message, wParam, lParam );
30 }
31
32
33 /**********************************************************************
34  *           Catch    (KERNEL.55)
35  */
36 int Catch( LPCATCHBUF lpbuf )
37 {
38     STACK16FRAME *pFrame = CURRENT_STACK16;
39
40     dprintf_catch( stddeb, "Catch: buf=%p ss:sp=%04x:%04x\n",
41                    lpbuf, IF1632_Saved16_ss, IF1632_Saved16_sp );
42
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()... */
46
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;
57 }
58
59
60 /**********************************************************************
61  *           Throw    (KERNEL.56)
62  */
63 int Throw( LPCATCHBUF lpbuf, int retval )
64 {
65     STACK16FRAME *pFrame;
66
67     dprintf_catch( stddeb, "Throw: buf=%p val=%04x ss:sp=%04x:%04x\n",
68                    lpbuf, retval, IF1632_Saved16_ss, IF1632_Saved16_sp );
69
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;
80 }
81
82
83 #endif /* !WINELIB */