Sun Sep 27 14:25:38 1998 Petter Reinholdtsen <pere@td.org.uit.no> * [files/drive.c] Make sure GetDriveType32A() handles param NULL. Added some doc on function. Sun Sep 27 14:07:26 1998 Huw D M Davies <daviesh@abacus.physics.ox.ac.uk> * [controls/edit.c] [windows/win.c] Don't call SetWindowLong() in EDIT_WM_NCREATE. Fix SetWindowLong(GWL_[EX]STYLE) to work for 16bit windows. Remove UpdateWindow() call. Sun Sep 27 13:41:22 1998 Alexandre Julliard <julliard@lrc.epfl.ch> * [scheduler/*.c] [server/event.c] [server/mutex.c] [server/semaphore.c] Implemented server-side synchronisation objects. Sun Sep 27 01:13:35 1998 Alex Priem <alexp@sci.kun.nl> * [dlls/comctl32/treeview.c] [include/treeview.h] [include/comctl.h] Treeview implementation. * [dlls/comctl32/trackbar.c] [include/trackbar.h] Trackbar implementation. Sat Sep 26 20:49:13 1998 Ulrich Weigand <weigand@informatik.uni-erlangen.de> * [if1632/thunk.c] [tools/build.c] [win32/kernel32.c] Bugfix: several problems with flat thunks fixed. * [memory/selector.c] Bugfix: IsBad...Ptr16 didn't work for limit_in_pages segments. * [scheduler/thread.c] Bugfix: CreateThread: Allow id parameter == NULL. * [objects/gdiobj.c] Bugfix: IsGDIObject: Return correct object type for stock objects. * [msdos/dpmi.c] Bugfix: fixed typo in INT_DoRealModeInt. * [msdos/int21.c] Bugfix: int21 READ *must* use WIN16_hread, not _hread16. * [if1632/kernel.spec] [if1632/dummy.c] [if1632/thunk.c] [loader/ne/module.c] [scheduler/event.c] [scheduler/synchro.c] [scheduler/thread.c] [win32/kernel32.c] [win32/ordinals.c] Added names/stubs for all undocumented KERNEL routines (Win95). Added the following undoc. 16-bit equivalents to Win32 routines: KERNEL.441-443,449-453,456-462,471-476,479-486,488. Added stubs for some other KERNEL routines. * [memory/heap.c] [memory/global.c] [include/global.h] Implemented Local32... 32-bit local heap routines (KERNEL.208-215, 229). * [miscemu/instr.c] [loader/module.c] [include/module.h] Implemented __GP fault handling and HasGPHandler (KERNEL.338). * [misc/error.c] Implemented LogParamErrorRegs (KERNEL.327). * [loader/task.c] [include/windows.h] Implemented GetCodeInfo (KERNEL.104). * [loader/task.c] [scheduler/thread.c] [include/thread.h] Implemented [GS]etThreadQueue and [GS]etFastQueue (KERNEL.463/4, 624/5). * [if1632/gdi.spec] [objects/dc.c] [objects/dib.c] [objects/bitmap.c] [include/windows.h] Bugfix: fixed wrong parameter for CreateDIBSection16. Added [GS]etDIBColorTable16, stub for GetBoundsRect16. Partially implemented BITMAP_GetObject16 for DIBs. * [if1632/gdi.spec] [relay32/gdi32.spec] [objects/palette.c] Added some GDI stubs. * [if1632/Makefile.in] [if1632/display.spec] [if1632/mouse.spec] [if1632/keyboard.spec] [if1632/builtin.c] [windows/keyboard.c] Added some stubs for Win16 drivers: KEYBOARD, MOUSE, DISPLAY. * [if1632/wprocs.spec] [msdos/vxd.c] Added some stubs for VxDs: VMM, ConfigMG, TimerAPI. * [msdos/int2f.c] Added some stubs for real-mode network drivers. Sat Sep 26 18:18:18 1998 Marcus Meissner <marcus@jet.franken.de> * [configure.in] Merged in some more of the FreeBSD ports/emulators/wine patches. (Maintainer(s) of this port: You can just submit these patches to Alexandre directly.) * [loader/pe_image.c] Check filesize of image against size derived from header to spot truncated executeables without crashing. * [files/directory.c] Set envvar "COMSPEC". One win32(!!) program crashes without it. * [multimedia/mmio.c] Added mmioSetInfo32. * [include/file.h] Return STD_ERROR_HANDLE for AUX and PRT dos handles. * [loader/module.c] Handle executeables with spaces in their names a bit better in CreateProcess. * [relay32/msvfw32.spec][if1632/msvideo.spec][multimedia/msvideo.c][include/vfw.h] Started on MS Video support (can load Win32 ICMs). * [tools/testrun] A bit smarter use of ps. * [memory/virtual.c] Report PAGE_GUARDed pages as PAGE_PROTECTED (AutoCAD LT R17 fails without that check (since Win95 doesn't know about PAGE_GUARD)). Sat Sep 26 15:04:05 1998 Ove Kaaven <ovek@arcticnet.no> * [include/miscemu.h] [if1632/builtin.c] [loader/task.c] [miscemu/instr.c] [msdos/dpmi.c] [msdos/int21.c] [msdos/interrupts.c] [windows/user.c] INT_[S|G]etHandler was renamed to INT_[S|G]etPMHandler. Added handlers to deal with real-mode interrupts; DOS programs are now able to hook real-mode interrupts. * [loader/dos/module.c] [msdos/dosmem.c] [msdos/int21.c] Moved real-mode interrupt table initialization to msdos/dosmem.c, and made new V86 tasks get a full copy of the existing "system memory" instead of almost empty space. Misc fixes. * [include/dosexe.h] [loader/dos/module.c] [msdos/dpmi.c] [msdos/int2f.c] First shot at letting DOS programs start up DPMI (but DPMI is still disabled for DOS programs, for pkunzip's sake). * [include/debugger.h] [debugger/break.c] [debugger/dbg.y] [debugger/registers.c] [debugger/memory.c] [debugger/info.c] [loader/dos/dosvm.c] First shot at making Wine's debugger work for DOS programs. The -debug flag works, as do "nexti" and "stepi". Sat Sep 26 13:13:13 1998 Juergen Schmied <juergen.schmied@metronet.de> * [dlls/shell32/dataobject.c] New classes IEnumFORMATETC implemented, IDataObject stubs. * [dlls/shell32/*.*][relay32/shell32.spec] Bugfixes. New: ICM_InsertItem(), ILCreateFromPath(). Implemented: ILCloneFirst(). Stubs: ILIsEqual(), ILFindChild(), SHLogILFromFSIL(), PathMatchSpec(), PathIsExe(). Changed: ILGetSize(), _ILIsDesktop(), PathCombine(). * [include/shlobj.h] New SHLGUID's New structures: DVTARGETDEVICE32, STGMEDIUM32, FORMATETC32, CLIPFORMAT32. New interfaces: IEnumFORMATETC, IDataObject, ICommDlgBrowser IDockingWindowFrame, IServiceProvider. * [dlls/shell32/folders.c] Stubs for IShellLink. * [loader/resource.c] Small fixes. * [misc/crtdll.c][relay32/crtdll.spec] New __dllonexit(). * [windows/message.c] SendNotifyMessageA, SendMessageCallBack32A half implemented. * [controls/edit.c] EDIT_WM_SetText set EF_UPDATE flag not for ES_MULTILINE. * [files/file.c] Handling of fileposition fixed. Fri Sep 25 18:13:30 1998 Patrik Stridvall <ps@leissner.se> * [include/windows.h] [include/wintypes.h] [ole/ole2nls.h] [relay32/kernel32.spec] Implemented EnumDateFormats and EnumTimeFormats. Only adds US English support. * [Makefile.in] [configure.in] [dlls/Makefile.in] [dlls/psapi/Makefile.in] [dlls/psapi/psapi_main.c] New files to implement stubs for PSAPI.DLL (NT only). * [relay32/Makefile.in] [relay32/builtin32.c] [relay32/psapi.spec] New spec file for PSAPI.DLL (NT only). * [scheduler/handle.c] HANDLE_GetObjPtr should only interpret the pseudo handles as the current thread or the current process if a thread or a process is requested. * [include/winversion.h] [misc/version.c] Adds the global function VERSION_GetVersion() so functions can have different behavior depending on the -winver flag. * [include/oledlg.h] [ole/oledlg.c] Minor fixes. * [windows/winproc.c] Minor changes. * [include/imm.h] [misc/imm.c] Now returns correct values under both Windows 95 and NT 4.0. Thu Sep 24 22:11:44 1998 Kristian Nielsen <kristian.nielsen@risoe.dk> * [configure.in] [include/acconfig.h] [include/thread.h] [scheduler/sysdeps.c] Autoconfig test for non-reentrant libc. Wed Sep 23 19:52:12 1998 Matthew Becker <mbecker@glasscity.net> * [*/*.c] Miscellaneous documentation updates and debugging output standardizations. * [objects/clipping.c] Added ExtSelectClipRgn. Wed Sep 23 00:03:28 EDT 1998 Pete Ratzlaff <pratzlaff@cfa.harvard.edu> * [include/windows.h] [if1632/user.spec] [relay32/user32.spec] [windows/keyboard.c] Added, marginally implemented, GetKeyboardLayoutName(). Only returns US English keyboard name. Tue Sep 22 16:32:41 1998 Marcel Baur <mbaur@iiic.ethz.ch> * [programs/control/*] New Winelib application. Mon Sep 21 00:29:18 1998 Peter Hunnisett <hunnise@nortel.ca> * [include/dplay.h][multimedia/dplay.c][ole/compobj.c] Added all DirectPlayLobby interfaces and enhanced DirectPlay and DirectPlayLobby support. Still not all that much. Useful enough if you just need to start a program, don't try any real dplay/lobby stuff. * [documentation/status/directplay] Added a very little bit. * [graphics/ddraw.c] - Call to SetWindowLong32A wasn't working because there was no memory set aside when the window class was registered. - Fixed some xlib reference counting and change the behaviour of DirectDrawSurface3_SetPalette to mimic observed behaviour (palette is associated will all backbuffers) - Also stored all palette colour fields and spit back our saved colour fields rather than query X for them. - Added plenty of AddRef and Release traces. - Added Xlib support for using -desktop option. - Fixed Xlib message handling. Messages weren't being passed to the application. Fixes mouse movements in some xlib DDraw games. - Added a few stubs. * [windows/win.c][include/winerror.h] Fixed up some error handling in WIN_SetWindowLong. SetLastError wasn't being used. Could cause problems with 0 return codes. Added new error in winerror (1400). * [AUTHORS] [include/authors.h] Added myself as a Wine author. Sun Sep 20 21:22:44 1998 Alexander Larsson <alla@lysator.liu.se> * [loader/module.c] Changed GetModuleFileName32A so that is returns the long version of the filename. Note that just the name is long, not the directories. Sat Sep 19 20:05:30 1998 Per Ångström <pang@mind.nu> * [controls/menu.c] Made a couple of fixes to make life easier for applications that alter their menus at runtime. * [windows/defdlg.c] Removed the cast of the return value from dialog procedures to a 16-bit bool. The return value needs to retain all its 32 bits, since it is not always a bool, such as when responding to the WM_NCHITTEST message. Fri Sep 18 11:30:38 1998 Sergey Turchanov <turchanov@usa.net> * [loader/resource.c] Fixed very funny bug (though gravely affecting further excecution) with FindResource[Ex]32 functions. * [include/multimon.h] [windows/multimon.c] [relay32/user32.spec] [include/windows.h] [windows/sysmetrics.c] Default implementation for Multimonitor API. * [include/windows.h] [windows/winpos.c] Fixed incorrect declaration (and behaviour) of GetWindowRect32. Wed Sep 16 10:21:15 1998 Gerard Patel <G.Patel@Wanadoo.fr> * [controls/edit.c] Fixed EDIT_EM_GetLine to use correctly length of lines. Tue Sep 15 20:40:16 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de> * [misc/tweak.c][include/tweak.h][controls/menu.c] Replaced the tweak graphic routines by calls to DrawEdge32(). * [misc/tweak.c][include/tweak.h][documentation/win95look] [wine.ini][*/*] Changed "look and feel" selection. Allows Win3.1, Win95 and Win98 (no GUI code implemented) look and feel. * [dlls/comctl32/header.c][include/header.h][include/commctrl.h] Started callback item support and did some minor improvements. * [dlls/comctl32/imagelist.c] Fixed bug in transparent image display. ImageList_GetIcon is still buggy :-( * [dlls/comctl32/toolbar.c] Fixed button drawing (partial hack). * [dlls/comctl32/commctrl.c] Fixed MenuHelp(). * [controls/button.c] Added 3d effect for groupbox. * [windows/msgbox.c] Added font support for message boxes. * [windows/nonclient.c] Fixed window moving bug. * [dlls/comctl32/*.c] Various improvements. * [dlls/comctl32/listview.c][dlls/comctl32/rebar.c] [include/commctrl.h] More messages. * [windows/syscolor.c][include/windows.h] Introduced new Win98 system colors. Tue Sep 15 18:29:45 1998 Wesley Filardo <eightknots@aol.com> * [files/profile.c] Added support in PROFILE_LoadWineIni for -config option * [misc/main.c] [include/options.h] Added -config option. Tue Sep 15 18:22:26 1998 Petter Reinholdtsen <pere@td.org.uit.no> * [documentation/Makefile.in] Make sure directory exists before installing into it. Tue Sep 15 01:47:33 1998 Pablo Saratxaga <pablo.sarachaga@ping.be> * [ole/nls/*] [ole/ole2nls.c] [include/winnls.h] Fixed a few errors and completed some NLS files. Mon Sep 14 01:23:45 1998 Joseph Pranevich <knight@baltimore.wwaves.com> * [include/miscemu.h] [msdos/interrupts.c] Removed a compilation warning, added INT 25 to the list of interrupts callable from DOS applications, added a debug message when unsupported interrupts are used. Sun Sep 13 19:55:22 1998 Lawson Whitney <lawson_whitney@juno.com> * [if1632/relay.c] CallProcEx32W should not reverse arguments. Sun Aug 17 21:18:12 1998 Eric Pouech <eric.pouech@lemel.fr> * [multimedia/midi.c] [multimedia/init.c] [multimedia/mmsys.c] [include/multimedia.h] [include/mmsystem.h] [multimedia/Makefile.in] [multimedia/midipatch.c] [if1632/multimedia.spec] Made MIDI input and output functional on OSS capable systems. * [multimedia/timer.c] Changes to trigger callbacks at the accurate pace even when fake timers are used.
937 lines
32 KiB
C
937 lines
32 KiB
C
/*
|
|
* Emulator thunks
|
|
*
|
|
* Copyright 1996, 1997 Alexandre Julliard
|
|
* Copyright 1998 Ulrich Weigand
|
|
*/
|
|
|
|
#include "windows.h"
|
|
#include "callback.h"
|
|
#include "resource.h"
|
|
#include "task.h"
|
|
#include "user.h"
|
|
#include "heap.h"
|
|
#include "hook.h"
|
|
#include "module.h"
|
|
#include "process.h"
|
|
#include "stackframe.h"
|
|
#include "selectors.h"
|
|
#include "task.h"
|
|
#include "except.h"
|
|
#include "win.h"
|
|
#include "debug.h"
|
|
#include "flatthunk.h"
|
|
|
|
|
|
/* List of the 16-bit callback functions. This list is used */
|
|
/* by the build program to generate the file if1632/callto16.S */
|
|
|
|
/* ### start build ### */
|
|
extern LONG CALLBACK CallTo16_sreg_(const CONTEXT *context, INT32 offset);
|
|
extern LONG CALLBACK CallTo16_lreg_(const CONTEXT *context, INT32 offset);
|
|
extern WORD CALLBACK CallTo16_word_ (FARPROC16);
|
|
extern LONG CALLBACK CallTo16_long_ (FARPROC16);
|
|
extern WORD CALLBACK CallTo16_word_w (FARPROC16,WORD);
|
|
extern LONG CALLBACK CallTo16_long_l (FARPROC16,LONG);
|
|
extern WORD CALLBACK CallTo16_word_ww (FARPROC16,WORD,WORD);
|
|
extern WORD CALLBACK CallTo16_word_wl (FARPROC16,WORD,LONG);
|
|
extern WORD CALLBACK CallTo16_word_ll (FARPROC16,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_ll (FARPROC16,LONG,LONG);
|
|
extern WORD CALLBACK CallTo16_word_www (FARPROC16,WORD,WORD,WORD);
|
|
extern WORD CALLBACK CallTo16_word_wwl (FARPROC16,WORD,WORD,LONG);
|
|
extern WORD CALLBACK CallTo16_word_wlw (FARPROC16,WORD,LONG,WORD);
|
|
extern LONG CALLBACK CallTo16_long_wwl (FARPROC16,WORD,WORD,LONG);
|
|
extern LONG CALLBACK CallTo16_long_lll (FARPROC16,LONG,LONG,LONG);
|
|
extern WORD CALLBACK CallTo16_word_llwl (FARPROC16,LONG,LONG,WORD,LONG);
|
|
extern WORD CALLBACK CallTo16_word_lwll (FARPROC16,LONG,WORD,LONG,LONG);
|
|
extern WORD CALLBACK CallTo16_word_lwww (FARPROC16,LONG,WORD,WORD,WORD);
|
|
extern WORD CALLBACK CallTo16_word_wwll (FARPROC16,WORD,WORD,LONG,LONG);
|
|
extern WORD CALLBACK CallTo16_word_llll (FARPROC16,LONG,LONG,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_llll (FARPROC16,LONG,LONG,LONG,LONG);
|
|
extern WORD CALLBACK CallTo16_word_wllwl(FARPROC16,WORD,LONG,LONG,WORD,LONG);
|
|
extern LONG CALLBACK CallTo16_long_lwwll(FARPROC16,LONG,WORD,WORD,LONG,LONG);
|
|
extern WORD CALLBACK CallTo16_word_wwlll(FARPROC16,WORD,WORD,LONG,LONG,LONG);
|
|
extern WORD CALLBACK CallTo16_word_wwwww(FARPROC16,WORD,WORD,WORD,WORD,WORD);
|
|
extern WORD CALLBACK CallTo16_word_lwlll(FARPROC16,LONG,WORD,LONG,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_lwlll(FARPROC16,LONG,WORD,LONG,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_lllll(FARPROC16,LONG,LONG,LONG,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_llllll(FARPROC16,LONG,LONG,LONG,LONG,LONG,
|
|
LONG);
|
|
extern LONG CALLBACK CallTo16_long_lllllll(FARPROC16,LONG,LONG,LONG,LONG,LONG,
|
|
LONG,LONG);
|
|
extern WORD CALLBACK CallTo16_word_llwwlll(FARPROC16,LONG,LONG,WORD,WORD,LONG,
|
|
LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_word_lwwlllll(FARPROC16,LONG,WORD,WORD,LONG,LONG,
|
|
LONG,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_llllllll(FARPROC16,LONG,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_lllllllll(FARPROC16,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_llllllllll(FARPROC16,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_lllllllllll(FARPROC16,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,LONG,
|
|
LONG);
|
|
extern LONG CALLBACK CallTo16_long_llllllllllll(FARPROC16,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,LONG,
|
|
LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_lwwllwlllllw(FARPROC16,LONG,WORD,WORD,LONG,
|
|
LONG,WORD,LONG,LONG,LONG,LONG,
|
|
LONG,WORD);
|
|
extern LONG CALLBACK CallTo16_long_lllllllllllll(FARPROC16,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_llllllllllllll(FARPROC16,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,
|
|
LONG);
|
|
extern LONG CALLBACK CallTo16_word_lwwwwlwwwwllll(FARPROC16,LONG,WORD,WORD,
|
|
WORD,WORD,LONG,WORD,WORD,
|
|
WORD,WORD,LONG,LONG,LONG,
|
|
LONG);
|
|
extern LONG CALLBACK CallTo16_long_lllllllllllllll(FARPROC16,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,
|
|
LONG,LONG);
|
|
extern LONG CALLBACK CallTo16_long_llllllllllllllll(FARPROC16,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG,LONG,LONG,
|
|
LONG,LONG,LONG);
|
|
/* ### stop build ### */
|
|
|
|
|
|
typedef void (*RELAY)();
|
|
|
|
#pragma pack(1)
|
|
|
|
typedef struct tagTHUNK
|
|
{
|
|
BYTE popl_eax; /* 0x58 popl %eax (return address)*/
|
|
BYTE pushl_func; /* 0x68 pushl $proc */
|
|
FARPROC32 proc WINE_PACKED;
|
|
BYTE pushl_eax; /* 0x50 pushl %eax */
|
|
BYTE jmp; /* 0xe9 jmp relay (relative jump)*/
|
|
RELAY relay WINE_PACKED;
|
|
struct tagTHUNK *next WINE_PACKED;
|
|
} THUNK;
|
|
|
|
#pragma pack(4)
|
|
|
|
#define DECL_THUNK(name,proc,relay) \
|
|
THUNK name = { 0x58, 0x68, (FARPROC32)(proc), 0x50, 0xe9, \
|
|
(RELAY)((char *)(relay) - (char *)(&(name).next)), NULL }
|
|
|
|
|
|
static THUNK *firstThunk = NULL;
|
|
|
|
static LRESULT WINAPI THUNK_CallWndProc16( WNDPROC16 proc, HWND16 hwnd,
|
|
UINT16 msg, WPARAM16 wParam,
|
|
LPARAM lParam );
|
|
static void WINAPI THUNK_CallTaskReschedule(void);
|
|
static BOOL32 WINAPI THUNK_WOWCallback16Ex( FARPROC16,DWORD,DWORD,
|
|
LPVOID,LPDWORD );
|
|
|
|
/* TASK_Reschedule() 16-bit entry point */
|
|
static FARPROC16 TASK_RescheduleProc;
|
|
|
|
extern void CallFrom16_p_long_wwwll(void);
|
|
|
|
/* Callbacks function table for the emulator */
|
|
static const CALLBACKS_TABLE CALLBACK_EmulatorTable =
|
|
{
|
|
(void *)CallTo16_sreg_, /* CallRegisterShortProc */
|
|
(void *)CallTo16_lreg_, /* CallRegisterLongProc */
|
|
THUNK_CallTaskReschedule, /* CallTaskRescheduleProc */
|
|
CallFrom16_p_long_wwwll, /* CallFrom16WndProc */
|
|
THUNK_CallWndProc16, /* CallWndProc */
|
|
(void *)CallTo16_long_lwwll, /* CallDriverProc */
|
|
(void *)CallTo16_word_wwlll, /* CallDriverCallback */
|
|
(void *)CallTo16_word_wwlll, /* CallTimeFuncProc */
|
|
(void *)CallTo16_word_w, /* CallWindowsExitProc */
|
|
(void *)CallTo16_word_lwww, /* CallWordBreakProc */
|
|
(void *)CallTo16_word_ww, /* CallBootAppProc */
|
|
(void *)CallTo16_word_www, /* CallLoadAppSegProc */
|
|
(void *)CallTo16_word_, /* CallSystemTimerProc */
|
|
(void *)CallTo16_word_www, /* CallResourceHandlerProc */
|
|
(void *)CallTo16_long_l, /* CallWOWCallbackProc */
|
|
THUNK_WOWCallback16Ex, /* CallWOWCallback16Ex */
|
|
(void *)CallTo16_long_l, /* CallASPIPostProc */
|
|
(void *)CallTo16_word_lwll, /* CallDrvControlProc */
|
|
(void *)CallTo16_word_lwlll, /* CallDrvEnableProc */
|
|
(void *)CallTo16_word_llll, /* CallDrvEnumDFontsProc */
|
|
(void *)CallTo16_word_lwll, /* CallDrvEnumObjProc */
|
|
(void *)CallTo16_word_lwwlllll, /* CallDrvOutputProc */
|
|
(void *)CallTo16_long_lwlll, /* CallDrvRealizeProc */
|
|
(void *)CallTo16_word_lwwwwlwwwwllll, /* CallDrvStretchBltProc */
|
|
(void *)CallTo16_long_lwwllwlllllw, /* CallDrvExtTextOutProc */
|
|
(void *)CallTo16_word_llwwlll /* CallDrvGetCharWidth */
|
|
};
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_Init
|
|
*/
|
|
BOOL32 THUNK_Init(void)
|
|
{
|
|
/* Set the window proc calling functions */
|
|
Callbacks = &CALLBACK_EmulatorTable;
|
|
/* Get the 16-bit reschedule function pointer */
|
|
TASK_RescheduleProc = MODULE_GetWndProcEntry16( "TASK_Reschedule" );
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_Alloc
|
|
*/
|
|
static THUNK *THUNK_Alloc( FARPROC32 func, RELAY relay )
|
|
{
|
|
THUNK *thunk = HeapAlloc( GetProcessHeap(), 0, sizeof(*thunk) );
|
|
if (thunk)
|
|
{
|
|
thunk->popl_eax = 0x58;
|
|
thunk->pushl_func = 0x68;
|
|
thunk->proc = func;
|
|
thunk->pushl_eax = 0x50;
|
|
thunk->jmp = 0xe9;
|
|
thunk->relay = (RELAY)((char *)relay - (char *)(&thunk->next));
|
|
thunk->next = firstThunk;
|
|
firstThunk = thunk;
|
|
}
|
|
return thunk;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_Find
|
|
*/
|
|
static THUNK *THUNK_Find( FARPROC32 func )
|
|
{
|
|
THUNK *thunk = firstThunk;
|
|
while (thunk && (thunk->proc != func)) thunk = thunk->next;
|
|
return thunk;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_Free
|
|
*/
|
|
static void THUNK_Free( THUNK *thunk )
|
|
{
|
|
if (HEAP_IsInsideHeap( GetProcessHeap(), 0, thunk ))
|
|
{
|
|
THUNK **prev = &firstThunk;
|
|
while (*prev && (*prev != thunk)) prev = &(*prev)->next;
|
|
if (*prev)
|
|
{
|
|
*prev = thunk->next;
|
|
HeapFree( GetProcessHeap(), 0, thunk );
|
|
return;
|
|
}
|
|
}
|
|
ERR(thunk, "invalid thunk addr %p\n", thunk );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_CallWndProc16
|
|
*
|
|
* Call a 16-bit window procedure
|
|
*/
|
|
static LRESULT WINAPI THUNK_CallWndProc16( WNDPROC16 proc, HWND16 hwnd,
|
|
UINT16 msg, WPARAM16 wParam,
|
|
LPARAM lParam )
|
|
{
|
|
CONTEXT context;
|
|
LRESULT ret;
|
|
WORD *args;
|
|
WND *wndPtr = WIN_FindWndPtr( hwnd );
|
|
DWORD offset = 0;
|
|
THDB *thdb = THREAD_Current();
|
|
|
|
/* Window procedures want ax = hInstance, ds = es = ss */
|
|
|
|
memset(&context, '\0', sizeof(context));
|
|
DS_reg(&context) = SELECTOROF(thdb->cur_stack);
|
|
ES_reg(&context) = DS_reg(&context);
|
|
EAX_reg(&context) = wndPtr ? wndPtr->hInstance : DS_reg(&context);
|
|
CS_reg(&context) = SELECTOROF(proc);
|
|
EIP_reg(&context) = OFFSETOF(proc);
|
|
EBP_reg(&context) = OFFSETOF(thdb->cur_stack)
|
|
+ (WORD)&((STACK16FRAME*)0)->bp;
|
|
|
|
if (lParam)
|
|
{
|
|
/* Some programs (eg. the "Undocumented Windows" examples, JWP) only
|
|
work if structures passed in lParam are placed in the stack/data
|
|
segment. Programmers easily make the mistake of converting lParam
|
|
to a near rather than a far pointer, since Windows apparently
|
|
allows this. We copy the structures to the 16 bit stack; this is
|
|
ugly but makes these programs work. */
|
|
switch (msg)
|
|
{
|
|
case WM_CREATE:
|
|
case WM_NCCREATE:
|
|
offset = sizeof(CREATESTRUCT16); break;
|
|
case WM_DRAWITEM:
|
|
offset = sizeof(DRAWITEMSTRUCT16); break;
|
|
case WM_COMPAREITEM:
|
|
offset = sizeof(COMPAREITEMSTRUCT16); break;
|
|
}
|
|
if (offset)
|
|
{
|
|
void *s = PTR_SEG_TO_LIN(lParam);
|
|
lParam = STACK16_PUSH( thdb, offset );
|
|
memcpy( PTR_SEG_TO_LIN(lParam), s, offset );
|
|
}
|
|
}
|
|
|
|
args = (WORD *)THREAD_STACK16(thdb) - 5;
|
|
args[0] = LOWORD(lParam);
|
|
args[1] = HIWORD(lParam);
|
|
args[2] = wParam;
|
|
args[3] = msg;
|
|
args[4] = hwnd;
|
|
|
|
ret = CallTo16_sreg_( &context, 5 * sizeof(WORD) );
|
|
if (offset) STACK16_POP( thdb, offset );
|
|
return ret;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_CallTaskReschedule
|
|
*/
|
|
static void WINAPI THUNK_CallTaskReschedule(void)
|
|
{
|
|
CallTo16_word_(TASK_RescheduleProc);
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_EnumObjects16 (GDI.71)
|
|
*/
|
|
INT16 WINAPI THUNK_EnumObjects16( HDC16 hdc, INT16 nObjType,
|
|
GOBJENUMPROC16 func, LPARAM lParam )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_ll );
|
|
return EnumObjects16( hdc, nObjType, (GOBJENUMPROC16)&thunk, lParam );
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* THUNK_EnumFonts16 (GDI.70)
|
|
*/
|
|
INT16 WINAPI THUNK_EnumFonts16( HDC16 hdc, LPCSTR lpFaceName,
|
|
FONTENUMPROC16 func, LPARAM lParam )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_llwl );
|
|
return EnumFonts16( hdc, lpFaceName, (FONTENUMPROC16)&thunk, lParam );
|
|
}
|
|
|
|
/******************************************************************
|
|
* THUNK_EnumMetaFile16 (GDI.175)
|
|
*/
|
|
BOOL16 WINAPI THUNK_EnumMetaFile16( HDC16 hdc, HMETAFILE16 hmf,
|
|
MFENUMPROC16 func, LPARAM lParam )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_wllwl );
|
|
return EnumMetaFile16( hdc, hmf, (MFENUMPROC16)&thunk, lParam );
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* THUNK_EnumFontFamilies16 (GDI.330)
|
|
*/
|
|
INT16 WINAPI THUNK_EnumFontFamilies16( HDC16 hdc, LPCSTR lpszFamily,
|
|
FONTENUMPROC16 func, LPARAM lParam )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_llwl );
|
|
return EnumFontFamilies16(hdc, lpszFamily, (FONTENUMPROC16)&thunk, lParam);
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* THUNK_EnumFontFamiliesEx16 (GDI.613)
|
|
*/
|
|
INT16 WINAPI THUNK_EnumFontFamiliesEx16( HDC16 hdc, LPLOGFONT16 lpLF,
|
|
FONTENUMPROCEX16 func, LPARAM lParam,
|
|
DWORD reserved )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_llwl );
|
|
return EnumFontFamiliesEx16( hdc, lpLF, (FONTENUMPROCEX16)&thunk,
|
|
lParam, reserved );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* THUNK_LineDDA16 (GDI.100)
|
|
*/
|
|
void WINAPI THUNK_LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd,
|
|
INT16 nYEnd, LINEDDAPROC16 func, LPARAM lParam )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_wwl );
|
|
LineDDA16( nXStart, nYStart, nXEnd, nYEnd, (LINEDDAPROC16)&thunk, lParam );
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
* THUNK_EnumWindows16 (USER.54)
|
|
*/
|
|
BOOL16 WINAPI THUNK_EnumWindows16( WNDENUMPROC16 func, LPARAM lParam )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_wl );
|
|
return EnumWindows16( (WNDENUMPROC16)&thunk, lParam );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* THUNK_EnumChildWindows16 (USER.55)
|
|
*/
|
|
BOOL16 WINAPI THUNK_EnumChildWindows16( HWND16 parent, WNDENUMPROC16 func,
|
|
LPARAM lParam )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_wl );
|
|
return EnumChildWindows16( parent, (WNDENUMPROC16)&thunk, lParam );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* THUNK_EnumTaskWindows16 (USER.225)
|
|
*/
|
|
BOOL16 WINAPI THUNK_EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func,
|
|
LPARAM lParam )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_wl );
|
|
return EnumTaskWindows16( hTask, (WNDENUMPROC16)&thunk, lParam );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_EnumProps16 (USER.27)
|
|
*/
|
|
INT16 WINAPI THUNK_EnumProps16( HWND16 hwnd, PROPENUMPROC16 func )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_wlw );
|
|
return EnumProps16( hwnd, (PROPENUMPROC16)&thunk );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_GrayString16 (USER.185)
|
|
*/
|
|
BOOL16 WINAPI THUNK_GrayString16( HDC16 hdc, HBRUSH16 hbr,
|
|
GRAYSTRINGPROC16 func, LPARAM lParam,
|
|
INT16 cch, INT16 x, INT16 y,
|
|
INT16 cx, INT16 cy )
|
|
{
|
|
DECL_THUNK( thunk, func, CallTo16_word_wlw );
|
|
if (!func)
|
|
return GrayString16( hdc, hbr, NULL, lParam, cch, x, y, cx, cy );
|
|
else
|
|
return GrayString16( hdc, hbr, (GRAYSTRINGPROC16)&thunk, lParam, cch,
|
|
x, y, cx, cy );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_SetWindowsHook16 (USER.121)
|
|
*/
|
|
FARPROC16 WINAPI THUNK_SetWindowsHook16( INT16 id, HOOKPROC16 proc )
|
|
{
|
|
HINSTANCE16 hInst = FarGetOwner( HIWORD(proc) );
|
|
HTASK16 hTask = (id == WH_MSGFILTER) ? GetCurrentTask() : 0;
|
|
THUNK *thunk = THUNK_Alloc( (FARPROC16)proc, (RELAY)CallTo16_long_wwl );
|
|
if (!thunk) return 0;
|
|
return (FARPROC16)SetWindowsHookEx16( id, (HOOKPROC16)thunk, hInst, hTask);
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_UnhookWindowsHook16 (USER.234)
|
|
*/
|
|
BOOL16 WINAPI THUNK_UnhookWindowsHook16( INT16 id, HOOKPROC16 proc )
|
|
{
|
|
BOOL16 ret;
|
|
THUNK *thunk = THUNK_Find( (FARPROC16)proc );
|
|
if (!thunk) return FALSE;
|
|
ret = UnhookWindowsHook16( id, (HOOKPROC16)thunk );
|
|
THUNK_Free( thunk );
|
|
return ret;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_SetWindowsHookEx16 (USER.291)
|
|
*/
|
|
HHOOK WINAPI THUNK_SetWindowsHookEx16( INT16 id, HOOKPROC16 proc,
|
|
HINSTANCE16 hInst, HTASK16 hTask )
|
|
{
|
|
THUNK *thunk = THUNK_Alloc( (FARPROC16)proc, (RELAY)CallTo16_long_wwl );
|
|
if (!thunk) return 0;
|
|
return SetWindowsHookEx16( id, (HOOKPROC16)thunk, hInst, hTask );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_UnhookWindowHookEx16 (USER.292)
|
|
*/
|
|
BOOL16 WINAPI THUNK_UnhookWindowsHookEx16( HHOOK hhook )
|
|
{
|
|
THUNK *thunk = (THUNK *)HOOK_GetProc16( hhook );
|
|
BOOL16 ret = UnhookWindowsHookEx16( hhook );
|
|
if (thunk) THUNK_Free( thunk );
|
|
return ret;
|
|
}
|
|
|
|
|
|
|
|
static FARPROC16 defDCHookProc = NULL;
|
|
|
|
/***********************************************************************
|
|
* THUNK_SetDCHook (GDI.190)
|
|
*/
|
|
BOOL16 WINAPI THUNK_SetDCHook( HDC16 hdc, FARPROC16 proc, DWORD dwHookData )
|
|
{
|
|
THUNK *thunk, *oldThunk;
|
|
|
|
if (!defDCHookProc) /* Get DCHook Win16 entry point */
|
|
defDCHookProc = NE_GetEntryPoint( GetModuleHandle16("USER"), 362 );
|
|
|
|
if (proc != defDCHookProc)
|
|
{
|
|
thunk = THUNK_Alloc( proc, (RELAY)CallTo16_word_wwll );
|
|
if (!thunk) return FALSE;
|
|
}
|
|
else thunk = (THUNK *)DCHook;
|
|
|
|
/* Free the previous thunk */
|
|
GetDCHook( hdc, (FARPROC16 *)&oldThunk );
|
|
if (oldThunk && (oldThunk != (THUNK *)DCHook)) THUNK_Free( oldThunk );
|
|
|
|
return SetDCHook( hdc, (FARPROC16)thunk, dwHookData );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_GetDCHook (GDI.191)
|
|
*/
|
|
DWORD WINAPI THUNK_GetDCHook( HDC16 hdc, FARPROC16 *phookProc )
|
|
{
|
|
THUNK *thunk = NULL;
|
|
DWORD ret = GetDCHook( hdc, (FARPROC16 *)&thunk );
|
|
if (thunk)
|
|
{
|
|
if (thunk == (THUNK *)DCHook)
|
|
{
|
|
if (!defDCHookProc) /* Get DCHook Win16 entry point */
|
|
defDCHookProc = NE_GetEntryPoint(GetModuleHandle16("USER"),362);
|
|
*phookProc = defDCHookProc;
|
|
}
|
|
else *phookProc = thunk->proc;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* THUNK_SetTaskSignalProc (KERNEL.38)
|
|
*/
|
|
FARPROC16 WINAPI THUNK_SetTaskSignalProc( HTASK16 hTask, FARPROC16 proc )
|
|
{
|
|
static FARPROC16 defSignalProc16 = NULL;
|
|
|
|
THUNK *thunk = NULL;
|
|
|
|
if( !defSignalProc16 )
|
|
defSignalProc16 = NE_GetEntryPoint(GetModuleHandle16("USER"), 314 );
|
|
|
|
if( proc == defSignalProc16 )
|
|
thunk = (THUNK*)SetTaskSignalProc( hTask, (FARPROC16)&USER_SignalProc );
|
|
else
|
|
{
|
|
thunk = THUNK_Alloc( proc, (RELAY)CallTo16_word_wwwww );
|
|
if( !thunk ) return FALSE;
|
|
thunk = (THUNK*)SetTaskSignalProc( hTask, (FARPROC16)thunk );
|
|
}
|
|
|
|
if( thunk != (THUNK*)USER_SignalProc )
|
|
{
|
|
if( !thunk ) return NULL;
|
|
|
|
proc = thunk->proc;
|
|
THUNK_Free( thunk );
|
|
return proc;
|
|
}
|
|
return defSignalProc16;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* THUNK_CreateThread16 (KERNEL.441)
|
|
*/
|
|
static DWORD CALLBACK THUNK_StartThread16( LPVOID threadArgs )
|
|
{
|
|
FARPROC16 start = ((FARPROC16 *)threadArgs)[0];
|
|
DWORD param = ((DWORD *)threadArgs)[1];
|
|
HeapFree( GetProcessHeap(), 0, threadArgs );
|
|
|
|
return CallTo16_long_l( start, param );
|
|
}
|
|
HANDLE32 WINAPI THUNK_CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
|
|
FARPROC16 start, SEGPTR param,
|
|
DWORD flags, LPDWORD id )
|
|
{
|
|
DWORD *threadArgs = HeapAlloc( GetProcessHeap(), 0, 2*sizeof(DWORD) );
|
|
if (!threadArgs) return INVALID_HANDLE_VALUE32;
|
|
threadArgs[0] = (DWORD)start;
|
|
threadArgs[1] = (DWORD)param;
|
|
|
|
return CreateThread( sa, stack, THUNK_StartThread16, threadArgs, flags, id );
|
|
}
|
|
|
|
/***********************************************************************
|
|
* THUNK_WOWCallback16Ex (WOW32.3)(KERNEL32.55)
|
|
* Generic thunking routine to call 16 bit functions from 32bit code.
|
|
*
|
|
* RETURNS
|
|
* TRUE if the call was done
|
|
*/
|
|
static BOOL32 WINAPI THUNK_WOWCallback16Ex(
|
|
FARPROC16 proc, /* [in] 16bit function to call */
|
|
DWORD dwFlags, /* [in] flags (WCB_*) */
|
|
DWORD cbArgs, /* [in] number of arguments */
|
|
LPVOID xargs, /* [in/out] arguments */
|
|
LPDWORD pdwret /* [out] return value of the 16bit call */
|
|
) {
|
|
LPDWORD args = (LPDWORD)xargs;
|
|
DWORD ret,i;
|
|
|
|
TRACE(relay,"(%p,0x%08lx,%ld,%p,%p)\n",
|
|
proc,dwFlags,cbArgs,xargs,pdwret
|
|
);
|
|
if (dwFlags == WCB16_CDECL) {
|
|
/* swap the arguments */
|
|
args = HeapAlloc(GetProcessHeap(),0,cbArgs*sizeof(DWORD));
|
|
for (i=0;i<cbArgs;i++)
|
|
args[i] = ((DWORD*)xargs)[cbArgs-i-1];
|
|
}
|
|
switch (cbArgs) {
|
|
case 0: ret = CallTo16_long_(proc);break;
|
|
case 1: ret = CallTo16_long_l(proc,args[0]);break;
|
|
case 2: ret = CallTo16_long_ll(proc,args[0],args[1]);break;
|
|
case 3: ret = CallTo16_long_lll(proc,args[0],args[1],args[2]);break;
|
|
case 4: ret = CallTo16_long_llll(proc,args[0],args[1],args[2],args[3]);
|
|
break;
|
|
case 5: ret = CallTo16_long_lllll(proc,args[0],args[1],args[2],args[3],
|
|
args[4]
|
|
);
|
|
break;
|
|
case 6: ret = CallTo16_long_llllll(proc,args[0],args[1],args[2],args[3],
|
|
args[4],args[5]
|
|
);
|
|
break;
|
|
case 7: ret = CallTo16_long_lllllll(proc,args[0],args[1],args[2],args[3],
|
|
args[4],args[5],args[6]
|
|
);
|
|
break;
|
|
case 8: ret = CallTo16_long_llllllll(proc,args[0],args[1],args[2],args[3],
|
|
args[4],args[5],args[6],args[7]
|
|
);
|
|
break;
|
|
case 9: ret = CallTo16_long_lllllllll(proc,args[0],args[1],args[2],args[3],
|
|
args[4],args[5],args[6],args[7],args[8]
|
|
);
|
|
break;
|
|
case 10:ret = CallTo16_long_llllllllll(proc,args[0],args[1],args[2],args[3],
|
|
args[4],args[5],args[6],args[7],args[8],args[9]
|
|
);
|
|
break;
|
|
case 11:ret = CallTo16_long_lllllllllll(proc,args[0],args[1],args[2],
|
|
args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10]
|
|
);
|
|
break;
|
|
case 12:ret = CallTo16_long_llllllllllll(proc,args[0],args[1],args[2],
|
|
args[3],args[4],args[5],args[6],args[7],args[8],args[9],
|
|
args[10],args[11]
|
|
);
|
|
break;
|
|
case 13:ret = CallTo16_long_lllllllllllll(proc,args[0],args[1],args[2],
|
|
args[3],args[4],args[5],args[6],args[7],args[8],args[9],
|
|
args[10],args[11],args[12]
|
|
);
|
|
break;
|
|
case 14:ret = CallTo16_long_llllllllllllll(proc,args[0],args[1],args[2],
|
|
args[3],args[4],args[5],args[6],args[7],args[8],args[9],
|
|
args[10],args[11],args[12],args[13]
|
|
);
|
|
break;
|
|
case 15:ret = CallTo16_long_lllllllllllllll(proc,args[0],args[1],args[2],
|
|
args[3],args[4],args[5],args[6],args[7],args[8],args[9],
|
|
args[10],args[11],args[12],args[13],args[14]
|
|
);
|
|
break;
|
|
case 16:ret = CallTo16_long_llllllllllllllll(proc,args[0],args[1],args[2],
|
|
args[3],args[4],args[5],args[6],args[7],args[8],args[9],
|
|
args[10],args[11],args[12],args[13],args[14],args[15]
|
|
);
|
|
break;
|
|
default:
|
|
ERR(thunk,"%ld arguments not supported.\n",cbArgs);
|
|
if (dwFlags == WCB16_CDECL)
|
|
HeapFree(GetProcessHeap(),0,args);
|
|
return FALSE;
|
|
}
|
|
if (dwFlags == WCB16_CDECL)
|
|
HeapFree(GetProcessHeap(),0,args);
|
|
if (pdwret)
|
|
*pdwret = ret;
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* 16->32 Flat Thunk routines:
|
|
*/
|
|
|
|
/***********************************************************************
|
|
* ThunkConnect16 (KERNEL.651)
|
|
* Connects a 32bit and a 16bit thunkbuffer.
|
|
*/
|
|
UINT32 WINAPI ThunkConnect16(
|
|
LPSTR module16, /* [in] name of win16 dll */
|
|
LPSTR module32, /* [in] name of win32 dll */
|
|
HINSTANCE16 hInst16, /* [in] hInst of win16 dll */
|
|
DWORD dwReason, /* [in] initialisation argument */
|
|
struct ThunkDataCommon *TD, /* [in/out] thunkbuffer */
|
|
LPSTR thunkfun32, /* [in] win32 thunkfunction */
|
|
WORD CS /* [in] CS of win16 dll */
|
|
) {
|
|
BOOL32 directionSL;
|
|
|
|
if (!lstrncmp32A(TD->magic, "SL01", 4))
|
|
{
|
|
directionSL = TRUE;
|
|
|
|
TRACE(thunk, "SL01 thunk %s (%lx) -> %s (%s), Reason: %ld\n",
|
|
module16, (DWORD)TD, module32, thunkfun32, dwReason);
|
|
}
|
|
else if (!lstrncmp32A(TD->magic, "LS01", 4))
|
|
{
|
|
directionSL = FALSE;
|
|
|
|
TRACE(thunk, "LS01 thunk %s (%lx) <- %s (%s), Reason: %ld\n",
|
|
module16, (DWORD)TD, module32, thunkfun32, dwReason);
|
|
}
|
|
else
|
|
{
|
|
ERR(thunk, "Invalid magic %c%c%c%c\n",
|
|
TD->magic[0], TD->magic[1], TD->magic[2], TD->magic[3]);
|
|
return 0;
|
|
}
|
|
|
|
switch (dwReason)
|
|
{
|
|
case DLL_PROCESS_ATTACH:
|
|
if (directionSL)
|
|
{
|
|
struct ThunkDataSL16 *SL16 = (struct ThunkDataSL16 *)TD;
|
|
struct ThunkDataSL *SL = SL16->fpData;
|
|
|
|
if (SL == NULL)
|
|
{
|
|
SL = HeapAlloc(GetProcessHeap(), 0, sizeof(*SL));
|
|
|
|
SL->common = SL16->common;
|
|
SL->flags1 = SL16->flags1;
|
|
SL->flags2 = SL16->flags2;
|
|
|
|
SL->apiDB = PTR_SEG_TO_LIN(SL16->apiDatabase);
|
|
SL->targetDB = NULL;
|
|
|
|
lstrcpyn32A(SL->pszDll16, module16, 255);
|
|
lstrcpyn32A(SL->pszDll32, module32, 255);
|
|
|
|
/* We should create a SEGPTR to the ThunkDataSL,
|
|
but since the contents are not in the original format,
|
|
any access to this by 16-bit code would crash anyway. */
|
|
SL16->spData = 0;
|
|
SL16->fpData = SL;
|
|
}
|
|
|
|
|
|
if (SL->flags2 & 0x80000000)
|
|
{
|
|
TRACE(thunk, "Preloading 32-bit library\n");
|
|
LoadLibrary32A(module32);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
/* nothing to do */
|
|
}
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
/* FIXME: cleanup */
|
|
break;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* C16ThkSL (KERNEL.630)
|
|
*/
|
|
|
|
void WINAPI C16ThkSL(CONTEXT *context)
|
|
{
|
|
extern void CallFrom16_t_long_(void);
|
|
LPBYTE stub = PTR_SEG_TO_LIN(EAX_reg(context)), x = stub;
|
|
WORD cs, ds;
|
|
GET_CS(cs);
|
|
GET_DS(ds);
|
|
|
|
/* We produce the following code:
|
|
*
|
|
* mov ax, __FLATDS
|
|
* mov es, ax
|
|
* movzx ecx, cx
|
|
* mov edx, es:[ecx + $EDX]
|
|
* push bp
|
|
* push edx
|
|
* call __FLATCS:CallFrom16_t_long_
|
|
*/
|
|
|
|
*x++ = 0xB8; *((WORD *)x)++ = ds;
|
|
*x++ = 0x8E; *x++ = 0xC0;
|
|
*x++ = 0x66; *x++ = 0x0F; *x++ = 0xB7; *x++ = 0xC9;
|
|
*x++ = 0x67; *x++ = 0x66; *x++ = 0x26; *x++ = 0x8B;
|
|
*x++ = 0x91; *((DWORD *)x)++ = EDX_reg(context);
|
|
|
|
*x++ = 0x55;
|
|
*x++ = 0x66; *x++ = 0x52;
|
|
*x++ = 0x66; *x++ = 0x9A; *((DWORD *)x)++ = (DWORD)CallFrom16_t_long_;
|
|
*((WORD *)x)++ = cs;
|
|
|
|
/* Jump to the stub code just created */
|
|
IP_reg(context) = LOWORD(EAX_reg(context));
|
|
CS_reg(context) = HIWORD(EAX_reg(context));
|
|
|
|
/* Since C16ThkSL got called by a jmp, we need to leave the
|
|
orginal return address on the stack */
|
|
SP_reg(context) -= 4;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* C16ThkSL01 (KERNEL.631)
|
|
*/
|
|
|
|
void WINAPI C16ThkSL01(CONTEXT *context)
|
|
{
|
|
LPBYTE stub = PTR_SEG_TO_LIN(EAX_reg(context)), x = stub;
|
|
|
|
if (stub)
|
|
{
|
|
struct ThunkDataSL16 *SL16 = PTR_SEG_TO_LIN(EDX_reg(context));
|
|
struct ThunkDataSL *td = SL16->fpData;
|
|
|
|
extern void CallFrom16_t_long_(void);
|
|
DWORD procAddress = (DWORD)GetProcAddress16(GetModuleHandle16("KERNEL"), 631);
|
|
WORD cs;
|
|
GET_CS(cs);
|
|
|
|
if (!td)
|
|
{
|
|
ERR(thunk, "ThunkConnect16 was not called!\n");
|
|
return;
|
|
}
|
|
|
|
TRACE(thunk, "Creating stub for ThunkDataSL %08lx\n", (DWORD)td);
|
|
|
|
|
|
/* We produce the following code:
|
|
*
|
|
* xor eax, eax
|
|
* mov edx, $td
|
|
* call C16ThkSL01
|
|
* push bp
|
|
* push edx
|
|
* call __FLATCS:CallFrom16_t_long_
|
|
*/
|
|
|
|
*x++ = 0x66; *x++ = 0x33; *x++ = 0xC0;
|
|
*x++ = 0x66; *x++ = 0xBA; *((DWORD *)x)++ = (DWORD)td;
|
|
*x++ = 0x9A; *((DWORD *)x)++ = procAddress;
|
|
|
|
*x++ = 0x55;
|
|
*x++ = 0x66; *x++ = 0x52;
|
|
*x++ = 0x66; *x++ = 0x9A; *((DWORD *)x)++ = (DWORD)CallFrom16_t_long_;
|
|
*((WORD *)x)++ = cs;
|
|
|
|
/* Jump to the stub code just created */
|
|
IP_reg(context) = LOWORD(EAX_reg(context));
|
|
CS_reg(context) = HIWORD(EAX_reg(context));
|
|
|
|
/* Since C16ThkSL01 got called by a jmp, we need to leave the
|
|
orginal return address on the stack */
|
|
SP_reg(context) -= 4;
|
|
}
|
|
else
|
|
{
|
|
struct ThunkDataSL *td = (struct ThunkDataSL *)EDX_reg(context);
|
|
DWORD targetNr = CX_reg(context) / 4;
|
|
struct SLTargetDB *tdb;
|
|
|
|
TRACE(thunk, "Process %08lx calling target %ld of ThunkDataSL %08lx\n",
|
|
(DWORD)PROCESS_Current(), targetNr, (DWORD)td);
|
|
|
|
for (tdb = td->targetDB; tdb; tdb = tdb->next)
|
|
if (tdb->process == PROCESS_Current())
|
|
break;
|
|
|
|
if (!tdb)
|
|
{
|
|
TRACE(thunk, "Loading 32-bit library %s\n", td->pszDll32);
|
|
LoadLibrary32A(td->pszDll32);
|
|
|
|
for (tdb = td->targetDB; tdb; tdb = tdb->next)
|
|
if (tdb->process == PROCESS_Current())
|
|
break;
|
|
}
|
|
|
|
if (tdb)
|
|
{
|
|
EDX_reg(context) = tdb->targetTable[targetNr];
|
|
|
|
TRACE(thunk, "Call target is %08lx\n", EDX_reg(context));
|
|
}
|
|
else
|
|
{
|
|
WORD *stack = PTR_SEG_OFF_TO_LIN(SS_reg(context), SP_reg(context));
|
|
DX_reg(context) = HIWORD(td->apiDB[targetNr].errorReturnValue);
|
|
AX_reg(context) = LOWORD(td->apiDB[targetNr].errorReturnValue);
|
|
IP_reg(context) = stack[2];
|
|
CS_reg(context) = stack[3];
|
|
SP_reg(context) += td->apiDB[targetNr].nrArgBytes + 4;
|
|
|
|
ERR(thunk, "Process %08lx did not ThunkConnect32 %s to %s\n",
|
|
(DWORD)PROCESS_Current(), td->pszDll32, td->pszDll16);
|
|
}
|
|
}
|
|
}
|
|
|
|
DWORD WINAPI
|
|
WOW16Call(WORD x,WORD y,WORD z) {
|
|
int i;
|
|
DWORD calladdr;
|
|
FIXME(thunk,"(0x%04x,0x%04x,%d),calling (",x,y,z);
|
|
|
|
for (i=0;i<x/2;i++) {
|
|
WORD a = STACK16_POP(THREAD_Current(),2);
|
|
DPRINTF("%04x ",a);
|
|
}
|
|
calladdr = STACK16_POP(THREAD_Current(),4);
|
|
DPRINTF(") calling address was 0x%08lx\n",calladdr);
|
|
return 0;
|
|
}
|