mirror of
https://github.com/reactos/wine.git
synced 2024-12-12 05:45:56 +00:00
5819953c2a
Wed Apr 20 14:53:35 1994 Bob Amstadt (bob@pooh) * [tools/build.c] [if1632/call.S] [if1632/Imakefile] Fixed bug for non-Linux systems. Apr 18, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [windows/win.c] Bug fixed in CreateWindowEx() : Now use SetMenu() for menubar setup. New empty stub for function SetSysModalWindow(). * [misc/exec.c] New empty stub for function ExitWindows(). * [objects/font.c] New empty stub for function EnumFonts(). * New file [misc/property.c] New functions RemoveProp(), GetProp(), SetProp() & EnumProps(). * New file [misc/shell.c] New empty stubs for function RegisterShellProc(), ShellExecute() & ShellProc(). * New files [loader/task.c] & [include/task.h] Move functions GetWindowTask(), GetNumTask(), EnumTaskWindows() from 'loader/library.c'. * [if1632/user.c] [if1632/kernel.c] Put Atoms functions entries. * [controls/combo.c] New functions DirDlgSelectComboBox() & DirDlgListComboBox(). * [controls/listbox.c] New functions DirDlgSelect() & DirDlgList(). Sun Apr 17 20:57:59 1994 Erik Bos (erik@trashcan.hacktic.nl) * [objects/test.c] GrayString() added. * [if1632/callback.c] CallGrayStringProc() added. * [if1632/relay.c] [if1632/mmsystem.spec] Added. * [if1632/kernel.spec] [if1632/user.spec] Added forgotten specs for atom functions. Tue Apr 12 00:05:31 1994 Bob Amstadt (bob@pooh) * misc/spy.c (SpyInit): Added more message types * [windows/mdi.c] [include/mdi.h] Maximizing and restoring child windows. Tiling of child windows. Mon Apr 11 20:48:28 1994 Alexandre Julliard (julliard@lamisun.epfl.ch) * [windows/winpos.c] Revert focus and activation to previous window when hiding a window. * [windows/syscolor.c] Implemented system color objects (brushes and pens created at SetSysColor() time for better performance). * [windows/graphics.c] [windows/nonclient.c] [controls/button.c] Changed painting code to use system color objects. * [windows/message.c] New function MSG_InternalGetMessage() for internal messages loops (e.g. for dialogs or menus). * [windows/hook.c] [include/hook.h] (New files) Beginning of the window hooks implementation. * [windows/dialog.c] Use new function MSG_InternalGetMessage() in DialogBox(). * [if1632/callback.c] Added function CallHookProc(). Apr 11, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [windows/event.c] Bug fix : WM_CHARs are sent to focused window like WM_KEY???. * [misc/exec.c] Nothing much more than a stub for LoadModule(), I saw there a lot to be done in that corner, I will come back later ... * [loader/library.c] New functions GetWindowTask(), GetNumTask(), EnumTaskWindows() and associated modules & tasks linked-lists. (it's only an 'emerging bud', more to come next weeks). * [loader/wine.c] Use LoadLibrary() instead of LoadImage() for 'sysres.dll'. * [control/menu.c] You can now click outside menu region without problem. Keyboard navig more smootly, even if a child has the focus. Bug fix in InsertItem(), (bad linklist when insert point not found). change Realloc for Free & Alloc in ModifyItem(). MF_STRING now set BLACK_PEN to fix bug of bad color of the underscores done by DrawText(), (maybe it should done in DrawText() itself ?). Sun Apr 10 14:06:08 1994 Erik Bos (erik@trashcan.hacktic.nl) * [misc/profile.c] .INI files will now be stored in / loaded from the windows dir if no path is supplied. * [if1632/kernel.spec] Fixed GetDriveType's prototype. * [if1632/winsock.spec] [include/winsock.h] [misc/winsocket.c] Fixed prototypes: winsock uses a word as socket handle not an int. * [misc/winsocket.c] Added heap allocation for returned structures. Added non-blocking WSAAsyncGetXbyY() functions as blocking ones. * [loader/wine.c] Added IsDLLLoaded(), used in LoadImage() to prevent loading a dll multiple times. Directory is added to wine's path when a fullpath is supplied when starting wine. LoadImage(): DLL filename used instead DLL's own internal name, fixes 'Bad DLL name' errors. Sat Apr 9 08:26:03 1994 David Metcalfe <david@prism.demon.co.uk> * [controls/edit.c] [controls/widgets.c] First release of edit control.
292 lines
7.2 KiB
C
292 lines
7.2 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"
|
|
#include <setjmp.h>
|
|
|
|
extern SEGDESC Segments[];
|
|
extern unsigned short IF1632_Saved16_ss;
|
|
extern unsigned long IF1632_Saved16_ebp;
|
|
extern unsigned long IF1632_Saved16_esp;
|
|
extern unsigned short IF1632_Saved32_ss;
|
|
extern unsigned long IF1632_Saved32_ebp;
|
|
extern unsigned long IF1632_Saved32_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 Segments[seg_idx].owner;
|
|
}
|
|
|
|
/**********************************************************************
|
|
* 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);
|
|
tp->used = 1;
|
|
|
|
return tp->thunk;
|
|
}
|
|
|
|
/**********************************************************************
|
|
* FreeProcInstance (KERNEL.52)
|
|
*/
|
|
void FreeProcInstance(FARPROC func)
|
|
{
|
|
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 ((void *) tp->thunk == (void *) func)
|
|
{
|
|
tp->used = 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**********************************************************************
|
|
* CallWindowProc (USER.122)
|
|
*/
|
|
LONG CallWindowProc( FARPROC func, HWND hwnd, WORD message,
|
|
WORD wParam, LONG lParam )
|
|
{
|
|
SpyMessage(hwnd, message, wParam, lParam);
|
|
|
|
if (Is16bitAddress(func))
|
|
{
|
|
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 (*func)(hwnd, message, wParam, lParam);
|
|
}
|
|
}
|
|
|
|
/**********************************************************************
|
|
* CallLineDDAProc
|
|
*/
|
|
void CallLineDDAProc(FARPROC func, short xPos, short yPos, long lParam)
|
|
{
|
|
if (Is16bitAddress(func))
|
|
{
|
|
PushOn16( CALLBACK_SIZE_WORD, xPos );
|
|
PushOn16( CALLBACK_SIZE_WORD, yPos );
|
|
PushOn16( CALLBACK_SIZE_LONG, lParam );
|
|
CallTo16((unsigned int) func,
|
|
FindDataSegmentForCode((unsigned long) func));
|
|
}
|
|
else
|
|
{
|
|
(*func)(xPos, yPos, lParam);
|
|
}
|
|
}
|
|
|
|
/**********************************************************************
|
|
* CallHookProc
|
|
*/
|
|
DWORD CallHookProc( HOOKPROC func, short code, WPARAM wParam, LPARAM lParam )
|
|
{
|
|
if (Is16bitAddress(func))
|
|
{
|
|
PushOn16( CALLBACK_SIZE_WORD, code );
|
|
PushOn16( CALLBACK_SIZE_WORD, wParam );
|
|
PushOn16( CALLBACK_SIZE_LONG, lParam );
|
|
return CallTo16((unsigned int) func,
|
|
FindDataSegmentForCode((unsigned long) func));
|
|
}
|
|
else
|
|
{
|
|
return (*func)( code, wParam, lParam );
|
|
}
|
|
}
|
|
|
|
/**********************************************************************
|
|
* CallGrayStringProc
|
|
*/
|
|
BOOL CallGrayStringProc(FARPROC func, HDC hdc, LPARAM lParam, INT cch )
|
|
{
|
|
if (Is16bitAddress(func))
|
|
{
|
|
PushOn16( CALLBACK_SIZE_WORD, hdc );
|
|
PushOn16( CALLBACK_SIZE_LONG, lParam );
|
|
PushOn16( CALLBACK_SIZE_WORD, cch );
|
|
return CallTo16((unsigned int) func,
|
|
FindDataSegmentForCode((unsigned long) func));
|
|
}
|
|
else
|
|
{
|
|
return (*func)( hdc, lParam, cch );
|
|
}
|
|
}
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
/*
|
|
* The following functions realize the Catch/Throw functionality.
|
|
* My thought is to use the setjmp, longjmp combination to do the
|
|
* major part of this one. All I have to remember, in addition to
|
|
* whatever the jmp_buf contains, is the contents of the 16-bit
|
|
* sp, bp and ss. I do this by storing them in the structure passed
|
|
* to me by the 16-bit program (including my own jmp_buf...).
|
|
* Hopefully there isn't any program that modifies the contents!
|
|
* Bad thing: I have to save part of the stack, since this will
|
|
* get reused on the next call after my return, leaving it in an
|
|
* undefined state.
|
|
*/
|
|
#define STACK_DEPTH_16 28
|
|
|
|
struct special_buffer {
|
|
jmp_buf buffer;
|
|
long regs [6];
|
|
char stack_part [STACK_DEPTH_16];
|
|
} *sb;
|
|
|
|
int Catch (LPCATCHBUF cbuf)
|
|
{
|
|
WORD retval;
|
|
jmp_buf *tmp_jmp;
|
|
char *stack16 = (char *) (((unsigned int)IF1632_Saved16_ss << 16) +
|
|
(IF1632_Saved16_esp & 0xffff));
|
|
|
|
sb = malloc (sizeof (struct special_buffer));
|
|
|
|
sb -> regs [0] = IF1632_Saved16_esp;
|
|
sb -> regs [1] = IF1632_Saved16_ebp;
|
|
sb -> regs [2] = IF1632_Saved16_ss & 0xffff;
|
|
sb -> regs [3] = IF1632_Saved32_esp;
|
|
sb -> regs [4] = IF1632_Saved32_ebp;
|
|
sb -> regs [5] = IF1632_Saved32_ss & 0xffff;
|
|
memcpy (sb -> stack_part, stack16, STACK_DEPTH_16);
|
|
tmp_jmp = &sb -> buffer;
|
|
*((struct special_buffer **)cbuf) = sb;
|
|
|
|
if ((retval = setjmp (*tmp_jmp)))
|
|
{
|
|
IF1632_Saved16_esp = sb -> regs [0];
|
|
IF1632_Saved16_ebp = sb -> regs [1];
|
|
IF1632_Saved16_ss = sb -> regs [2] & 0xffff;
|
|
IF1632_Saved32_esp = sb -> regs [3];
|
|
IF1632_Saved32_ebp = sb -> regs [4];
|
|
IF1632_Saved32_ss = sb -> regs [5] & 0xffff;
|
|
stack16 = (char *) (((unsigned int)IF1632_Saved16_ss << 16) +
|
|
(IF1632_Saved16_esp & 0xffff));
|
|
|
|
memcpy (stack16, sb -> stack_part, STACK_DEPTH_16);
|
|
#ifdef DEBUG_CATCH
|
|
printf ("Been thrown here: %d, retval = %d\n", sb, retval);
|
|
#endif
|
|
free ((void *) sb);
|
|
return (retval);
|
|
} else {
|
|
#ifdef DEBUG_CATCH
|
|
printf ("Will somtime get thrown here: %d\n", sb);
|
|
#endif
|
|
return (retval);
|
|
}
|
|
}
|
|
|
|
void Throw (LPCATCHBUF cbuf, int val)
|
|
{
|
|
sb = *((struct special_buffer **)cbuf);
|
|
#ifdef DEBUG_CATCH
|
|
printf ("Throwing to: %d\n", sb);
|
|
#endif
|
|
longjmp (sb -> buffer, val);
|
|
}
|