Commit 198746d8 authored by Alexandre Julliard's avatar Alexandre Julliard

Replaced global Callbacks structure by appropriate glue code

generation. Removed a few unused entries in the Callout structure.
parent 415c615d
......@@ -18,6 +18,8 @@ C_SRCS = \
uitools.c \
widgets.c
GLUE = edit.c
all: $(MODULE).o
@MAKE_RULES@
......
......@@ -19,17 +19,16 @@
#include "winnt.h"
#include "win.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "combo.h"
#include "local.h"
#include "selectors.h"
#include "debugtools.h"
#include "callback.h"
#include "tweak.h"
#include "winversion.h"
DEFAULT_DEBUG_CHANNEL(edit)
DECLARE_DEBUG_CHANNEL(combo)
DECLARE_DEBUG_CHANNEL(relay)
DEFAULT_DEBUG_CHANNEL(edit);
DECLARE_DEBUG_CHANNEL(combo);
DECLARE_DEBUG_CHANNEL(relay);
#define BUFLIMIT_MULTI 65534 /* maximum buffer size (not including '\0')
FIXME: BTW, new specs say 65535 (do you dare ???) */
......@@ -305,6 +304,41 @@ static inline void EDIT_WM_Cut(WND *wnd, EDITSTATE *es)
}
/**********************************************************************
* get_app_version
*
* Returns the window version in case Wine emulates a later version
* of windows then the application expects.
*
* In a number of cases when windows runs an application that was
* designed for an earlier windows version, windows reverts
* to "old" behaviour of that earlier version.
*
* An example is a disabled edit control that needs to be painted.
* Old style behaviour is to send a WM_CTLCOLOREDIT message. This was
* changed in Win95, NT4.0 by a WM_CTLCOLORSTATIC message _only_ for
* applications with an expected version 0f 4.0 or higher.
*
*/
static DWORD get_app_version(void)
{
static DWORD version;
if (!version)
{
DWORD dwEmulatedVersion;
OSVERSIONINFOA info;
DWORD dwProcVersion = GetProcessVersion(0);
GetVersionExA( &info );
dwEmulatedVersion = MAKELONG( info.dwMinorVersion, info.dwMajorVersion );
/* fixme: this may not be 100% correct; see discussion on the
* wine developer list in Nov 1999 */
version = dwProcVersion < dwEmulatedVersion ? dwProcVersion : dwEmulatedVersion;
}
return version;
}
/*********************************************************************
*
* EditWndProc()
......@@ -1057,12 +1091,15 @@ static void EDIT_BuildLineDefs_ML(WND *wnd, EDITSTATE *es)
* the string under examination (we can decide this for ourselves).
*
*/
/* ### start build ### */
extern WORD CALLBACK EDIT_CallTo16_word_lwww(EDITWORDBREAKPROC16,SEGPTR,WORD,WORD,WORD);
/* ### stop build ### */
static INT EDIT_CallWordBreakProc(WND *wnd, EDITSTATE *es, INT start, INT index, INT count, INT action)
{
if (es->word_break_proc16) {
HLOCAL16 hloc16 = EDIT_EM_GetHandle16(wnd, es);
SEGPTR segptr = LocalLock16(hloc16);
INT ret = (INT)Callbacks->CallWordBreakProc(es->word_break_proc16,
INT ret = (INT)EDIT_CallTo16_word_lwww(es->word_break_proc16,
segptr + start, index, count, action);
LocalUnlock16(hloc16);
return ret;
......@@ -2049,7 +2086,7 @@ static HLOCAL EDIT_EM_GetHandle(WND *wnd, EDITSTATE *es)
LocalFree(newBuf);
return 0;
}
lstrcpyA(newText, es->text);
strcpy(newText, es->text);
EDIT_UnlockBuffer(wnd, es, TRUE);
if (es->text)
HeapFree(es->heap, 0, es->text);
......@@ -2109,7 +2146,7 @@ static HLOCAL16 EDIT_EM_GetHandle16(WND *wnd, EDITSTATE *es)
LOCAL_Free(wnd->hInstance, newBuf);
return 0;
}
lstrcpyA(newText, es->text);
strcpy(newText, es->text);
EDIT_UnlockBuffer(wnd, es, TRUE);
if (es->text)
HeapFree(es->heap, 0, es->text);
......@@ -2455,7 +2492,7 @@ static void EDIT_EM_ReplaceSel(WND *wnd, EDITSTATE *es, BOOL can_undo, LPCSTR lp
EDIT_EM_EmptyUndoBuffer(wnd, es);
/* now delete */
lstrcpyA(es->text + s, es->text + e);
strcpy(es->text + s, es->text + e);
}
if (strl) {
/* there is an insertion */
......@@ -2929,7 +2966,7 @@ static BOOL EDIT_EM_Undo(WND *wnd, EDITSTATE *es)
INT ulength = strlen(es->undo_text);
LPSTR utext = HeapAlloc(es->heap, 0, ulength + 1);
lstrcpyA(utext, es->undo_text);
strcpy(utext, es->undo_text);
TRACE("before UNDO:insertion length = %d, deletion buffer = %s\n",
es->undo_insert_count, utext);
......@@ -3198,7 +3235,7 @@ static LRESULT EDIT_WM_EraseBkGnd(WND *wnd, EDITSTATE *es, HDC dc)
HBRUSH brush;
RECT rc;
if ( VERSION_AppWinVer() >= 0x40000 &&(
if ( get_app_version() >= 0x40000 &&(
!es->bEnableState || (es->style & ES_READONLY)))
brush = (HBRUSH)EDIT_SEND_CTLCOLORSTATIC(wnd, dc);
else
......@@ -3828,7 +3865,7 @@ static void EDIT_WM_Paint(WND *wnd, EDITSTATE *es, WPARAM wParam)
}
if (es->font)
old_font = SelectObject(dc, es->font);
if ( VERSION_AppWinVer() >= 0x40000 &&(
if ( get_app_version() >= 0x40000 &&(
!es->bEnableState || (es->style & ES_READONLY)))
EDIT_SEND_CTLCOLORSTATIC(wnd, dc);
else
......
......@@ -2,3 +2,4 @@
Makefile
kernel.s
libkernel32.so.1.0
utthunk.glue.c
......@@ -23,6 +23,8 @@ RC_SRCS = \
MC_SRCS = \
messages/winerr_enu.mc
GLUE = utthunk.c
EXTRASUBDIRS = \
messages
......
......@@ -304,7 +304,7 @@ void WINAPI QT_Thunk( CONTEXT86 *context )
memcpy( (LPBYTE)CURRENT_STACK16 - argsize,
(LPBYTE)ESP_reg(context), argsize );
EAX_reg(context) = Callbacks->CallRegisterShortProc( &context16, argsize );
EAX_reg(context) = CallTo16RegisterShort( &context16, argsize );
EDX_reg(context) = HIWORD(EAX_reg(context));
EAX_reg(context) = LOWORD(EAX_reg(context));
}
......@@ -427,7 +427,7 @@ void WINAPI FT_Thunk( CONTEXT86 *context )
+ (*(LPBYTE *)arg - oldstack));
}
EAX_reg(context) = Callbacks->CallRegisterShortProc( &context16, argsize );
EAX_reg(context) = CallTo16RegisterShort( &context16, argsize );
EDX_reg(context) = HIWORD(EAX_reg(context));
EAX_reg(context) = LOWORD(EAX_reg(context));
......@@ -635,7 +635,7 @@ void WINAPI Common32ThkLS( CONTEXT86 *context )
memcpy( (LPBYTE)CURRENT_STACK16 - argsize,
(LPBYTE)ESP_reg(context), argsize );
EAX_reg(context) = Callbacks->CallRegisterLongProc(&context16, argsize + 32);
EAX_reg(context) = CallTo16RegisterLong(&context16, argsize + 32);
/* Clean up caller's stack frame */
ESP_reg(context) += argsize;
......@@ -685,7 +685,7 @@ void WINAPI OT_32ThkLSF( CONTEXT86 *context )
memcpy( (LPBYTE)CURRENT_STACK16 - argsize,
(LPBYTE)ESP_reg(context), argsize );
EAX_reg(context) = Callbacks->CallRegisterShortProc(&context16, argsize);
EAX_reg(context) = CallTo16RegisterShort(&context16, argsize);
memcpy( (LPBYTE)ESP_reg(context),
(LPBYTE)CURRENT_STACK16 - argsize, argsize );
......@@ -1178,7 +1178,7 @@ void WINAPI PK16FNF(LPSTR strPtr)
FIXME("(%p): stub\n", strPtr);
/* fill in a fake filename that'll be easy to recognize */
lstrcpyA(strPtr, "WINESTUB.FIX");
strcpy(strPtr, "WINESTUB.FIX");
}
/***********************************************************************
......
......@@ -61,6 +61,9 @@ BOOL WINAPI UTRegister( HMODULE hModule, LPSTR lpsz16BITDLL,
VOID WINAPI UTUnRegister( HMODULE hModule );
/* ### start build ### */
extern LONG CALLBACK UTTHUNK_CallTo16_long_ll(FARPROC16,LONG,LONG);
/* ### stop build ### */
/****************************************************************************
* UTGlue16 (WPROCS.*)
......@@ -118,7 +121,7 @@ static DWORD WINAPI UTGlue32( FARPROC16 target, LPVOID lpBuff, DWORD dwUserDefin
/* Call 16-bit routine */
retv = Callbacks->CallUTProc( target, segBuff, dwUserDefined );
retv = UTTHUNK_CallTo16_long_ll( target, segBuff, dwUserDefined );
/* Free temporary selectors */
......@@ -253,7 +256,7 @@ BOOL WINAPI UTRegister( HMODULE hModule, LPSTR lpsz16BITDLL,
SEGPTR callback = SEGPTR_GET( &ut->ut16 );
SEGPTR segBuff = MapLS( lpBuff );
if ( !Callbacks->CallUTProc( init16, callback, segBuff ) )
if ( !UTTHUNK_CallTo16_long_ll( init16, callback, segBuff ) )
{
UnMapLS( segBuff );
UTUnRegister( hModule );
......
......@@ -2,3 +2,4 @@
*.spec.glue.s
Makefile
libwnaspi32.so.1.0
winaspi16.glue.c
......@@ -12,6 +12,8 @@ C_SRCS = \
winaspi16.c \
winaspi32.c
GLUE = winaspi16.c
@MAKE_DLL_RULES@
### Dependencies:
......@@ -20,9 +20,8 @@
#include "selectors.h"
#include "miscemu.h"
#include "ldt.h"
#include "callback.h"
DEFAULT_DEBUG_CHANNEL(aspi)
DEFAULT_DEBUG_CHANNEL(aspi);
/* FIXME!
......@@ -31,6 +30,10 @@ DEFAULT_DEBUG_CHANNEL(aspi)
* 3) Only linux supported so far
*/
/* ### start build ### */
extern LONG CALLBACK ASPI_CallTo16_long_l(FARPROC16,SEGPTR);
/* ### stop build ### */
#ifdef linux
static ASPI_DEVICE_INFO *ASPI_open_devices = NULL;
......@@ -348,12 +351,12 @@ ASPI_ExecScsiCmd(DWORD ptrPRB, UINT16 mode)
{
SEGPTR spPRB = MapLS(lpPRB);
Callbacks->CallASPIPostProc(lpPRB->SRB_PostProc, spPRB);
ASPI_CallTo16_long_l(lpPRB->SRB_PostProc, spPRB);
UnMapLS(spPRB);
break;
}
case ASPI_WIN16:
Callbacks->CallASPIPostProc(lpPRB->SRB_PostProc, ptrPRB);
ASPI_CallTo16_long_l(lpPRB->SRB_PostProc, ptrPRB);
break;
}
}
......@@ -416,7 +419,7 @@ DWORD ASPI_SendASPICommand(DWORD ptrSRB, UINT16 mode)
if (ASPIChainFunc)
{
/* This is not the post proc, it's the chain proc this time */
DWORD ret = Callbacks->CallASPIPostProc(ASPIChainFunc, ptrSRB);
DWORD ret = ASPI_CallTo16_long_l(ASPIChainFunc, ptrSRB);
if (ret)
{
lpSRB->inquiry.SRB_Status = SS_INVALID_SRB;
......
......@@ -18,7 +18,6 @@
#include "heap.h"
#include "debugtools.h"
#include "ldt.h"
#include "callback.h"
DEFAULT_DEBUG_CHANNEL(aspi);
......
......@@ -21,17 +21,18 @@
#include <string.h>
#include "winbase.h"
#include "wingdi.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "heap.h"
#include "winemm.h"
#include "syslevel.h"
#include "callback.h"
#include "selectors.h"
#include "module.h"
#include "debugtools.h"
#include "ntddk.h"
DEFAULT_DEBUG_CHANNEL(mmsys)
DEFAULT_DEBUG_CHANNEL(mmsys);
LONG WINAPI DrvDefDriverProc(DWORD dwDevID, HDRVR16 hDrv, WORD wMsg,
DWORD dwParam1, DWORD dwParam2);
......@@ -667,11 +668,11 @@ BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
TRACE("Window(%04lX) handle=%04X!\n", dwCallBack, hDev);
if (!IsWindow(dwCallBack))
return FALSE;
Callout.PostMessageA((HWND16)dwCallBack, wMsg, hDev, dwParam1);
PostMessageA((HWND16)dwCallBack, wMsg, hDev, dwParam1);
break;
case DCB_TASK: /* aka DCB_THREAD */
TRACE("Task(%04lx) !\n", dwCallBack);
Callout.PostThreadMessageA(dwCallBack, wMsg, hDev, dwParam1);
PostThreadMessageA(dwCallBack, wMsg, hDev, dwParam1);
break;
case DCB_FUNCTION:
TRACE("Function (32 bit) !\n");
......@@ -1578,7 +1579,7 @@ BOOL16 WINAPI mciDriverNotify16(HWND16 hWndCallBack, UINT16 wDevID, UINT16 wStat
return FALSE;
}
TRACE("before PostMessage\n");
Callout.PostMessageA(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
PostMessageA(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
return TRUE;
}
......@@ -1595,7 +1596,7 @@ BOOL WINAPI mciDriverNotify(HWND hWndCallBack, UINT wDevID, UINT wStatus)
return FALSE;
}
TRACE("before PostMessage\n");
Callout.PostMessageA(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
PostMessageA(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
return TRUE;
}
......@@ -3156,7 +3157,7 @@ static DWORD CALLBACK MMSYSTEM_MidiStream_Player(LPVOID pmt)
/* force thread's queue creation */
/* Used to be InitThreadInput16(0, 5); */
/* but following works also with hack in midiStreamOpen */
Callout.PeekMessageA(&msg, 0, 0, 0, 0);
PeekMessageA(&msg, 0, 0, 0, 0);
/* FIXME: this next line must be called before midiStreamOut or midiStreamRestart are called */
SetEvent(lpMidiStrm->hEvent);
......@@ -3174,11 +3175,11 @@ static DWORD CALLBACK MMSYSTEM_MidiStream_Player(LPVOID pmt)
lpMidiHdr = lpMidiStrm->lpMidiHdr;
if (!lpMidiHdr) {
/* for first message, block until one arrives, then process all that are available */
Callout.GetMessageA(&msg, 0, 0, 0);
GetMessageA(&msg, 0, 0, 0);
do {
if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm, lpwm, &msg))
goto the_end;
} while (Callout.PeekMessageA(&msg, 0, 0, 0, PM_REMOVE));
} while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE));
lpData = 0;
continue;
}
......@@ -3199,7 +3200,7 @@ static DWORD CALLBACK MMSYSTEM_MidiStream_Player(LPVOID pmt)
while ((dwCurrTC = GetTickCount()) < dwToGo) {
if (MsgWaitForMultipleObjects(0, NULL, FALSE, dwToGo - dwCurrTC, QS_ALLINPUT) == WAIT_OBJECT_0) {
/* got a message, handle it */
while (Callout.PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
if (!MMSYSTEM_MidiStream_MessageHandler(lpMidiStrm, lpwm, &msg))
goto the_end;
}
......@@ -3261,7 +3262,7 @@ the_end:
*/
static BOOL MMSYSTEM_MidiStream_PostMessage(WINE_MIDIStream* lpMidiStrm, WORD msg, DWORD pmt1, DWORD pmt2)
{
if (Callout.PostThreadMessageA(lpMidiStrm->dwThreadID, msg, pmt1, pmt2)) {
if (PostThreadMessageA(lpMidiStrm->dwThreadID, msg, pmt1, pmt2)) {
DWORD count;
BOOL bHasWin16Lock;
......@@ -3399,7 +3400,7 @@ MMRESULT WINAPI midiStreamOut(HMIDISTRM hMidiStrm, LPMIDIHDR lpMidiHdr,
if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, NULL)) {
ret = MMSYSERR_INVALHANDLE;
} else {
if (!Callout.PostThreadMessageA(lpMidiStrm->dwThreadID,
if (!PostThreadMessageA(lpMidiStrm->dwThreadID,
WINE_MSM_HEADER, cbMidiHdr,
(DWORD)lpMidiHdr)) {
WARN("bad PostThreadMessageA\n");
......@@ -4765,7 +4766,7 @@ void WINAPI mmTaskBlock16(HINSTANCE16 WINE_UNUSED hInst)
LRESULT WINAPI mmTaskSignal16(HTASK16 ht)
{
TRACE("(%04x);\n", ht);
return Callout.PostAppMessage16(ht, WM_USER, 0, 0);
return PostAppMessage16(ht, WM_USER, 0, 0);
}
/**************************************************************************
......@@ -4930,9 +4931,9 @@ static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD* lpMMThd)
break;
case WAIT_OBJECT_0 + 1: /* Msg */
TRACE("S2.2\n");
if (Callout.PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
Callout.TranslateMessage(&msg);
Callout.DispatchMessageA(&msg);
if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
break;
default:
......
......@@ -24,39 +24,20 @@ DEFAULT_DEBUG_CHANNEL(thunk);
/* ### start build ### */
extern WORD CALLBACK THUNK_CallTo16_word_ (FARPROC16);
extern WORD CALLBACK THUNK_CallTo16_word_w (FARPROC16,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_l (FARPROC16,LONG);
extern LONG CALLBACK THUNK_CallTo16_long_l (FARPROC16,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_ww (FARPROC16,WORD,WORD);
extern LONG CALLBACK THUNK_CallTo16_long_ll (FARPROC16,LONG,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_www (FARPROC16,WORD,WORD,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_lllw (FARPROC16,LONG,LONG,LONG,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_lwww (FARPROC16,LONG,WORD,WORD,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_wlww (FARPROC16,WORD,LONG,WORD,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_wwwl (FARPROC16,WORD,WORD,WORD,LONG);
extern LONG CALLBACK THUNK_CallTo16_long_wwwl (FARPROC16,WORD,WORD,WORD,LONG);
extern WORD CALLBACK THUNK_CallTo16_word_lwwww(FARPROC16,LONG,WORD,WORD,WORD,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_w (FARPROC16,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_wlww (FARPROC16,WORD,LONG,WORD,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_ww (FARPROC16,WORD,WORD);
extern WORD CALLBACK THUNK_CallTo16_word_wwwl (FARPROC16,WORD,WORD,WORD,LONG);
/* ### stop build ### */
static THUNK *firstThunk = NULL;
/* Callbacks function table for the emulator */
static const CALLBACKS_TABLE CALLBACK_EmulatorTable =
{
(void *)CallTo16RegisterShort, /* CallRegisterShortProc */
(void *)CallTo16RegisterLong, /* CallRegisterLongProc */
(void *)THUNK_CallTo16_word_w, /* CallWindowsExitProc */
(void *)THUNK_CallTo16_word_lwww, /* CallWordBreakProc */
(void *)THUNK_CallTo16_word_ww, /* CallBootAppProc */
(void *)THUNK_CallTo16_word_www, /* CallLoadAppSegProc */
(void *)THUNK_CallTo16_word_www, /* CallLocalNotifyFunc */
(void *)THUNK_CallTo16_word_www, /* CallResourceHandlerProc */
(void *)THUNK_CallTo16_long_ll, /* CallUTProc */
(void *)THUNK_CallTo16_long_l /* CallASPIPostProc */
};
const CALLBACKS_TABLE *Callbacks = &CALLBACK_EmulatorTable;
CALLOUT_TABLE Callout = { 0 };
......@@ -176,17 +157,11 @@ void THUNK_InitCallout(void)
*(FARPROC *)&Callout.##name = GetProcAddress( hModule, #name )
GETADDR( PeekMessageA );
GETADDR( PeekMessageW );
GETADDR( GetMessageA );
GETADDR( GetMessageW );
GETADDR( SendMessageA );
GETADDR( SendMessageW );
GETADDR( PostMessageA );
GETADDR( PostMessageW );
GETADDR( PostThreadMessageA );
GETADDR( PostThreadMessageW );
GETADDR( TranslateMessage );
GETADDR( DispatchMessageW );
GETADDR( DispatchMessageA );
GETADDR( RedrawWindow );
GETADDR( WaitForInputIdle );
......@@ -206,16 +181,8 @@ void THUNK_InitCallout(void)
*(FARPROC *)&Callout.##var = THUNK_GetCalloutThunk( pModule, name, \
(RELAY)THUNK_CallTo16_##thk )
GETADDR( PeekMessage16, "PeekMessage", word_lwwww );
GETADDR( GetMessage16, "GetMessage", word_lwww );
GETADDR( SendMessage16, "SendMessage", long_wwwl );
GETADDR( PostMessage16, "PostMessage", word_wwwl );
GETADDR( PostAppMessage16, "PostAppMessage", word_wwwl );
GETADDR( TranslateMessage16, "TranslateMessage", word_l );
GETADDR( DispatchMessage16, "DispatchMessage", long_l );
GETADDR( RedrawWindow16, "RedrawWindow", word_wlww );
GETADDR( FinalUserInit16, "FinalUserInit", word_ );
GETADDR( InitApp16, "InitApp", word_w );
GETADDR( InitThreadInput16, "InitThreadInput", word_ww );
GETADDR( UserYield16, "UserYield", word_ );
GETADDR( DestroyIcon32, "DestroyIcon32", word_ww );
......
......@@ -13,8 +13,6 @@
struct _CONTEXT86;
struct _STACK16FRAME;
extern void RELAY_Unimplemented16(void);
extern WORD CallFrom16Word();
extern LONG CallFrom16Long();
extern void CallFrom16Register();
......@@ -33,17 +31,15 @@ typedef struct
BYTE pushl; /* pushl $target */
void (*target)();
WORD call; /* call CALLFROM16 */
WORD callfrom16;
short callfrom16;
} ENTRYPOINT16;
#define EP(target, offset) { 0x5566, 0x68, (target), 0xe866, (WORD) (offset) }
typedef struct
{
BYTE pushl; /* pushl $relay */
DWORD relay;
void *relay;
BYTE lcall; /* lcall __FLATCS__:glue */
DWORD glue;
void *glue;
WORD flatcs;
BYTE prefix; /* lret $nArgs */
BYTE lret;
......@@ -51,24 +47,6 @@ typedef struct
LPCSTR profile; /* profile string */
} CALLFROM16;
#define CF16_WORD( relay, nArgs, profile ) \
{ 0x68, (DWORD)(relay), \
0x9a, (DWORD)CallFrom16Word, __FLATCS__, \
0x66, (nArgs)? 0xca : 0xcb, (nArgs)? (nArgs) : 0x9090, \
(profile) }
#define CF16_LONG( relay, nArgs, profile ) \
{ 0x68, (DWORD)(relay), \
0x9a, (DWORD)CallFrom16Long, __FLATCS__, \
0x66, (nArgs)? 0xca : 0xcb, (nArgs)? (nArgs) : 0x9090, \
(profile) }
#define CF16_REGS( relay, nArgs, profile ) \
{ 0x68, (DWORD)(relay), \
0x9a, (DWORD)CallFrom16Register, __FLATCS__, \
0x66, (nArgs)? 0xca : 0xcb, (nArgs)? (nArgs) : 0x9090, \
(profile) }
#include "poppack.h"
typedef struct
......
......@@ -24,92 +24,30 @@ extern void THUNK_Free( FARPROC thunk );
extern BOOL THUNK_Init(void);
extern void THUNK_InitCallout(void);
typedef struct
{
LONG CALLBACK (*CallRegisterShortProc)( CONTEXT86 *, INT );
LONG CALLBACK (*CallRegisterLongProc)( CONTEXT86 *, INT );
INT16 CALLBACK (*CallWindowsExitProc)( FARPROC16, INT16 );
INT16 CALLBACK (*CallWordBreakProc)( EDITWORDBREAKPROC16, SEGPTR, INT16,
INT16, INT16 );
VOID CALLBACK (*CallBootAppProc)( FARPROC16, HANDLE16, HFILE16 );
WORD CALLBACK (*CallLoadAppSegProc)( FARPROC16, HANDLE16, HFILE16, WORD );
WORD CALLBACK (*CallLocalNotifyFunc)( FARPROC16, WORD, HLOCAL16, WORD );
HGLOBAL16 CALLBACK (*CallResourceHandlerProc)( FARPROC16, HGLOBAL16, HMODULE16, HRSRC16 );
DWORD CALLBACK (*CallUTProc)( FARPROC16, DWORD, DWORD );
LRESULT CALLBACK (*CallASPIPostProc)( FARPROC16, SEGPTR );
} CALLBACKS_TABLE;
extern const CALLBACKS_TABLE *Callbacks;
typedef struct
{
BOOL16 WINAPI (*PeekMessage16)( LPMSG16 msg, HWND16 hwnd,
UINT16 first, UINT16 last, UINT16 flags );
BOOL WINAPI (*PeekMessageA)( LPMSG lpmsg, HWND hwnd,
UINT min, UINT max, UINT wRemoveMsg );
BOOL WINAPI (*PeekMessageW)( LPMSG lpmsg, HWND hwnd,
UINT min, UINT max, UINT wRemoveMsg );
BOOL16 WINAPI (*GetMessage16)( SEGPTR msg, HWND16 hwnd,
UINT16 first, UINT16 last );
BOOL WINAPI (*GetMessageA)( MSG* lpmsg, HWND hwnd,
UINT min, UINT max );
BOOL WINAPI (*GetMessageW)( MSG* lpmsg, HWND hwnd,
UINT min, UINT max );
LRESULT WINAPI (*SendMessage16)( HWND16 hwnd, UINT16 msg,
WPARAM16 wParam, LPARAM lParam );
LRESULT WINAPI (*SendMessageA)( HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam );
LRESULT WINAPI (*SendMessageW)( HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam );
BOOL16 WINAPI (*PostMessage16)( HWND16 hwnd, UINT16 message,
WPARAM16 wParam, LPARAM lParam );
BOOL WINAPI (*PostMessageA)( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam );
BOOL WINAPI (*PostMessageW)( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam );
BOOL16 WINAPI (*PostAppMessage16)( HTASK16 hTask, UINT16 message,
WPARAM16 wParam, LPARAM lParam );
BOOL WINAPI (*PostThreadMessageA)( DWORD idThread , UINT message,
WPARAM wParam, LPARAM lParam );
BOOL WINAPI (*PostThreadMessageW)( DWORD idThread , UINT message,
WPARAM wParam, LPARAM lParam );
BOOL16 WINAPI (*TranslateMessage16)( const MSG16 *msg );
BOOL WINAPI (*TranslateMessage)( const MSG *msg );
LONG WINAPI (*DispatchMessage16)( const MSG16* msg );
LONG WINAPI (*DispatchMessageA)( const MSG* msg );
LONG WINAPI (*DispatchMessageW)( const MSG* msg );
BOOL16 WINAPI (*RedrawWindow16)( HWND16 hwnd, const RECT16 *rectUpdate,
HRGN16 hrgnUpdate, UINT16 flags );
BOOL WINAPI (*RedrawWindow)( HWND hwnd, const RECT *rectUpdate,
HRGN hrgnUpdate, UINT flags );
WORD WINAPI (*UserSignalProc)( UINT uCode, DWORD dwThreadOrProcessID,
DWORD dwFlags, HMODULE16 hModule );
void WINAPI (*FinalUserInit16)( void );
INT16 WINAPI (*InitApp16)( HINSTANCE16 hInst );
HQUEUE16 WINAPI (*InitThreadInput16)( WORD unknown, WORD flags );
void WINAPI (*UserYield16)( void );
WORD WINAPI (*DestroyIcon32)( HGLOBAL16 handle, UINT16 flags );
DWORD WINAPI (*WaitForInputIdle)( HANDLE hProcess, DWORD dwTimeOut );
DWORD WINAPI (*MsgWaitForMultipleObjects)( DWORD nCount, HANDLE *pHandles,
BOOL fWaitAll, DWORD dwMilliseconds,
DWORD dwWakeMask );
HWND WINAPI (*WindowFromDC)( HDC hDC );
HWND WINAPI (*GetForegroundWindow)(void);
BOOL WINAPI (*IsChild)( HWND parent, HWND child );
INT WINAPI (*MessageBoxA)( HWND hWnd, LPCSTR text, LPCSTR title, UINT type );
INT WINAPI (*MessageBoxW)( HWND hwnd, LPCWSTR text, LPCWSTR title, UINT type );
BOOL WINAPI (*PeekMessageA)( LPMSG, HWND, UINT, UINT, UINT );
BOOL WINAPI (*GetMessageA)( MSG*, HWND, UINT, UINT );
LRESULT WINAPI (*SendMessageA)( HWND, UINT, WPARAM, LPARAM );
BOOL WINAPI (*PostMessageA)( HWND, UINT, WPARAM, LPARAM );
BOOL16 WINAPI (*PostAppMessage16)( HTASK16, UINT16, WPARAM16, LPARAM );
BOOL WINAPI (*PostThreadMessageA)( DWORD, UINT, WPARAM, LPARAM );
BOOL WINAPI (*TranslateMessage)( const MSG *msg );
LONG WINAPI (*DispatchMessageA)( const MSG* msg );
BOOL WINAPI (*RedrawWindow)( HWND, const RECT *, HRGN, UINT );
WORD WINAPI (*UserSignalProc)( UINT, DWORD, DWORD, HMODULE16 );
void WINAPI (*FinalUserInit16)( void );
HQUEUE16 WINAPI (*InitThreadInput16)( WORD, WORD );
void WINAPI (*UserYield16)( void );
WORD WINAPI (*DestroyIcon32)( HGLOBAL16, UINT16 );
DWORD WINAPI (*WaitForInputIdle)( HANDLE, DWORD );
DWORD WINAPI (*MsgWaitForMultipleObjects)( DWORD, HANDLE *, BOOL, DWORD, DWORD );
HWND WINAPI (*WindowFromDC)( HDC );
HWND WINAPI (*GetForegroundWindow)(void);
BOOL WINAPI (*IsChild)( HWND parent, HWND );
INT WINAPI (*MessageBoxA)( HWND, LPCSTR, LPCSTR, UINT );
INT WINAPI (*MessageBoxW)( HWND, LPCWSTR, LPCWSTR, UINT );
} CALLOUT_TABLE;
extern CALLOUT_TABLE Callout;
......
Makefile
module.glue.c
segment.glue.c
......@@ -11,6 +11,8 @@ C_SRCS = \
resource.c \
segment.c
GLUE = module.c segment.c
all: $(MODULE).o
@MAKE_RULES@
......
......@@ -17,7 +17,6 @@
#include "toolhelp.h"
#include "file.h"
#include "ldt.h"
#include "callback.h"
#include "heap.h"
#include "task.h"
#include "global.h"
......@@ -45,6 +44,10 @@ static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_
static HMODULE16 NE_GetModuleByFilename( LPCSTR name );
/* ### start build ### */
extern WORD CALLBACK NE_CallTo16_word_w(FARPROC16,WORD);
/* ### stop build ### */
/***********************************************************************
* NE_GetPtr
*/
......@@ -1176,7 +1179,7 @@ static void NE_InitProcess(void)
SELECTOROF(pTask->teb->cur_stack),
OFFSETOF(pTask->teb->cur_stack) );
ExitThread( Callbacks->CallRegisterShortProc( &context, 0 ) );
ExitThread( CallTo16RegisterShort( &context, 0 ) );
}
SYSLEVEL_LeaveWin16Lock();
......@@ -1209,7 +1212,7 @@ static BOOL16 MODULE_CallWEP( HMODULE16 hModule )
WARN("module %04x doesn't have a WEP\n", hModule );
return FALSE;
}
return Callbacks->CallWindowsExitProc( WEP, WEP_FREE_DLL );
return NE_CallTo16_word_w( WEP, WEP_FREE_DLL );
}
......
......@@ -29,6 +29,9 @@ DEFAULT_DEBUG_CHANNEL(resource)
static FARPROC16 DefResourceHandlerProc = (FARPROC16)0xffffffff;
/* already defined in segment.c glue code */
extern WORD CALLBACK NE_CallTo16_word_www(FARPROC16,WORD,WORD,WORD);
/***********************************************************************
* NE_FindNameTableId
*
......@@ -486,7 +489,7 @@ HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc )
{
if ( pTypeInfo->resloader
&& pTypeInfo->resloader != DefResourceHandlerProc )
pNameInfo->handle = Callbacks->CallResourceHandlerProc(
pNameInfo->handle = NE_CallTo16_word_www(
pTypeInfo->resloader, pNameInfo->handle, pModule->self, hRsrc );
else
pNameInfo->handle = NE_DefResourceHandler(
......
......@@ -21,7 +21,6 @@
#include "global.h"
#include "task.h"
#include "selectors.h"
#include "callback.h"
#include "file.h"
#include "module.h"
#include "stackframe.h"
......@@ -29,15 +28,20 @@
#include "debugtools.h"
#include "toolhelp.h"
DECLARE_DEBUG_CHANNEL(dll)
DECLARE_DEBUG_CHANNEL(fixup)
DECLARE_DEBUG_CHANNEL(module)
DECLARE_DEBUG_CHANNEL(segment)
DECLARE_DEBUG_CHANNEL(dll);
DECLARE_DEBUG_CHANNEL(fixup);
DECLARE_DEBUG_CHANNEL(module);
DECLARE_DEBUG_CHANNEL(segment);
#define SEL(x) ((x)|1)
static void NE_FixupSegmentPrologs(NE_MODULE *pModule, WORD segnum);
/* ### start build ### */
extern WORD CALLBACK NE_CallTo16_word_ww(FARPROC16,WORD,WORD);
extern WORD CALLBACK NE_CallTo16_word_www(FARPROC16,WORD,WORD,WORD);
/* ### stop build ### */
/***********************************************************************
* NE_GetRelocAddrName
*/
......@@ -121,9 +125,8 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
DuplicateHandle( GetCurrentProcess(), hf, GetCurrentProcess(), &hFile32,
0, FALSE, DUPLICATE_SAME_ACCESS );
hFile16 = FILE_AllocDosHandle( hFile32 );
pSeg->hSeg = Callbacks->CallLoadAppSegProc( selfloadheader->LoadAppSeg,
pModule->self, hFile16,
segnum );
pSeg->hSeg = NE_CallTo16_word_www( selfloadheader->LoadAppSeg,
pModule->self, hFile16, segnum );
TRACE_(dll)("Ret CallLoadAppSegProc: hSeg = 0x%04x\n", pSeg->hSeg);
_lclose16( hFile16 );
NtCurrentTeb()->cur_stack = oldstack;
......@@ -420,7 +423,7 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule )
hFile16 = FILE_AllocDosHandle( hf );
TRACE_(dll)("CallBootAppProc(hModule=0x%04x,hf=0x%04x)\n",
pModule->self,hFile16);
Callbacks->CallBootAppProc(selfloadheader->BootApp, pModule->self,hFile16);
NE_CallTo16_word_ww(selfloadheader->BootApp, pModule->self,hFile16);
TRACE_(dll)("Return from CallBootAppProc\n");
_lclose16(hf);
NtCurrentTeb()->cur_stack = oldstack;
......@@ -627,7 +630,7 @@ static BOOL NE_InitDLL( TDB* pTask, NE_MODULE *pModule )
TRACE_(dll)("Calling LibMain, cs:ip=%04lx:%04lx ds=%04lx di=%04x cx=%04x\n",
CS_reg(&context), EIP_reg(&context), DS_reg(&context),
DI_reg(&context), CX_reg(&context) );
Callbacks->CallRegisterShortProc( &context, 0 );
CallTo16RegisterShort( &context, 0 );
return TRUE;
}
......@@ -712,7 +715,7 @@ static void NE_CallDllEntryPoint( NE_MODULE *pModule, DWORD dwReason )
*(DWORD *)(stack - 14) = 0; /* dwReserved1 */
*(WORD *) (stack - 16) = 0; /* wReserved2 */
Callbacks->CallRegisterShortProc( &context, 16 );
CallTo16RegisterShort( &context, 16 );
}
}
......
......@@ -19,6 +19,8 @@ C_SRCS = \
string.c \
virtual.c
GLUE = local.c
all: $(MODULE).o
@MAKE_RULES@
......
......@@ -27,8 +27,8 @@
#include "debugtools.h"
#include "callback.h"
DEFAULT_DEBUG_CHANNEL(local)
DECLARE_DEBUG_CHANNEL(heap)
DEFAULT_DEBUG_CHANNEL(local);
DECLARE_DEBUG_CHANNEL(heap);
typedef struct
{
......@@ -124,6 +124,11 @@ WORD GDI_HeapSel = 0; /* GDI heap selector */
#define HANDLE_FIXED(handle) (((handle) & 3) == 0)
#define HANDLE_MOVEABLE(handle) (((handle) & 3) == 2)
/* ### start build ### */
extern WORD CALLBACK LOCAL_CallTo16_word_www(FARPROC16,WORD,HLOCAL16,WORD);
/* ### stop build ### */
/***********************************************************************
* LOCAL_GetHeap
*
......@@ -756,7 +761,7 @@ WORD LOCAL_Compact( HANDLE16 ds, UINT16 minfree, UINT16 flags )
/* Free the old location */
LOCAL_FreeArena(ds, movearena);
if (pInfo->notify)
Callbacks->CallLocalNotifyFunc(pInfo->notify, LN_MOVE,
LOCAL_CallTo16_word_www(pInfo->notify, LN_MOVE,
(WORD)((char *)pEntry - ptr), pEntry->addr);
/* Update handle table entry */
pEntry->addr = finalarena + ARENA_HEADER_SIZE + sizeof(HLOCAL16) ;
......@@ -795,7 +800,7 @@ WORD LOCAL_Compact( HANDLE16 ds, UINT16 minfree, UINT16 flags )
(char *)pEntry - ptr, pEntry->addr);
LOCAL_FreeArena(ds, ARENA_HEADER(pEntry->addr));
if (pInfo->notify)
Callbacks->CallLocalNotifyFunc(pInfo->notify, LN_DISCARD,
LOCAL_CallTo16_word_www(pInfo->notify, LN_DISCARD,
(char *)pEntry - ptr, pEntry->flags);
pEntry->addr = 0;
pEntry->flags = (LMEM_DISCARDED >> 8);
......@@ -875,7 +880,7 @@ notify_done:
{
#if 0
/* FIXME: doesn't work correctly yet */
if ((pInfo->notify) && (Callbacks->CallLocalNotifyFunc(pInfo->notify, LN_OUTOFMEM, ds - 20, size))) /* FIXME: "size" correct ? (should indicate bytes needed) */
if ((pInfo->notify) && (LOCAL_CallTo16_word_www(pInfo->notify, LN_OUTOFMEM, ds - 20, size))) /* FIXME: "size" correct ? (should indicate bytes needed) */
goto notify_done;
#endif
return 0;
......@@ -898,7 +903,7 @@ notify_done:
#if 0
if ((pInfo->notify) &&
/* FIXME: "size" correct ? (should indicate bytes needed) */
(Callbacks->CallLocalNotifyFunc(pInfo->notify, LN_OUTOFMEM, ds, size)))
(LOCAL_CallTo16_word_www(pInfo->notify, LN_OUTOFMEM, ds, size)))
goto notify_done;
#endif
return 0;
......
......@@ -320,7 +320,7 @@ static void CALLBACK comm_notification( ULONG_PTR private )
/* send notifications, if any */
if (ptr->wnd && mask) {
TRACE("notifying %04x: cid=%d, mask=%02x\n", ptr->wnd, cid, mask);
Callout.PostMessage16(ptr->wnd, WM_COMMNOTIFY, cid, mask);
Callout.PostMessageA(ptr->wnd, WM_COMMNOTIFY, cid, mask);
}
}
......
......@@ -9,6 +9,7 @@
#include "windef.h"
#include "wine/winbase16.h"
#include "ldt.h"
#include "builtin16.h"
#include "global.h"
#include "miscemu.h"
#include "msdos.h"
......@@ -285,7 +286,7 @@ static void DPMI_CallRMCBProc( CONTEXT86 *context, RMCB *rmcb, WORD flag )
ES_reg(&ctx) = rmcb->regs_sel;
EDI_reg(&ctx) = rmcb->regs_ofs;
/* FIXME: I'm pretty sure this isn't right - should push flags first */
Callbacks->CallRegisterShortProc(&ctx, 0);
CallTo16RegisterShort(&ctx, 0);
es = ES_reg(&ctx);
edi = EDI_reg(&ctx);
}
......@@ -626,7 +627,7 @@ static void StartPM( CONTEXT86 *context, LPDOSTASK lpDosTask )
GS_reg(&pm_ctx) = 0;
TRACE("DOS program is now entering protected mode\n");
Callbacks->CallRegisterShortProc(&pm_ctx, 0);
CallTo16RegisterShort(&pm_ctx, 0);
/* in the current state of affairs, we won't ever actually return here... */
/* we should have int21/ah=4c do it someday, though... */
......
......@@ -508,6 +508,8 @@ void BuildSpec16File( FILE *outfile )
fprintf( outfile, "#define __FLATCS__ 0x%04x\n", code_selector );
fprintf( outfile, "#include \"builtin16.h\"\n\n" );
fprintf( outfile, "extern void RELAY_Unimplemented16(void);\n\n" );
data = (unsigned char *)xmalloc( 0x10000 );
memset( data, 0, 16 );
data_offset = 16;
......@@ -585,7 +587,7 @@ void BuildSpec16File( FILE *outfile )
/* Output code segment */
fprintf( outfile, "\nstatic struct\n{\n CALLFROM16 call[%d];\n"
" ENTRYPOINT16 entry[%d];\n} Code_Segment = \n{\n {\n",
" ENTRYPOINT16 entry[%d];\n} Code_Segment = \n{\n {\n",
nTypes, nFuncs );
code_offset = 0;
......@@ -621,15 +623,21 @@ void BuildSpec16File( FILE *outfile )
if ( typelist[i]->type == TYPE_INTERRUPT )
argsize += 2;
fprintf( outfile, " CF16_%s( %s_CallFrom16_%s, %d, \"%s\" ),\n",
( typelist[i]->type == TYPE_REGISTER
|| typelist[i]->type == TYPE_INTERRUPT)? "REGS":
typelist[i]->type == TYPE_PASCAL_16? "WORD" : "LONG",
DLLName, profile, argsize, profile );
fprintf( outfile, " { 0x68, %s_CallFrom16_%s, 0x9a, CallFrom16%s,\n",
DLLName, profile,
(typelist[i]->type == TYPE_REGISTER
|| typelist[i]->type == TYPE_INTERRUPT)? "Register":
typelist[i]->type == TYPE_PASCAL_16? "Word" : "Long" );
if (argsize)
fprintf( outfile, " 0x%04x, 0x66, 0xca, %d, \"%s\" },\n",
code_selector, argsize, profile );
else
fprintf( outfile, " 0x%04x, 0x66, 0xcb, 0x9090, \"%s\" },\n",
code_selector, profile );
code_offset += sizeof(CALLFROM16);
}
fprintf( outfile, " },\n {\n" );
fprintf( outfile, " },\n {\n" );
for (i = 0; i <= Limit; i++)
{
......@@ -665,8 +673,8 @@ void BuildSpec16File( FILE *outfile )
type = bsearch( &odp, typelist, nTypes, sizeof(ORDDEF *), Spec16TypeCompare );
assert( type );
fprintf( outfile, " /* %s.%d */ ", DLLName, i );
fprintf( outfile, "EP( %s, %d /* %s_%s_%s */ ),\n",
fprintf( outfile, " /* %s.%d */ ", DLLName, i );
fprintf( outfile, "{ 0x5566, 0x68, %s, 0xe866, %d /* %s_%s_%s */ },\n",
odp->u.func.link_name,
(type-typelist)*sizeof(CALLFROM16) -
(code_offset + sizeof(ENTRYPOINT16)),
......@@ -743,6 +751,9 @@ void BuildGlue( FILE *outfile, FILE *infile )
fprintf( outfile, "#include \"builtin16.h\"\n" );
fprintf( outfile, "#include \"stackframe.h\"\n\n" );
fprintf( outfile, "extern WORD CALLBACK CallTo16Word( FARPROC16 target, INT nArgs );\n" );
fprintf( outfile, "extern LONG CALLBACK CallTo16Long( FARPROC16 target, INT nArgs );\n" );
/* Build the callback glue functions */
while (fgets( buffer, sizeof(buffer), infile ))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment