Release 951003
[wine/hacks.git] / if1632 / callback.c
blob2d6a742d150bd9814b9a8aab8a011f0513411f14
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 return RELAY32_CallWindowProc(a->win32,hwnd,message,wParam,lParam);
44 /**********************************************************************
45 * Catch (KERNEL.55)
47 int Catch( LPCATCHBUF lpbuf )
49 STACK16FRAME *pFrame = CURRENT_STACK16;
51 dprintf_catch( stddeb, "Catch: buf=%p ss:sp=%04x:%04x\n",
52 lpbuf, IF1632_Saved16_ss, IF1632_Saved16_sp );
54 /* Note: we don't save the current ss, as the catch buffer is */
55 /* only 9 words long. Hopefully no one will have the silly */
56 /* idea to change the current stack before calling Throw()... */
58 lpbuf[0] = IF1632_Saved16_sp;
59 lpbuf[1] = LOWORD(IF1632_Saved32_esp);
60 lpbuf[2] = HIWORD(IF1632_Saved32_esp);
61 lpbuf[3] = pFrame->saved_ss;
62 lpbuf[4] = pFrame->saved_sp;
63 lpbuf[5] = pFrame->ds;
64 lpbuf[6] = pFrame->bp;
65 lpbuf[7] = pFrame->ip;
66 lpbuf[8] = pFrame->cs;
67 return 0;
71 /**********************************************************************
72 * Throw (KERNEL.56)
74 int Throw( LPCATCHBUF lpbuf, int retval )
76 STACK16FRAME *pFrame;
78 dprintf_catch( stddeb, "Throw: buf=%p val=%04x ss:sp=%04x:%04x\n",
79 lpbuf, retval, IF1632_Saved16_ss, IF1632_Saved16_sp );
81 IF1632_Saved16_sp = lpbuf[0] - sizeof(WORD);
82 IF1632_Saved32_esp = MAKELONG( lpbuf[1], lpbuf[2] );
83 pFrame = CURRENT_STACK16;
84 pFrame->saved_ss = lpbuf[3];
85 pFrame->saved_sp = lpbuf[4];
86 pFrame->ds = lpbuf[5];
87 pFrame->bp = lpbuf[6];
88 pFrame->ip = lpbuf[7];
89 pFrame->cs = lpbuf[8];
90 pFrame->es = 0;
91 return retval;
95 #endif /* !WINELIB */