Alexandre Julliard 60ce85c965 Release 980201
Sun Feb  1 13:24:54 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [files/drive.c]
	Added Device= parameter to drive configuration.

	* [if1632/relay.c]
	Throw() and Catch() now use the correct CATCHBUF layout (untested).

	* [tools/build.c] [include/stackframe.h] [loader/task.c]
	Moved 16-bit stack pointer into thread database.
	Save current %fs while running 16-bit code.

Fri Jan 30 09:25:49 1998  Martin Boehme  <boehme@informatik.mu-luebeck.de>

	* [graphics/mapping.c]
	Made DPtoLP32 and LPtoDP32 respect world transforms.

	* [graphics/path.c] [graphics/painting.c] [if1632/gdi.spec]
	  [include/path.h]
	More path support.

	* [include/gdi.h] [include/windows.h] [objects/dc.c]
	  [relay/gdi32.spec]
	Support for Get/SetArcDirection and Get/SetWorldTransform

	* [windows/hook.c]
	Fixed a bug in HOOK_Map16To32Common.

Thu Jan 29 23:43:18 1998  Douglas Ridgway <ridgway@taiga.gmcl.com>

	* [graphics/metafiledrv/init.c] [objects/metafile.c]
	Documentation for metafile related API calls. Fixed a bug to avoid
	documenting it.

	* [include/windows.h]
	Declaration for LoadImage.

