mirror of
https://github.com/reactos/wine.git
synced 2025-01-11 06:06:23 +00:00
75a839a0c0
Tue Jul 13 20:31:31 1993 Bob Amstadt (bob at pooh) * [global.c] Completed global memory pool API Sun Jul 11 16:59:52 1993 Alexandre Julliard * [message.c] [user.c] [user.spec] [windows.h] Added emulation of Windows message queue. Thu Jul 8 19:29:27 1993 Bob Amstadt (bob at pooh) * [build.c] Original by Bob Amstadt * [callback.c] Original by Bob Amstadt, updates by Alexandre Julliard * [dump.c] Original by Bob Amstadt * [global.c] Original by Bob Amstadt * [heap.c] Original by Bob Amstadt * [kernel.c] Original by Bob Amstadt * [ldt.c] Original by Bob Amstadt * [ldtlib.c] Original by Bob Amstadt * [relay.c] Original by Bob Amstadt * [resource.c] Original by Bob Amstadt, updates by Alexandre Juliard * [selector.c] Original by Bob Amstadt, updates by Eric Youngdale * [user.c] Original by Bob Amstadt * [wine.c] Original by Bob Amstadt, updates by Eric Youngdale and Alexandre Julliard * [wintcl.c] Original by Regents of the University of California, updates by Peter MacDonald and Alexandre Julliard * [callback.h] Original by Bob Amstadt * [dlls.h] Original by Bob Amstadt * [heap.h] Original by Bob Amstadt * [neexe.h] Original by Bob Amstadt * [prototypes.h] Original by Bob Amstadt, updates by Eric Youngdale * [segmem.h] Original by Bob Amstadt * [tkInt.h] Original by Regents of the University of California * [windows.h] Original by Peter MacDonald, updates by Alexandre Julliard and Bob Amstadt * [wine.h] Original by Eric Youngdale * [kernel.spec] Original by Bob Amstadt, updates by Alexandre Julliard * [gdi.spec] Original by Bob Amstadt, updates by Alexandre Julliard * [shell.spec] Original by Bob Amstadt * [unixlib.spec] Original by Bob Amstadt * [user.spec] Original by Bob Amstadt, updates by Alexandre Julliard * [win87em.spec] Original by Bob Amstadt * [Windows.tcl] Original by Peter MacDonald, updates by Alexandre Julliard * [build-spec.txt] Original by Bob Amstadt * [if1632.S] Original by Bob Amstadt, updates by Eric Youngdale
129 lines
2.9 KiB
C
129 lines
2.9 KiB
C
static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
|
|
static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
|
|
|
|
#include "windows.h"
|
|
#include "callback.h"
|
|
#include "wine.h"
|
|
#include "segmem.h"
|
|
|
|
extern unsigned short SelectorOwners[];
|
|
extern unsigned short IF1632_Saved16_ss;
|
|
extern unsigned long IF1632_Saved16_esp;
|
|
extern struct segment_descriptor_s *MakeProcThunks;
|
|
|
|
struct thunk_s
|
|
{
|
|
int used;
|
|
unsigned char thunk[10];
|
|
};
|
|
|
|
/**********************************************************************
|
|
* PushOn16
|
|
*/
|
|
static void
|
|
PushOn16(int size, unsigned int value)
|
|
{
|
|
char *p = (char *) (((unsigned int)IF1632_Saved16_ss << 16) +
|
|
(IF1632_Saved16_esp & 0xffff));
|
|
if (size)
|
|
{
|
|
unsigned long *lp = (unsigned long *) p - 1;
|
|
|
|
*lp = value;
|
|
IF1632_Saved16_esp -= 4;
|
|
}
|
|
else
|
|
{
|
|
unsigned short *sp = (unsigned short *) p - 1;
|
|
|
|
*sp = value;
|
|
IF1632_Saved16_esp -= 2;
|
|
}
|
|
}
|
|
|
|
/**********************************************************************
|
|
* FindDataSegmentForCode
|
|
*/
|
|
static unsigned short
|
|
FindDataSegmentForCode(unsigned long csip)
|
|
{
|
|
unsigned int seg_idx;
|
|
|
|
seg_idx = (unsigned short) (csip >> 19);
|
|
return SelectorOwners[seg_idx];
|
|
}
|
|
|
|
/**********************************************************************
|
|
* CallBack16
|
|
*/
|
|
int
|
|
CallBack16(void *func, int n_args, ...)
|
|
{
|
|
va_list ap;
|
|
int i;
|
|
int arg_type, arg_value;
|
|
|
|
va_start(ap, n_args);
|
|
|
|
for (i = 0; i < n_args; i++)
|
|
{
|
|
arg_type = va_arg(ap, int);
|
|
arg_value = va_arg(ap, int);
|
|
PushOn16(arg_type, arg_value);
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
return CallTo16((unsigned int) func,
|
|
FindDataSegmentForCode((unsigned long) func));
|
|
}
|
|
|
|
/**********************************************************************
|
|
* CALLBACK_MakeProcInstance
|
|
*/
|
|
void *
|
|
CALLBACK_MakeProcInstance(void *func, int instance)
|
|
{
|
|
int handle;
|
|
void *new_func;
|
|
struct thunk_s *tp;
|
|
int i;
|
|
|
|
tp = (struct thunk_s *) MakeProcThunks->base_addr;
|
|
for (i = 0; i < 0x10000 / sizeof(*tp); i++, tp++)
|
|
if (!tp->used)
|
|
break;
|
|
|
|
if (tp->used)
|
|
return (void *) 0;
|
|
|
|
tp->thunk[0] = 0xb8;
|
|
tp->thunk[1] = (unsigned char) instance;
|
|
tp->thunk[2] = (unsigned char) (instance >> 8);
|
|
tp->thunk[3] = 0x8e;
|
|
tp->thunk[4] = 0xd8;
|
|
tp->thunk[5] = 0xea;
|
|
memcpy(&tp->thunk[6], &func, 4);
|
|
|
|
return tp->thunk;
|
|
}
|
|
|
|
/**********************************************************************
|
|
* CallWindowProc (USER.122)
|
|
*/
|
|
LONG CallWindowProc( FARPROC func, HWND hwnd, WORD message,
|
|
WORD wParam, LONG lParam )
|
|
{
|
|
if ((unsigned int)func & 0xffff0000)
|
|
{
|
|
PushOn16( CALLBACK_SIZE_WORD, hwnd );
|
|
PushOn16( CALLBACK_SIZE_WORD, message );
|
|
PushOn16( CALLBACK_SIZE_WORD, wParam );
|
|
PushOn16( CALLBACK_SIZE_LONG, lParam );
|
|
return CallTo16((unsigned int) func,
|
|
FindDataSegmentForCode((unsigned long) func));
|
|
}
|
|
else
|
|
return WIDGETS_Call32WndProc( func, hwnd, message, wParam, lParam );
|
|
}
|