wine/if1632/relay.c
Alexandre Julliard 2d93d000a4 Release 960521
Tue May 21 14:06:07 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [controls/button.c]
	Made ButtonWndProc a 32-bit window procedure.

	* [controls/desktop.c]
	Made DesktopWndProc a 32-bit window procedure.
	Added handling of WM_SETCURSOR.

	* [controls/menu.c]
	Allocate menu items and strings on the 32-bit system heap.
	Implemented Win32 versions for ChangeMenu, InsertMenu, ModifyMenu,
	AppendMenu and LoadMenuIndirect.

	* [controls/widgets.c]
	Added possibility to have 32-bit built-in classes.

	* [files/drive.c]
	Implemented GetLogicalDrive() and GetLogicalDriveStrings().

	* [misc/spy.c] [include/spy.h]
	Added support for spying Win32 messages.

	* [loader/builtin.c]
	Fixed bug in -dll option parsing.

	* [memory/local.c]
	Added back the change by Huw D. M. Davies to free the block in
	LocalRealloc() before allocating the new one.

	* [objects/bitmap.c] [objects/cursoricon.c] [objects/oembitmap.c]
	Fixed bug in bitmap size that caused memory corruption for 24bpp.

	* [windows/defwnd.c]
	Implemented Win32 version of DefWindowProc().

	* [windows/dialog.c]
	Implemented Win32 version of SendDlgItemMessage,
	Get/SetDlgItemText and Get/SetDlgItemInt.

	* [windows/mdi.c]
	Implemented Win32 version of DefFrameProc() and DefMDIChildProc().
	Don't make a copy of the OBM bitmaps for every MDI window.

	* [windows/message.c]
	Implemented Win32 version of SendMessage().
	
	* [windows/winproc.c] [windows/class.c] [windows/win.c]
	New scheme for 32-bit window procedures to replace aliases. All
	32-bit window procedure get a 16-bit address pointing to a
	WINDOWPROC structure.
	Implemented Ansi<->Unicode translation for CallWindowProc().
	Added translation of WM_DRAWITEM between Win16 and Win32.

	* [windows/win.c] [include/callback.h]
	Added ugly hack to build CREATESTRUCT on the stack when sending
	WM_NCCREATE.
	Implemented Win32 version of Get/SetWindowWord/Long and
	Get/SetWindowText.
	
Fri May 17 10:20:16 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [controls/button.c]
	Avoid gray text on gray background in disabled push buttons
	using a b/w raster and some raster operations (PatBlt,BitBlt).

	* [objects/text.c]
	DrawText(): don't draw an underbar anymore if DT_CALCRECT is set.
1996-05-21 15:01:41 +00:00

334 lines
9.6 KiB
C