Thu Jan 29 21:44:45 1998  Huw D M Davies <h.davies1@physics.oxford.ac.uk>

	* [graphics/win16drv/*]
	Changes to printing code to enable use of printer fonts with the
	win3.1 postscript driver. Remember to add printer=on to [wine]
	section of wine.conf . You will also need to disable truetype
	fonts from control panel. Winword 6.0 and Write seem to be happy
	with this...

	* [include/bitmap.h]
	Fix Widthbytes for 15bpp displays.

Tue Jan 27 20:54:08 1998  Kristian Nielsen <kristian.nielsen@risoe.dk>

	* [tsx11/*] [include/ts*] [tools/make_X11wrappers]
	Implemented thread-safe X11 wrappers.

Tue Jan 27 13:54:09 1998  Constantine Sapuntzakis  <csapuntz@tma-1.lcs.mit.edu>

	* [windows/queue.c]
	Forgot to convert thdb to thread_id.

	* [misc/registry.c]
	Sped up Windows 95 registry reading. Changed code to traverse
	registry as a tree rather than read in all possible keys
	(including dead ones). 

Tue Jan 27 12:46:09 1998  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [loader/pe_image.c][Makefile.in][scheduler/thread.c]
	  [libtest/hello5.c]
	Don't exit() on failed to load referenced dlls.
	Fixed static tls allocation for multiple threads.
	WINELIB should now be able to load PE dlls. A sample
	winelib program, that dynamically loads a internal dll
	is included.

	* [graphics/ddraw.c][include/ddraw.h][include/d3d.h]
	Cleaned up and enhanced further. Added several DirectX5
	interface definitions and DirectSurface3 implementation.
	Stubs for D3D (NOT coming soon, just there so it fails safely).

	* [multimedia/dsound.c][include/dsound.h]
	Actually works now for a lot of cases. Some DirectX5 stuff
	added. Still lacking several features.

	* [windows/dinput.c][include/dinput.h]
	Started implementing DirectInput. Doesn't work yet, don't 
	know why.

	* [if1632/thunk.c][misc/callbacks.c]
	  [win32/kernel.c][include/callbacks.h]
	Added WOWCallback16Ex, WOWHandle32.

	* [misc/cpu.c]
	Fixed GetSystemInfo, IsProcessorFeaturePresent.

	* [multimedia/joystick.c][multimedia/time.c]
	Several fixes. Small hack to get timerevents in timeGetTime() loops.

Tue Jan 20 11:26:27 1998  Slaven Rezic  <eserte@cs.tu-berlin.de>

	* [configure.in]
	Fixed check for union semun on FreeBSD systems.

Sun Jan 18 23:05:04 1998  Karl Backström <karl_b@geocities.com>

	* [misc/ole2nls.c] [programs/progman/Sw.rc] [programs/winhelp/Sw.rc]
	  [resources/sysres_Sw.rc]
	Added/updated Swedish language support.

Sun Jan 18 18:49:01 1998  Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [misc/winsock.c] [misc/winsock_dns.c] [windows/event.c]
	  [windows/win.c] [windows/dce.c] [windows/winpos.c]
	Bug fixes.

Sun Jan 18 12:45:23 1997  Andreas Mohr <100.30936@germany.net>

	* [msdos/int25.c] [msdos/int26.c]
        Implemented "native" absolute disk read/write access.

	* [msdos/int13.c] [msdos/ioports.c]
	Enhanced GET DRIVE PARAMETERS (int13 AH=08).

	* [graphics/win16drv/prtdrv.c] [if1632/gdi.spec]
	Fixed typos, implemented dmEnumDFonts,
	Started implementation of dmRealizeObject.

	* [if1632/compobj.spec] [ole/compobj.c] [relay32/ole32.spec]
	Stubs CoCreateInstance, CoFreeUnusedLibraries, implemented
	CoFileTimeNow.

	* [if1632/kernel.spec] [include/windows.h] [memory/global.c]
	  [memory/string.c] [misc/kernel.c] [misc/Makefile.in]
	  [misc/toolhelp.c] [msdos/int21.c]
	Implemented GlobalHandleNoRIP, GetFreeMemInfo, DebugFillBuffer, 
	stubs GetSetKernelDOSProc, DiagQuery, DiagOutput, ToolHelpHook
	(Undocumented Windows).

	* [if1632/user.spec] [if1632/win32s16.spec] [misc/win32s16.c]
	Misc stubs.

	* [if1632/winaspi.spec] [misc/aspi.c]
	Implemented GetASPIDLLVersion.

	* [if1632/wprocs.spec] [msdos/int20.c] [msdos/Makefile.in]
	Added handler for Int 0x20 (terminate program, _very_ old-fashioned).

	* [misc/w32scomb.c]
	Implemented Get16DLLAddress() partially
	(big thanks to Marcus and Alexandre).

	* [relay32/Makefile.in] [relay32/builtin32.c] [relay32/dplay.spec]
	Added built-in DPLAY.DLL.

	* [relay32/winmm.spec] [multimedia/joystick.c]
	Added joySetThreshold.

	* [misc/windebug.c]
	Added WinNotify.

	* [win32/console.c]
	Stubs CreateConsoleScreenBuffer, SetConsoleActiveScreenBuffer,
	WriteConsoleOutput32A.

	* [windows/user.c]
	Stub SetEventHook.

Sat Jan 17 19:30:35 1998  Matthew Toseland  <Paul.Toseland@btinternet.com>

	* [windows/painting.c]
	Fixed broken restore-to-maximized.

Mon Jan 12 21:25:32 1998  Perceval - Marc Huguet Puig <mhp@tinet.fut.es>

	* [documentation/wine.man] [include/options.h]
	  [misc/main.c] [ole/ole2nls.c] [resources/sysres.c]
	  [resources/sysres_Ca.rc] [resources/Makefile.in]
	Added language catalan. (Afegit l'idioma català).
1998-02-01 18:33:27 +00:00

462 lines
13 KiB
C

/*
* Copyright 1993 Robert J. Amstadt
* Copyright 1995 Alexandre Julliard
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "windows.h"
#include "winnt.h"
#include "global.h"
#include "heap.h"
#include "module.h"
#include "stackframe.h"
#include "task.h"
#include "stddebug.h"
/* #define DEBUG_RELAY */
#include "debug.h"
#if 0
/* Make make_debug think these were really used */
dprintf_relay
#endif
/***********************************************************************
* RELAY_Init
*/
BOOL32 RELAY_Init(void)
{
WORD codesel;
extern BOOL32 THUNK_Init(void);
/* 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;
extern DWORD 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 );
/* Create built-in modules */
if (!BUILTIN_Init()) return FALSE;
/* Initialize thunking */
return THUNK_Init();
}
/***********************************************************************
* RELAY_DebugCallFrom16
*/
void RELAY_DebugCallFrom16( int func_type, char *args,
void *entry_point, CONTEXT *context )
{
STACK16FRAME *frame;
WORD ordinal;
char *args16;
int i;
if (!debugging_relay) return;
frame = CURRENT_STACK16;
printf( "Call %s(", BUILTIN_GetEntryPoint16( frame->entry_cs,
frame->entry_ip,
&ordinal ));
VA_START16( args16 );
for (i = 0; i < strlen(args); i++)
{
switch(args[i])
{
case 'w':
case 's':
args16 += 2;
break;
case 'l':
case 'p':
case 't':
case 'T':
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 't':
args16 -= 4;
printf( "0x%08x", *(int *)args16 );
if (HIWORD(*(int *)args16)) {
LPBYTE s = (LPBYTE)PTR_SEG_TO_LIN(*(int*)args16);
/* filter out non printable chars, which would destroy output */
fputs(" \"",stdout);
while (*s) {
if (*s < ' ') {
printf( "\\0x%02x",*s++);
continue;
}
if (*s=='\\') {
fputs( "\\\\",stdout);
s++;
continue;
}
fputc(*s++,stdout);
}
fputs("\"",stdout);
}
break;
case 'p':
args16 -= 4;
printf( "%04x:%04x", *(WORD *)(args16+2), *(WORD *)args16 );
break;
case 'T':
args16 -= 4;
printf( "%04x:%04x", *(WORD *)(args16+2), *(WORD *)args16 );
if (HIWORD(*(int *)args16)) {
LPBYTE s = (LPBYTE)PTR_SEG_TO_LIN(*(int*)args16);
/* filter out non printable chars, which would destroy output */
fputs(" \"",stdout);
while (*s) {
if (*s < ' ') {
printf( "\\0x%02x",*s++);
continue;
}
if (*s=='\\') {
fputs( "\\\\",stdout);
s++;
continue;
}
fputc(*s++,stdout);
}
fputs("\"",stdout);
}
break;
}
args++;
if (*args) printf( "," );
}
printf( ") ret=%04x:%04x ds=%04x\n", frame->cs, frame->ip, frame->ds );
VA_END16( args16 );
if (func_type == 2) /* register function */
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),
(WORD)ES_reg(context), EFL_reg(context) );
}
/***********************************************************************
* RELAY_DebugCallFrom16Ret
*/
void RELAY_DebugCallFrom16Ret( int func_type, int ret_val, CONTEXT *context)
{
STACK16FRAME *frame;
WORD ordinal;
if (!debugging_relay) return;
frame = CURRENT_STACK16;
printf( "Ret %s() ", BUILTIN_GetEntryPoint16( frame->entry_cs,
frame->entry_ip,
&ordinal ));
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",
(WORD)CS_reg(context), IP_reg(context), (WORD)DS_reg(context));
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),
(WORD)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;
STACK16FRAME *frame = CURRENT_STACK16;
fprintf(stderr,"No handler for Win16 routine %s (called from %04x:%04x)\n",
BUILTIN_GetEntryPoint16(frame->entry_cs,frame->entry_ip,&ordinal),
frame->cs, frame->ip );
TASK_KillCurrentTask(1);
}
/***********************************************************************
* RELAY_DebugCallTo16
*
* 'stack' points to the called function address on the 32-bit stack.
* Stack layout:
* ... ...
* (stack+8) arg2
* (stack+4) arg1
* (stack) func to call
*/
void RELAY_DebugCallTo16( int* stack, int nb_args )
{
THDB *thdb;
if (!debugging_relay) return;
thdb = THREAD_Current();
if (nb_args == -1) /* Register function */
{
CONTEXT *context = (CONTEXT *)stack[0];
WORD *stack16 = (WORD *)THREAD_STACK16(thdb);
printf( "CallTo16(func=%04lx:%04x,ds=%04lx",
CS_reg(context), IP_reg(context), DS_reg(context) );
nb_args = stack[1] / sizeof(WORD);
while (nb_args--) printf( ",0x%04x", *(--stack16) );
printf( ")\n" );
printf( " AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x BP=%04x ES=%04x\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
BP_reg(context), (WORD)ES_reg(context) );
}
else
{
printf( "CallTo16(func=%04x:%04x,ds=%04x",
HIWORD(stack[0]), LOWORD(stack[0]),
SELECTOROF(thdb->cur_stack) );
stack++;
while (nb_args--) printf( ",0x%04x", *stack++ );
printf( ")\n" );
}
}
/**********************************************************************
* Catch (KERNEL.55)
*
* Real prototype is:
* INT16 WINAPI Catch( LPCATCHBUF lpbuf );
*/
void WINAPI Catch( CONTEXT *context )
{
VA_LIST16 valist;
SEGPTR buf;
LPCATCHBUF lpbuf;
VA_START16( valist );
buf = VA_ARG16( valist, SEGPTR );
lpbuf = (LPCATCHBUF)PTR_SEG_TO_LIN( buf );
VA_END16( valist );
/* 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()... */
/* Windows uses:
* lpbuf[0] = ip
* lpbuf[1] = cs
* lpbuf[2] = sp
* lpbuf[3] = bp
* lpbuf[4] = si
* lpbuf[5] = di
* lpbuf[6] = ds
* lpbuf[7] = unused
* lpbuf[8] = ss
*/
lpbuf[0] = IP_reg(context);
lpbuf[1] = CS_reg(context);
lpbuf[2] = SP_reg(context);
lpbuf[3] = BP_reg(context);
lpbuf[4] = SI_reg(context);
lpbuf[5] = DI_reg(context);
lpbuf[6] = DS_reg(context);
lpbuf[7] = 0;
lpbuf[8] = SS_reg(context);
AX_reg(context) = 0; /* Return 0 */
}
/**********************************************************************
* Throw (KERNEL.56)
*
* Real prototype is:
* INT16 WINAPI Throw( LPCATCHBUF lpbuf, INT16 retval );
*/
void WINAPI Throw( CONTEXT *context )
{
VA_LIST16 valist;
SEGPTR buf;
LPCATCHBUF lpbuf;
STACK16FRAME *pFrame;
STACK32FRAME *frame32;
THDB *thdb = THREAD_Current();
VA_START16( valist );
AX_reg(context) = VA_ARG16( valist, WORD ); /* retval */
buf = VA_ARG16( valist, SEGPTR );
lpbuf = (LPCATCHBUF)PTR_SEG_TO_LIN( buf );
VA_END16( valist );
/* Find the frame32 corresponding to the frame16 we are jumping to */
frame32 = THREAD_STACK16( thdb )->frame32;
while (frame32 && frame32->frame16)
{
if (OFFSETOF(frame32->frame16) > lpbuf[2]) break;
frame32 = ((STACK16FRAME *)PTR_SEG_TO_LIN(frame32->frame16))->frame32;
}
thdb->cur_stack = PTR_SEG_OFF_TO_SEGPTR( lpbuf[8], lpbuf[2]-sizeof(WORD) );
pFrame = THREAD_STACK16( thdb );
pFrame->frame32 = frame32;
IP_reg(context) = lpbuf[0];
CS_reg(context) = lpbuf[1];
BP_reg(context) = lpbuf[3];
SI_reg(context) = lpbuf[4];
DI_reg(context) = lpbuf[5];
DS_reg(context) = lpbuf[6];
if (debugging_relay) /* Make sure we have a valid entry point address */
{
static FARPROC16 entryPoint = NULL;
if (!entryPoint) /* Get entry point for Throw() */
entryPoint = MODULE_GetEntryPoint( GetModuleHandle16("KERNEL"),
56 );
pFrame->entry_cs = SELECTOROF(entryPoint);
pFrame->entry_ip = OFFSETOF(entryPoint);
}
}
/**********************************************************************
* RELAY_CallProc32W
*
* Helper for CallProc[Ex]32W
*/
static DWORD RELAY_CallProc32W(int Ex)
{
DWORD nrofargs, argconvmask;
FARPROC32 proc32;
DWORD *args, ret;
VA_LIST16 valist;
int i;
VA_START16( valist );
nrofargs = VA_ARG16( valist, DWORD );
argconvmask = VA_ARG16( valist, DWORD );
proc32 = VA_ARG16( valist, FARPROC32 );
dprintf_relay(stddeb,"CallProc32W(%ld,%ld,%p, Ex%d args[",nrofargs,argconvmask,proc32,Ex);
args = (DWORD*)HEAP_xalloc( GetProcessHeap(), 0,
sizeof(DWORD)*nrofargs );
for (i=0;i<nrofargs;i++) {
if (argconvmask & (1<<i))
{
SEGPTR ptr = VA_ARG16( valist, SEGPTR );
args[nrofargs-i-1] = (DWORD)PTR_SEG_TO_LIN(ptr);
dprintf_relay(stddeb,"%08lx(%p),",ptr,PTR_SEG_TO_LIN(ptr));
}
else
{
args[nrofargs-i-1] = VA_ARG16( valist, DWORD );
dprintf_relay(stddeb,"%ld,",args[nrofargs-i-1]);
}
}
dprintf_relay(stddeb,"]) - ");
VA_END16( valist );
switch (nrofargs) {
case 0: ret = proc32();
break;
case 1: ret = proc32(args[0]);
break;
case 2: ret = proc32(args[0],args[1]);
break;
case 3: ret = proc32(args[0],args[1],args[2]);
break;
case 4: ret = proc32(args[0],args[1],args[2],args[3]);
break;
case 5: ret = proc32(args[0],args[1],args[2],args[3],args[4]);
break;
case 6: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5]);
break;
case 7: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6]);
break;
case 8: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]);
break;
case 9: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]);
break;
case 10: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9]);
break;
case 11: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10]);
break;
default:
/* FIXME: should go up to 32 arguments */
fprintf(stderr,"CallProc32W: unsupported number of arguments %ld, please report.\n",nrofargs);
ret = 0;
break;
}
/* POP nrofargs DWORD arguments and 3 DWORD parameters */
if (!Ex) STACK16_POP( THREAD_Current(),
(3 + nrofargs) * sizeof(DWORD) );
dprintf_relay(stddeb,"returns %08lx\n",ret);
HeapFree( GetProcessHeap(), 0, args );
return ret;
}
/**********************************************************************
* CallProc32W (KERNEL.517)
*/
DWORD WINAPI WIN16_CallProc32W()
{
return RELAY_CallProc32W(0);
}
/**********************************************************************
* CallProcEx32W() (KERNEL.518)
*
* C - style linkage to CallProc32W - caller pops stack.
*/
DWORD WINAPI WIN16_CallProcEx32W()
{
return RELAY_CallProc32W(TRUE);
}