/*
* Copyright 1993 Robert J. Amstadt
* Copyright 1995 Alexandre Julliard
*/
#include <stdio.h>
#include "global.h"
#include "module.h"
#include "registers.h"
#include "stackframe.h"
#include "stddebug.h"
/* #define DEBUG_RELAY */
#include "debug.h"
#if 0
/* Make make_debug think these were really used */
dprintf_relay
#endif
/* Saved 16-bit stack for current process (Win16 only) */
WORD IF1632_Saved16_ss = 0;
WORD IF1632_Saved16_sp = 0;
/* Saved 32-bit stack for current process (Win16 only) */
DWORD IF1632_Saved32_esp = 0;
SEGPTR IF1632_Stack32_base = 0;
/* Original Unix stack */
DWORD IF1632_Original32_esp;
/***********************************************************************
* RELAY_Init
*/
BOOL RELAY_Init(void)
{
WORD codesel;
/* Allocate the code selector for CallTo16 routines */
extern void CALLTO16_Start(), CALLTO16_End();
extern void CALLTO16_Ret_word(), CALLTO16_Ret_long();
extern DWORD CALLTO16_RetAddr_word, CALLTO16_RetAddr_long;
codesel = GLOBAL_CreateBlock( GMEM_FIXED, (void *)CALLTO16_Start,
(int)CALLTO16_End - (int)CALLTO16_Start,
0, TRUE, TRUE, FALSE, NULL );
if (!codesel) return FALSE;
/* Patch the return addresses for CallTo16 routines */
CALLTO16_RetAddr_word=MAKELONG( (int)CALLTO16_Ret_word-(int)CALLTO16_Start,
codesel );
CALLTO16_RetAddr_long=MAKELONG( (int)CALLTO16_Ret_long-(int)CALLTO16_Start,
codesel );
return TRUE;
}
/***********************************************************************
* RELAY_DebugCallFrom16
*/
void RELAY_DebugCallFrom16( int func_type, char *args,
void *entry_point, int args32 )
{
STACK16FRAME *frame;
NE_MODULE *pModule;
WORD ordinal;
char *args16, *name;
int i;
if (!debugging_relay) return;
frame = CURRENT_STACK16;
pModule = BUILTIN_GetEntryPoint( frame->entry_cs, frame->entry_ip,
&ordinal, &name );
printf( "Call %.*s.%d: %.*s(",
*((BYTE *)pModule + pModule->name_table),
(char *)pModule + pModule->name_table + 1,
ordinal, *name, name + 1 );
args16 = (char *)frame->args;
for (i = 0; i < strlen(args); i++)
{
switch(args[i])
{
case 'w':
case 's':
args16 += 2;
break;
case 'l':
case 'p':
args16 += 4;
break;
}
}
while (*args)
{
switch(*args)
{
case 'w':
case 's':
args16 -= 2;
printf( "0x%04x", *(WORD *)args16 );
break;
case 'l':
args16 -= 4;
printf( "0x%08x", *(int *)args16 );
break;
case 'p':
args16 -= 4;
printf( "%04x:%04x", *(WORD *)(args16+2), *(WORD *)args16 );
break;
}
args++;
if (*args) printf( "," );
}
printf( ") ret=%04x:%04x ds=%04x\n", frame->cs, frame->ip, frame->ds );
if (func_type == 2) /* register function */
{
struct sigcontext_struct *context = (struct sigcontext_struct *)&args32;
printf( " AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
ES_reg(context), EFL_reg(context) );
}
}
/***********************************************************************
* RELAY_DebugCallFrom16Ret
*/
void RELAY_DebugCallFrom16Ret( int func_type, int ret_val, int args32 )
{
STACK16FRAME *frame;
NE_MODULE *pModule;
WORD ordinal;
char *name;
if (*(DWORD *)PTR_SEG_TO_LIN(IF1632_Stack32_base) != 0xDEADBEEF)
{
fprintf(stderr, "Wine wrote past the end of the 32 bit stack. Please report this.\n");
exit(1); /* There's probably no point in going on */
}
if (!debugging_relay) return;
frame = CURRENT_STACK16;
pModule = BUILTIN_GetEntryPoint( frame->entry_cs, frame->entry_ip,
&ordinal, &name );
printf( "Ret %.*s.%d: %.*s() ",
*((BYTE *)pModule + pModule->name_table),
(char *)pModule + pModule->name_table + 1,
ordinal, *name, name + 1 );
switch(func_type)
{
case 0: /* long */
printf( "retval=0x%08x ret=%04x:%04x ds=%04x\n",
ret_val, frame->cs, frame->ip, frame->ds );
break;
case 1: /* word */
printf( "retval=0x%04x ret=%04x:%04x ds=%04x\n",
ret_val & 0xffff, frame->cs, frame->ip, frame->ds );
break;
case 2: /* regs */
printf( "retval=none ret=%04x:%04x ds=%04x\n",
frame->cs, frame->ip, frame->ds );
{
struct sigcontext_struct *context = (struct sigcontext_struct *)&args32;
printf( " AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
ES_reg(context), EFL_reg(context) );
}
break;
}
}
/***********************************************************************
* RELAY_Unimplemented16
*
* This function is called for unimplemented 16-bit entry points (declared
* as 'stub' in the spec file).
*/
void RELAY_Unimplemented16(void)
{
WORD ordinal;
char *name;
STACK16FRAME *frame = CURRENT_STACK16;
NE_MODULE *pModule = BUILTIN_GetEntryPoint( frame->entry_cs,
frame->entry_ip,
&ordinal, &name );
fprintf( stderr, "No handler for routine %.*s.%d (%.*s)\n",
*((BYTE *)pModule + pModule->name_table),
(char *)pModule + pModule->name_table + 1,
ordinal, *name, name + 1 );
exit(1);
}
/***********************************************************************
* RELAY_Unimplemented32
*
* This function is called for unimplemented 32-bit entry points (declared
* as 'stub' in the spec file).
* (The args are the same than for RELAY_DebugCallFrom32).
*/
void RELAY_Unimplemented32( int nb_args, void *entry_point,
const char *func_name )
{
fprintf( stderr, "No handler for Win32 routine %s\n", func_name );
exit(1);
}
/***********************************************************************
* RELAY_DebugCallTo16
*
* 'stack' points to the called function address on the 32-bit stack.
* Stack layout:
* ... ...
* (stack+12) arg2
* (stack+8) arg1
* (stack+4) 16-bit ds
* (stack) func to call
*/
void RELAY_DebugCallTo16( int* stack, int nbargs )
{
if (!debugging_relay) return;
printf( "CallTo16(func=%04x:%04x,ds=%04x",
HIWORD(stack[0]), LOWORD(stack[0]), LOWORD(stack[1]) );
stack += 2;
while (nbargs--) printf( ",0x%04x", *stack++ );
printf( ")\n" );
}
/***********************************************************************
* RELAY_DebugCallFrom32
*/
void RELAY_DebugCallFrom32( int nb_args, void *entry_point,
const char *func_name, int ebp, int ret_addr,
int arg1 )
{
int *parg;
if (!debugging_relay) return;
printf( "Call %s(", func_name );
for (parg = &arg1; nb_args; parg++, nb_args--)
{
printf( "%08x", *parg );
if (nb_args > 1) printf( "," );
}
printf( ") ret=%08x\n", ret_addr );
}
/***********************************************************************
* RELAY_DebugCallFrom32Ret
*/
void RELAY_DebugCallFrom32Ret( int ret_val, void *entry_point,
const char *func_name, int ebp, int ret_addr )
{
if (!debugging_relay) return;
printf( "Ret %s() retval=0x%08x ret=%08x\n",
func_name, ret_val, ret_addr );
}
/***********************************************************************
* RELAY_DebugCallTo32
*/
void RELAY_DebugCallTo32( unsigned int func, int nbargs, unsigned int arg1 )
{
unsigned int *argptr;
if (!debugging_relay) return;
printf( "CallTo32(func=%08x", func );
for (argptr = &arg1; nbargs; nbargs--, argptr++)
printf( ",%08x", *argptr );
printf( ")\n" );
}
/**********************************************************************
* Catch (KERNEL.55)
*/
INT Catch( LPCATCHBUF lpbuf )
{
STACK16FRAME *pFrame = CURRENT_STACK16;
/* Note: we don't save the current ss, as the catch buffer is */
/* only 9 words long. Hopefully no one will have the silly */
/* idea to change the current stack before calling Throw()... */
lpbuf[0] = IF1632_Saved16_sp;
lpbuf[1] = LOWORD(IF1632_Saved32_esp);
lpbuf[2] = HIWORD(IF1632_Saved32_esp);
lpbuf[3] = pFrame->saved_ss;
lpbuf[4] = pFrame->saved_sp;
lpbuf[5] = pFrame->ds;
lpbuf[6] = pFrame->bp;
lpbuf[7] = pFrame->ip;
lpbuf[8] = pFrame->cs;
return 0;
}
/**********************************************************************
* Throw (KERNEL.56)
*/
int Throw( LPCATCHBUF lpbuf, int retval )
{
STACK16FRAME *pFrame;
IF1632_Saved16_sp = lpbuf[0] - sizeof(WORD);
IF1632_Saved32_esp = MAKELONG( lpbuf[1], lpbuf[2] );
pFrame = CURRENT_STACK16;
pFrame->saved_ss = lpbuf[3];
pFrame->saved_sp = lpbuf[4];
pFrame->ds = lpbuf[5];
pFrame->bp = lpbuf[6];
pFrame->ip = lpbuf[7];
pFrame->cs = lpbuf[8];
pFrame->es = 0;
return retval;
}