Moved thunking functions off to kernel32.dll.
This commit is contained in:
parent
cd770eafcd
commit
d5041fc45a
|
@ -388,7 +388,7 @@ ddraw/libddraw.so: libx11drv.so
|
||||||
dplayx/libdplayx.so: libole32.so
|
dplayx/libdplayx.so: libole32.so
|
||||||
dsound/libdsound.so: libwinmm.so
|
dsound/libdsound.so: libwinmm.so
|
||||||
msvideo/libmsvfw32.so: libwinmm.so
|
msvideo/libmsvfw32.so: libwinmm.so
|
||||||
ole32/libole32.so: librpcrt4.so
|
ole32/libole32.so: librpcrt4.so libkernel32.so
|
||||||
oleaut32/liboleaut32.so: libole32.so libcomctl32.so
|
oleaut32/liboleaut32.so: libole32.so libcomctl32.so
|
||||||
olecli/libolecli32.so: libolesvr32.so libole32.so
|
olecli/libolecli32.so: libolesvr32.so libole32.so
|
||||||
olepro32/libolepro32.so: liboleaut32.so libole32.so
|
olepro32/libolepro32.so: liboleaut32.so libole32.so
|
||||||
|
@ -398,6 +398,7 @@ shfolder/libshfolder.so: libshell32.so
|
||||||
shlwapi/libshlwapi.so: libshell32.so
|
shlwapi/libshlwapi.so: libshell32.so
|
||||||
urlmon/liburlmon.so: libole32.so
|
urlmon/liburlmon.so: libole32.so
|
||||||
version/libversion.so: liblz32.so
|
version/libversion.so: liblz32.so
|
||||||
|
win32s/libw32skrnl.so: libkernel32.so
|
||||||
winmm/joystick/libjoystick.drv.so: libwinmm.so
|
winmm/joystick/libjoystick.drv.so: libwinmm.so
|
||||||
winmm/mcianim/libmcianim.drv.so: libwinmm.so
|
winmm/mcianim/libmcianim.drv.so: libwinmm.so
|
||||||
winmm/mciavi/libmciavi.drv.so: libwinmm.so
|
winmm/mciavi/libmciavi.drv.so: libwinmm.so
|
||||||
|
|
|
@ -8,8 +8,11 @@ ALTNAMES = comm kernel system toolhelp windebug win87em wprocs
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
kernel_main.c \
|
kernel_main.c \
|
||||||
|
thunk.c \
|
||||||
|
utthunk.c \
|
||||||
win87em.c \
|
win87em.c \
|
||||||
windebug.c
|
windebug.c \
|
||||||
|
wowthunk.c
|
||||||
|
|
||||||
RC_SRCS = \
|
RC_SRCS = \
|
||||||
locale_rc.rc
|
locale_rc.rc
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
|
|
||||||
struct _PDB;
|
|
||||||
|
|
||||||
struct ThunkDataCommon
|
struct ThunkDataCommon
|
||||||
{
|
{
|
||||||
char magic[4]; /* 00 */
|
char magic[4]; /* 00 */
|
||||||
|
@ -100,7 +98,7 @@ struct ThunkDataSL
|
||||||
struct SLTargetDB
|
struct SLTargetDB
|
||||||
{
|
{
|
||||||
struct SLTargetDB * next;
|
struct SLTargetDB * next;
|
||||||
struct _PDB * process;
|
DWORD process;
|
||||||
DWORD * targetTable;
|
DWORD * targetTable;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
extern void CODEPAGE_Init(void);
|
extern void CODEPAGE_Init(void);
|
||||||
|
extern BOOL THUNK_Init(void);
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* KERNEL process initialisation routine
|
* KERNEL process initialisation routine
|
||||||
|
@ -27,6 +29,9 @@ static BOOL process_attach(void)
|
||||||
/* Setup codepage info */
|
/* Setup codepage info */
|
||||||
CODEPAGE_Init();
|
CODEPAGE_Init();
|
||||||
|
|
||||||
|
/* Initialize thunking */
|
||||||
|
if (!THUNK_Init()) return FALSE;
|
||||||
|
|
||||||
/* Initialize DOS memory */
|
/* Initialize DOS memory */
|
||||||
if (!DOSMEM_Init(0)) return FALSE;
|
if (!DOSMEM_Init(0)) return FALSE;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,7 +5,7 @@ VPATH = @srcdir@
|
||||||
MODULE = ole32
|
MODULE = ole32
|
||||||
SOVERSION = 1.0
|
SOVERSION = 1.0
|
||||||
ALTNAMES = ole2 ole2nls ole2conv ole2prox ole2thk storage compobj
|
ALTNAMES = ole2 ole2nls ole2conv ole2prox ole2thk storage compobj
|
||||||
IMPORTS = rpcrt4
|
IMPORTS = rpcrt4 kernel32
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
antimoniker.c \
|
antimoniker.c \
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
name ole32
|
name ole32
|
||||||
type win32
|
type win32
|
||||||
|
|
||||||
import rpcrt4
|
import rpcrt4
|
||||||
|
import kernel32
|
||||||
|
|
||||||
1 stub BindMoniker # stdcall (ptr long ptr ptr) return 0,ERR_NOTIMPLEMENTED
|
1 stub BindMoniker # stdcall (ptr long ptr ptr) return 0,ERR_NOTIMPLEMENTED
|
||||||
2 stdcall CLSIDFromProgID(wstr ptr) CLSIDFromProgID
|
2 stdcall CLSIDFromProgID(wstr ptr) CLSIDFromProgID
|
||||||
|
|
|
@ -5,6 +5,7 @@ VPATH = @srcdir@
|
||||||
MODULE = w32skrnl
|
MODULE = w32skrnl
|
||||||
SOVERSION = 1.0
|
SOVERSION = 1.0
|
||||||
ALTNAMES = w32sys win32s16
|
ALTNAMES = w32sys win32s16
|
||||||
|
IMPORTS = kernel32
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
w32skernel.c \
|
w32skernel.c \
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
name w32skrnl
|
name w32skrnl
|
||||||
type win32
|
type win32
|
||||||
|
|
||||||
|
import kernel32.dll
|
||||||
|
|
||||||
1 stub _kSetEnvironmentVariable@8
|
1 stub _kSetEnvironmentVariable@8
|
||||||
2 stub _SzFromImte@4
|
2 stub _SzFromImte@4
|
||||||
3 stdcall GetCurrentTask32() GetCurrentTask
|
3 stdcall GetCurrentTask32() GetCurrentTask
|
||||||
|
|
|
@ -53,9 +53,7 @@ BOOL RELAY_Init(void)
|
||||||
CALL32_CBClientEx_RetAddr =
|
CALL32_CBClientEx_RetAddr =
|
||||||
PTR_SEG_OFF_TO_SEGPTR( codesel, (char*)CALL32_CBClientEx_Ret - (char*)Call16_Ret_Start );
|
PTR_SEG_OFF_TO_SEGPTR( codesel, (char*)CALL32_CBClientEx_Ret - (char*)Call16_Ret_Start );
|
||||||
#endif
|
#endif
|
||||||
|
return TRUE;
|
||||||
/* Initialize thunking */
|
|
||||||
return THUNK_Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -338,85 +336,3 @@ void RELAY_DebugCallTo16Ret( int ret_val )
|
||||||
OFFSETOF(NtCurrentTeb()->cur_stack), ret_val);
|
OFFSETOF(NtCurrentTeb()->cur_stack), ret_val);
|
||||||
SYSLEVEL_CheckNotLevel( 2 );
|
SYSLEVEL_CheckNotLevel( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* Catch (KERNEL.55)
|
|
||||||
*
|
|
||||||
* Real prototype is:
|
|
||||||
* INT16 WINAPI Catch( LPCATCHBUF lpbuf );
|
|
||||||
*/
|
|
||||||
void WINAPI Catch16( LPCATCHBUF lpbuf, CONTEXT86 *context )
|
|
||||||
{
|
|
||||||
/* 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] = LOWORD(EIP_reg(context));
|
|
||||||
lpbuf[1] = CS_reg(context);
|
|
||||||
/* Windows pushes 4 more words before saving sp */
|
|
||||||
lpbuf[2] = LOWORD(ESP_reg(context)) - 4 * sizeof(WORD);
|
|
||||||
lpbuf[3] = LOWORD(EBP_reg(context));
|
|
||||||
lpbuf[4] = LOWORD(ESI_reg(context));
|
|
||||||
lpbuf[5] = LOWORD(EDI_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 Throw16( LPCATCHBUF lpbuf, INT16 retval, CONTEXT86 *context )
|
|
||||||
{
|
|
||||||
STACK16FRAME *pFrame;
|
|
||||||
STACK32FRAME *frame32;
|
|
||||||
TEB *teb = NtCurrentTeb();
|
|
||||||
|
|
||||||
AX_reg(context) = retval;
|
|
||||||
|
|
||||||
/* Find the frame32 corresponding to the frame16 we are jumping to */
|
|
||||||
pFrame = THREAD_STACK16(teb);
|
|
||||||
frame32 = pFrame->frame32;
|
|
||||||
while (frame32 && frame32->frame16)
|
|
||||||
{
|
|
||||||
if (OFFSETOF(frame32->frame16) < OFFSETOF(teb->cur_stack))
|
|
||||||
break; /* Something strange is going on */
|
|
||||||
if (OFFSETOF(frame32->frame16) > lpbuf[2])
|
|
||||||
{
|
|
||||||
/* We found the right frame */
|
|
||||||
pFrame->frame32 = frame32;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
frame32 = ((STACK16FRAME *)PTR_SEG_TO_LIN(frame32->frame16))->frame32;
|
|
||||||
}
|
|
||||||
|
|
||||||
EIP_reg(context) = lpbuf[0];
|
|
||||||
CS_reg(context) = lpbuf[1];
|
|
||||||
ESP_reg(context) = lpbuf[2] + 4 * sizeof(WORD) - sizeof(WORD) /*extra arg*/;
|
|
||||||
EBP_reg(context) = lpbuf[3];
|
|
||||||
ESI_reg(context) = lpbuf[4];
|
|
||||||
EDI_reg(context) = lpbuf[5];
|
|
||||||
DS_reg(context) = lpbuf[6];
|
|
||||||
|
|
||||||
if (lpbuf[8] != SS_reg(context))
|
|
||||||
ERR("Switching stack segment with Throw() not supported; expect crash now\n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
683
if1632/thunk.c
683
if1632/thunk.c
|
@ -7,21 +7,16 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "wine/winbase16.h"
|
#include "wine/winbase16.h"
|
||||||
#include "task.h"
|
|
||||||
#include "hook.h"
|
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
#include "builtin16.h"
|
#include "builtin16.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
|
#include "module.h"
|
||||||
#include "neexe.h"
|
#include "neexe.h"
|
||||||
#include "process.h"
|
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
#include "win.h"
|
|
||||||
#include "flatthunk.h"
|
|
||||||
#include "selectors.h"
|
#include "selectors.h"
|
||||||
#include "keyboard.h"
|
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(thunk)
|
DEFAULT_DEBUG_CHANNEL(thunk);
|
||||||
|
|
||||||
|
|
||||||
/* List of the 16-bit callback functions. This list is used */
|
/* List of the 16-bit callback functions. This list is used */
|
||||||
|
@ -45,8 +40,6 @@ extern WORD CALLBACK THUNK_CallTo16_word_lwwww(FARPROC16,LONG,WORD,WORD,WORD,WOR
|
||||||
|
|
||||||
static THUNK *firstThunk = NULL;
|
static THUNK *firstThunk = NULL;
|
||||||
|
|
||||||
static BOOL THUNK_ThunkletInit( void );
|
|
||||||
|
|
||||||
/* Callbacks function table for the emulator */
|
/* Callbacks function table for the emulator */
|
||||||
static const CALLBACKS_TABLE CALLBACK_EmulatorTable =
|
static const CALLBACKS_TABLE CALLBACK_EmulatorTable =
|
||||||
{
|
{
|
||||||
|
@ -67,15 +60,6 @@ const CALLBACKS_TABLE *Callbacks = &CALLBACK_EmulatorTable;
|
||||||
CALLOUT_TABLE Callout = { 0 };
|
CALLOUT_TABLE Callout = { 0 };
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* THUNK_Init
|
|
||||||
*/
|
|
||||||
BOOL THUNK_Init(void)
|
|
||||||
{
|
|
||||||
/* Initialize Thunklets */
|
|
||||||
return THUNK_ThunkletInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* THUNK_Alloc
|
* THUNK_Alloc
|
||||||
*/
|
*/
|
||||||
|
@ -236,666 +220,3 @@ void THUNK_InitCallout(void)
|
||||||
#undef GETADDR
|
#undef GETADDR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* 16->32 Flat Thunk routines:
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* ThunkConnect16 (KERNEL.651)
|
|
||||||
* Connects a 32bit and a 16bit thunkbuffer.
|
|
||||||
*/
|
|
||||||
UINT 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 */
|
|
||||||
) {
|
|
||||||
BOOL directionSL;
|
|
||||||
|
|
||||||
if (!strncmp(TD->magic, "SL01", 4))
|
|
||||||
{
|
|
||||||
directionSL = TRUE;
|
|
||||||
|
|
||||||
TRACE("SL01 thunk %s (%lx) -> %s (%s), Reason: %ld\n",
|
|
||||||
module16, (DWORD)TD, module32, thunkfun32, dwReason);
|
|
||||||
}
|
|
||||||
else if (!strncmp(TD->magic, "LS01", 4))
|
|
||||||
{
|
|
||||||
directionSL = FALSE;
|
|
||||||
|
|
||||||
TRACE("LS01 thunk %s (%lx) <- %s (%s), Reason: %ld\n",
|
|
||||||
module16, (DWORD)TD, module32, thunkfun32, dwReason);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ERR("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;
|
|
||||||
|
|
||||||
lstrcpynA(SL->pszDll16, module16, 255);
|
|
||||||
lstrcpynA(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("Preloading 32-bit library\n");
|
|
||||||
LoadLibraryA(module32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* nothing to do */
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DLL_PROCESS_DETACH:
|
|
||||||
/* FIXME: cleanup */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* C16ThkSL (KERNEL.630)
|
|
||||||
*/
|
|
||||||
|
|
||||||
void WINAPI C16ThkSL(CONTEXT86 *context)
|
|
||||||
{
|
|
||||||
LPBYTE stub = PTR_SEG_TO_LIN(EAX_reg(context)), x = stub;
|
|
||||||
WORD cs = __get_cs();
|
|
||||||
WORD ds = __get_ds();
|
|
||||||
|
|
||||||
/* We produce the following code:
|
|
||||||
*
|
|
||||||
* mov ax, __FLATDS
|
|
||||||
* mov es, ax
|
|
||||||
* movzx ecx, cx
|
|
||||||
* mov edx, es:[ecx + $EDX]
|
|
||||||
* push bp
|
|
||||||
* push edx
|
|
||||||
* push dx
|
|
||||||
* push edx
|
|
||||||
* call __FLATCS:CallFrom16Thunk
|
|
||||||
*/
|
|
||||||
|
|
||||||
*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++ = 0x52;
|
|
||||||
*x++ = 0x66; *x++ = 0x52;
|
|
||||||
*x++ = 0x66; *x++ = 0x9A; *((DWORD *)x)++ = (DWORD)CallFrom16Thunk;
|
|
||||||
*((WORD *)x)++ = cs;
|
|
||||||
|
|
||||||
/* Jump to the stub code just created */
|
|
||||||
EIP_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
|
|
||||||
original return address on the stack */
|
|
||||||
ESP_reg(context) -= 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* C16ThkSL01 (KERNEL.631)
|
|
||||||
*/
|
|
||||||
|
|
||||||
void WINAPI C16ThkSL01(CONTEXT86 *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;
|
|
||||||
|
|
||||||
DWORD procAddress = (DWORD)GetProcAddress16(GetModuleHandle16("KERNEL"), 631);
|
|
||||||
WORD cs = __get_cs();
|
|
||||||
|
|
||||||
if (!td)
|
|
||||||
{
|
|
||||||
ERR("ThunkConnect16 was not called!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("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
|
|
||||||
* push dx
|
|
||||||
* push edx
|
|
||||||
* call __FLATCS:CallFrom16Thunk
|
|
||||||
*/
|
|
||||||
|
|
||||||
*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++ = 0x52;
|
|
||||||
*x++ = 0x66; *x++ = 0x52;
|
|
||||||
*x++ = 0x66; *x++ = 0x9A; *((DWORD *)x)++ = (DWORD)CallFrom16Thunk;
|
|
||||||
*((WORD *)x)++ = cs;
|
|
||||||
|
|
||||||
/* Jump to the stub code just created */
|
|
||||||
EIP_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 */
|
|
||||||
ESP_reg(context) -= 4;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct ThunkDataSL *td = (struct ThunkDataSL *)EDX_reg(context);
|
|
||||||
DWORD targetNr = CX_reg(context) / 4;
|
|
||||||
struct SLTargetDB *tdb;
|
|
||||||
|
|
||||||
TRACE("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("Loading 32-bit library %s\n", td->pszDll32);
|
|
||||||
LoadLibraryA(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("Call target is %08lx\n", EDX_reg(context));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WORD *stack = PTR_SEG_OFF_TO_LIN(SS_reg(context), LOWORD(ESP_reg(context)));
|
|
||||||
DX_reg(context) = HIWORD(td->apiDB[targetNr].errorReturnValue);
|
|
||||||
AX_reg(context) = LOWORD(td->apiDB[targetNr].errorReturnValue);
|
|
||||||
EIP_reg(context) = stack[2];
|
|
||||||
CS_reg(context) = stack[3];
|
|
||||||
ESP_reg(context) += td->apiDB[targetNr].nrArgBytes + 4;
|
|
||||||
|
|
||||||
ERR("Process %08lx did not ThunkConnect32 %s to %s\n",
|
|
||||||
(DWORD)PROCESS_Current(), td->pszDll32, td->pszDll16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* 16<->32 Thunklet/Callback API:
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pshpack1.h"
|
|
||||||
typedef struct _THUNKLET
|
|
||||||
{
|
|
||||||
BYTE prefix_target;
|
|
||||||
BYTE pushl_target;
|
|
||||||
DWORD target;
|
|
||||||
|
|
||||||
BYTE prefix_relay;
|
|
||||||
BYTE pushl_relay;
|
|
||||||
DWORD relay;
|
|
||||||
|
|
||||||
BYTE jmp_glue;
|
|
||||||
DWORD glue;
|
|
||||||
|
|
||||||
BYTE type;
|
|
||||||
HINSTANCE16 owner;
|
|
||||||
struct _THUNKLET *next;
|
|
||||||
} THUNKLET;
|
|
||||||
#include "poppack.h"
|
|
||||||
|
|
||||||
#define THUNKLET_TYPE_LS 1
|
|
||||||
#define THUNKLET_TYPE_SL 2
|
|
||||||
|
|
||||||
static HANDLE ThunkletHeap = 0;
|
|
||||||
static THUNKLET *ThunkletAnchor = NULL;
|
|
||||||
|
|
||||||
static FARPROC ThunkletSysthunkGlueLS = 0;
|
|
||||||
static SEGPTR ThunkletSysthunkGlueSL = 0;
|
|
||||||
|
|
||||||
static FARPROC ThunkletCallbackGlueLS = 0;
|
|
||||||
static SEGPTR ThunkletCallbackGlueSL = 0;
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* THUNK_ThunkletInit
|
|
||||||
*/
|
|
||||||
static BOOL THUNK_ThunkletInit( void )
|
|
||||||
{
|
|
||||||
LPBYTE thunk;
|
|
||||||
|
|
||||||
ThunkletHeap = HeapCreate(HEAP_WINE_SEGPTR | HEAP_WINE_CODE16SEG, 0, 0);
|
|
||||||
if (!ThunkletHeap) return FALSE;
|
|
||||||
|
|
||||||
thunk = HeapAlloc( ThunkletHeap, 0, 5 );
|
|
||||||
if (!thunk) return FALSE;
|
|
||||||
|
|
||||||
ThunkletSysthunkGlueLS = (FARPROC)thunk;
|
|
||||||
*thunk++ = 0x58; /* popl eax */
|
|
||||||
*thunk++ = 0xC3; /* ret */
|
|
||||||
|
|
||||||
ThunkletSysthunkGlueSL = HEAP_GetSegptr( ThunkletHeap, 0, thunk );
|
|
||||||
*thunk++ = 0x66; *thunk++ = 0x58; /* popl eax */
|
|
||||||
*thunk++ = 0xCB; /* lret */
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* SetThunkletCallbackGlue (KERNEL.560)
|
|
||||||
*/
|
|
||||||
void WINAPI SetThunkletCallbackGlue16( FARPROC glueLS, SEGPTR glueSL )
|
|
||||||
{
|
|
||||||
ThunkletCallbackGlueLS = glueLS;
|
|
||||||
ThunkletCallbackGlueSL = glueSL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* THUNK_FindThunklet
|
|
||||||
*/
|
|
||||||
THUNKLET *THUNK_FindThunklet( DWORD target, DWORD relay,
|
|
||||||
DWORD glue, BYTE type )
|
|
||||||
{
|
|
||||||
THUNKLET *thunk;
|
|
||||||
|
|
||||||
for (thunk = ThunkletAnchor; thunk; thunk = thunk->next)
|
|
||||||
if ( thunk->type == type
|
|
||||||
&& thunk->target == target
|
|
||||||
&& thunk->relay == relay
|
|
||||||
&& ( type == THUNKLET_TYPE_LS ?
|
|
||||||
( thunk->glue == glue - (DWORD)&thunk->type )
|
|
||||||
: ( thunk->glue == glue ) ) )
|
|
||||||
return thunk;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* THUNK_AllocLSThunklet
|
|
||||||
*/
|
|
||||||
FARPROC THUNK_AllocLSThunklet( SEGPTR target, DWORD relay,
|
|
||||||
FARPROC glue, HTASK16 owner )
|
|
||||||
{
|
|
||||||
THUNKLET *thunk = THUNK_FindThunklet( (DWORD)target, relay, (DWORD)glue,
|
|
||||||
THUNKLET_TYPE_LS );
|
|
||||||
if (!thunk)
|
|
||||||
{
|
|
||||||
TDB *pTask = (TDB*)GlobalLock16( owner );
|
|
||||||
|
|
||||||
if ( !(thunk = HeapAlloc( ThunkletHeap, 0, sizeof(THUNKLET) )) )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
thunk->prefix_target = thunk->prefix_relay = 0x90;
|
|
||||||
thunk->pushl_target = thunk->pushl_relay = 0x68;
|
|
||||||
thunk->jmp_glue = 0xE9;
|
|
||||||
|
|
||||||
thunk->target = (DWORD)target;
|
|
||||||
thunk->relay = (DWORD)relay;
|
|
||||||
thunk->glue = (DWORD)glue - (DWORD)&thunk->type;
|
|
||||||
|
|
||||||
thunk->type = THUNKLET_TYPE_LS;
|
|
||||||
thunk->owner = pTask? pTask->hInstance : 0;
|
|
||||||
|
|
||||||
thunk->next = ThunkletAnchor;
|
|
||||||
ThunkletAnchor = thunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (FARPROC)thunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* THUNK_AllocSLThunklet
|
|
||||||
*/
|
|
||||||
SEGPTR THUNK_AllocSLThunklet( FARPROC target, DWORD relay,
|
|
||||||
SEGPTR glue, HTASK16 owner )
|
|
||||||
{
|
|
||||||
THUNKLET *thunk = THUNK_FindThunklet( (DWORD)target, relay, (DWORD)glue,
|
|
||||||
THUNKLET_TYPE_SL );
|
|
||||||
if (!thunk)
|
|
||||||
{
|
|
||||||
TDB *pTask = (TDB*)GlobalLock16( owner );
|
|
||||||
|
|
||||||
if ( !(thunk = HeapAlloc( ThunkletHeap, 0, sizeof(THUNKLET) )) )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
thunk->prefix_target = thunk->prefix_relay = 0x66;
|
|
||||||
thunk->pushl_target = thunk->pushl_relay = 0x68;
|
|
||||||
thunk->jmp_glue = 0xEA;
|
|
||||||
|
|
||||||
thunk->target = (DWORD)target;
|
|
||||||
thunk->relay = (DWORD)relay;
|
|
||||||
thunk->glue = (DWORD)glue;
|
|
||||||
|
|
||||||
thunk->type = THUNKLET_TYPE_SL;
|
|
||||||
thunk->owner = pTask? pTask->hInstance : 0;
|
|
||||||
|
|
||||||
thunk->next = ThunkletAnchor;
|
|
||||||
ThunkletAnchor = thunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEAP_GetSegptr( ThunkletHeap, 0, thunk );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* IsLSThunklet
|
|
||||||
*/
|
|
||||||
BOOL16 WINAPI IsLSThunklet( THUNKLET *thunk )
|
|
||||||
{
|
|
||||||
return thunk->prefix_target == 0x90 && thunk->pushl_target == 0x68
|
|
||||||
&& thunk->prefix_relay == 0x90 && thunk->pushl_relay == 0x68
|
|
||||||
&& thunk->jmp_glue == 0xE9 && thunk->type == THUNKLET_TYPE_LS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* IsSLThunklet (KERNEL.612)
|
|
||||||
*/
|
|
||||||
BOOL16 WINAPI IsSLThunklet16( THUNKLET *thunk )
|
|
||||||
{
|
|
||||||
return thunk->prefix_target == 0x66 && thunk->pushl_target == 0x68
|
|
||||||
&& thunk->prefix_relay == 0x66 && thunk->pushl_relay == 0x68
|
|
||||||
&& thunk->jmp_glue == 0xEA && thunk->type == THUNKLET_TYPE_SL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* AllocLSThunkletSysthunk (KERNEL.607)
|
|
||||||
*/
|
|
||||||
FARPROC WINAPI AllocLSThunkletSysthunk16( SEGPTR target,
|
|
||||||
FARPROC relay, DWORD dummy )
|
|
||||||
{
|
|
||||||
return THUNK_AllocLSThunklet( (SEGPTR)relay, (DWORD)target,
|
|
||||||
ThunkletSysthunkGlueLS, GetCurrentTask() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* AllocSLThunkletSysthunk (KERNEL.608)
|
|
||||||
*/
|
|
||||||
SEGPTR WINAPI AllocSLThunkletSysthunk16( FARPROC target,
|
|
||||||
SEGPTR relay, DWORD dummy )
|
|
||||||
{
|
|
||||||
return THUNK_AllocSLThunklet( (FARPROC)relay, (DWORD)target,
|
|
||||||
ThunkletSysthunkGlueSL, GetCurrentTask() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* AllocLSThunkletCallbackEx (KERNEL.567)
|
|
||||||
*/
|
|
||||||
FARPROC WINAPI AllocLSThunkletCallbackEx16( SEGPTR target,
|
|
||||||
DWORD relay, HTASK16 task )
|
|
||||||
{
|
|
||||||
THUNKLET *thunk = (THUNKLET *)PTR_SEG_TO_LIN( target );
|
|
||||||
if ( !thunk ) return NULL;
|
|
||||||
|
|
||||||
if ( IsSLThunklet16( thunk ) && thunk->relay == relay
|
|
||||||
&& thunk->glue == (DWORD)ThunkletCallbackGlueSL )
|
|
||||||
return (FARPROC)thunk->target;
|
|
||||||
|
|
||||||
return THUNK_AllocLSThunklet( target, relay,
|
|
||||||
ThunkletCallbackGlueLS, task );
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* AllocSLThunkletCallbackEx (KERNEL.568)
|
|
||||||
*/
|
|
||||||
SEGPTR WINAPI AllocSLThunkletCallbackEx16( FARPROC target,
|
|
||||||
DWORD relay, HTASK16 task )
|
|
||||||
{
|
|
||||||
THUNKLET *thunk = (THUNKLET *)target;
|
|
||||||
if ( !thunk ) return 0;
|
|
||||||
|
|
||||||
if ( IsLSThunklet( thunk ) && thunk->relay == relay
|
|
||||||
&& thunk->glue == (DWORD)ThunkletCallbackGlueLS - (DWORD)&thunk->type )
|
|
||||||
return (SEGPTR)thunk->target;
|
|
||||||
|
|
||||||
return THUNK_AllocSLThunklet( target, relay,
|
|
||||||
ThunkletCallbackGlueSL, task );
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* AllocLSThunkletCallback (KERNEL.561) (KERNEL.606)
|
|
||||||
*/
|
|
||||||
FARPROC WINAPI AllocLSThunkletCallback16( SEGPTR target, DWORD relay )
|
|
||||||
{
|
|
||||||
return AllocLSThunkletCallbackEx16( target, relay, GetCurrentTask() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* AllocSLThunkletCallback (KERNEL.562) (KERNEL.605)
|
|
||||||
*/
|
|
||||||
SEGPTR WINAPI AllocSLThunkletCallback16( FARPROC target, DWORD relay )
|
|
||||||
{
|
|
||||||
return AllocSLThunkletCallbackEx16( target, relay, GetCurrentTask() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* FindLSThunkletCallback (KERNEL.563) (KERNEL.609)
|
|
||||||
*/
|
|
||||||
FARPROC WINAPI FindLSThunkletCallback( SEGPTR target, DWORD relay )
|
|
||||||
{
|
|
||||||
THUNKLET *thunk = (THUNKLET *)PTR_SEG_TO_LIN( target );
|
|
||||||
if ( thunk && IsSLThunklet16( thunk ) && thunk->relay == relay
|
|
||||||
&& thunk->glue == (DWORD)ThunkletCallbackGlueSL )
|
|
||||||
return (FARPROC)thunk->target;
|
|
||||||
|
|
||||||
thunk = THUNK_FindThunklet( (DWORD)target, relay,
|
|
||||||
(DWORD)ThunkletCallbackGlueLS,
|
|
||||||
THUNKLET_TYPE_LS );
|
|
||||||
return (FARPROC)thunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* FindSLThunkletCallback (KERNEL.564) (KERNEL.610)
|
|
||||||
*/
|
|
||||||
SEGPTR WINAPI FindSLThunkletCallback( FARPROC target, DWORD relay )
|
|
||||||
{
|
|
||||||
THUNKLET *thunk = (THUNKLET *)target;
|
|
||||||
if ( thunk && IsLSThunklet( thunk ) && thunk->relay == relay
|
|
||||||
&& thunk->glue == (DWORD)ThunkletCallbackGlueLS - (DWORD)&thunk->type )
|
|
||||||
return (SEGPTR)thunk->target;
|
|
||||||
|
|
||||||
thunk = THUNK_FindThunklet( (DWORD)target, relay,
|
|
||||||
(DWORD)ThunkletCallbackGlueSL,
|
|
||||||
THUNKLET_TYPE_SL );
|
|
||||||
return HEAP_GetSegptr( ThunkletHeap, 0, thunk );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* FreeThunklet16 (KERNEL.611)
|
|
||||||
*/
|
|
||||||
BOOL16 WINAPI FreeThunklet16( DWORD unused1, DWORD unused2 )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* Callback Client API
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define N_CBC_FIXED 20
|
|
||||||
#define N_CBC_VARIABLE 10
|
|
||||||
#define N_CBC_TOTAL (N_CBC_FIXED + N_CBC_VARIABLE)
|
|
||||||
|
|
||||||
static SEGPTR CBClientRelay16[ N_CBC_TOTAL ];
|
|
||||||
static FARPROC *CBClientRelay32[ N_CBC_TOTAL ];
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* RegisterCBClient (KERNEL.619)
|
|
||||||
*/
|
|
||||||
INT16 WINAPI RegisterCBClient16( INT16 wCBCId,
|
|
||||||
SEGPTR relay16, FARPROC *relay32 )
|
|
||||||
{
|
|
||||||
/* Search for free Callback ID */
|
|
||||||
if ( wCBCId == -1 )
|
|
||||||
for ( wCBCId = N_CBC_FIXED; wCBCId < N_CBC_TOTAL; wCBCId++ )
|
|
||||||
if ( !CBClientRelay16[ wCBCId ] )
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Register Callback ID */
|
|
||||||
if ( wCBCId > 0 && wCBCId < N_CBC_TOTAL )
|
|
||||||
{
|
|
||||||
CBClientRelay16[ wCBCId ] = relay16;
|
|
||||||
CBClientRelay32[ wCBCId ] = relay32;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
wCBCId = 0;
|
|
||||||
|
|
||||||
return wCBCId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* UnRegisterCBClient (KERNEL.622)
|
|
||||||
*/
|
|
||||||
INT16 WINAPI UnRegisterCBClient16( INT16 wCBCId,
|
|
||||||
SEGPTR relay16, FARPROC *relay32 )
|
|
||||||
{
|
|
||||||
if ( wCBCId >= N_CBC_FIXED && wCBCId < N_CBC_TOTAL
|
|
||||||
&& CBClientRelay16[ wCBCId ] == relay16
|
|
||||||
&& CBClientRelay32[ wCBCId ] == relay32 )
|
|
||||||
{
|
|
||||||
CBClientRelay16[ wCBCId ] = 0;
|
|
||||||
CBClientRelay32[ wCBCId ] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
wCBCId = 0;
|
|
||||||
|
|
||||||
return wCBCId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* InitCBClient (KERNEL.623)
|
|
||||||
*/
|
|
||||||
void WINAPI InitCBClient16( FARPROC glueLS )
|
|
||||||
{
|
|
||||||
HMODULE16 kernel = GetModuleHandle16( "KERNEL" );
|
|
||||||
SEGPTR glueSL = (SEGPTR)WIN32_GetProcAddress16( kernel, (LPCSTR)604 );
|
|
||||||
|
|
||||||
SetThunkletCallbackGlue16( glueLS, glueSL );
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* CBClientGlueSL (KERNEL.604)
|
|
||||||
*/
|
|
||||||
void WINAPI CBClientGlueSL( CONTEXT86 *context )
|
|
||||||
{
|
|
||||||
/* Create stack frame */
|
|
||||||
SEGPTR stackSeg = stack16_push( 12 );
|
|
||||||
LPWORD stackLin = PTR_SEG_TO_LIN( stackSeg );
|
|
||||||
SEGPTR glue, *glueTab;
|
|
||||||
|
|
||||||
stackLin[3] = BP_reg( context );
|
|
||||||
stackLin[2] = SI_reg( context );
|
|
||||||
stackLin[1] = DI_reg( context );
|
|
||||||
stackLin[0] = DS_reg( context );
|
|
||||||
|
|
||||||
EBP_reg( context ) = OFFSETOF( stackSeg ) + 6;
|
|
||||||
ESP_reg( context ) = OFFSETOF( stackSeg ) - 4;
|
|
||||||
GS_reg( context ) = 0;
|
|
||||||
|
|
||||||
/* Jump to 16-bit relay code */
|
|
||||||
glueTab = PTR_SEG_TO_LIN( CBClientRelay16[ stackLin[5] ] );
|
|
||||||
glue = glueTab[ stackLin[4] ];
|
|
||||||
CS_reg ( context ) = SELECTOROF( glue );
|
|
||||||
EIP_reg( context ) = OFFSETOF ( glue );
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* CBClientThunkSL (KERNEL.620)
|
|
||||||
*/
|
|
||||||
extern DWORD CALL32_CBClient( FARPROC proc, LPWORD args, DWORD *esi );
|
|
||||||
void WINAPI CBClientThunkSL( CONTEXT86 *context )
|
|
||||||
{
|
|
||||||
/* Call 32-bit relay code */
|
|
||||||
|
|
||||||
LPWORD args = PTR_SEG_OFF_TO_LIN( SS_reg( context ), BP_reg( context ) );
|
|
||||||
FARPROC proc = CBClientRelay32[ args[2] ][ args[1] ];
|
|
||||||
|
|
||||||
EAX_reg(context) = CALL32_CBClient( proc, args, &ESI_reg( context ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* CBClientThunkSLEx (KERNEL.621)
|
|
||||||
*/
|
|
||||||
extern DWORD CALL32_CBClientEx( FARPROC proc, LPWORD args, DWORD *esi, INT *nArgs );
|
|
||||||
void WINAPI CBClientThunkSLEx( CONTEXT86 *context )
|
|
||||||
{
|
|
||||||
/* Call 32-bit relay code */
|
|
||||||
|
|
||||||
LPWORD args = PTR_SEG_OFF_TO_LIN( SS_reg( context ), BP_reg( context ) );
|
|
||||||
FARPROC proc = CBClientRelay32[ args[2] ][ args[1] ];
|
|
||||||
INT nArgs;
|
|
||||||
LPWORD stackLin;
|
|
||||||
|
|
||||||
EAX_reg(context) = CALL32_CBClientEx( proc, args, &ESI_reg( context ), &nArgs );
|
|
||||||
|
|
||||||
/* Restore registers saved by CBClientGlueSL */
|
|
||||||
stackLin = (LPWORD)((LPBYTE)CURRENT_STACK16 + sizeof(STACK16FRAME) - 4);
|
|
||||||
BP_reg( context ) = stackLin[3];
|
|
||||||
SI_reg( context ) = stackLin[2];
|
|
||||||
DI_reg( context ) = stackLin[1];
|
|
||||||
DS_reg( context ) = stackLin[0];
|
|
||||||
ESP_reg( context ) += 16+nArgs;
|
|
||||||
|
|
||||||
/* Return to caller of CBClient thunklet */
|
|
||||||
CS_reg ( context ) = stackLin[9];
|
|
||||||
EIP_reg( context ) = stackLin[8];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ C_SRCS = \
|
||||||
toolhelp.c \
|
toolhelp.c \
|
||||||
tweak.c \
|
tweak.c \
|
||||||
version.c \
|
version.c \
|
||||||
w32scomb.c \
|
|
||||||
wsprintf.c
|
wsprintf.c
|
||||||
|
|
||||||
GLUE = printdrv.c
|
GLUE = printdrv.c
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* W32SCOMB
|
|
||||||
* DLL for Win32s
|
|
||||||
*
|
|
||||||
* Copyright (c) 1997 Andreas Mohr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "windef.h"
|
|
||||||
#include "wine/winbase16.h"
|
|
||||||
#include "module.h"
|
|
||||||
#include "ldt.h"
|
|
||||||
#include "selectors.h"
|
|
||||||
#include "heap.h"
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* Get16DLLAddress (KERNEL32)
|
|
||||||
*
|
|
||||||
* This function is used by a Win32s DLL if it wants to call a Win16 function.
|
|
||||||
* A 16:16 segmented pointer to the function is returned.
|
|
||||||
* Written without any docu.
|
|
||||||
*/
|
|
||||||
SEGPTR WINAPI Get16DLLAddress(HMODULE handle, LPSTR func_name) {
|
|
||||||
HANDLE ThunkHeap = HeapCreate(HEAP_WINE_SEGPTR | HEAP_WINE_CODESEG, 0, 64);
|
|
||||||
LPBYTE x;
|
|
||||||
LPVOID tmpheap = HeapAlloc(ThunkHeap, 0, 32);
|
|
||||||
SEGPTR thunk = HEAP_GetSegptr(ThunkHeap, 0, tmpheap);
|
|
||||||
DWORD proc_16;
|
|
||||||
|
|
||||||
if (!handle) handle=GetModuleHandle16("WIN32S16");
|
|
||||||
proc_16 = (DWORD)WIN32_GetProcAddress16(handle, func_name);
|
|
||||||
|
|
||||||
x=PTR_SEG_TO_LIN(thunk);
|
|
||||||
*x++=0xba; *(DWORD*)x=proc_16;x+=4; /* movl proc_16, $edx */
|
|
||||||
*x++=0xea; *(DWORD*)x=(DWORD)GetProcAddress(GetModuleHandleA("KERNEL32"),"QT_Thunk");x+=4; /* jmpl QT_Thunk */
|
|
||||||
*(WORD*)x=__get_cs();
|
|
||||||
return thunk;
|
|
||||||
}
|
|
|
@ -8,9 +8,7 @@ MODULE = relay32
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
builtin32.c \
|
builtin32.c \
|
||||||
relay386.c \
|
relay386.c \
|
||||||
snoop.c \
|
snoop.c
|
||||||
utthunk.c \
|
|
||||||
wowthunk.c
|
|
||||||
|
|
||||||
all: $(MODULE).o
|
all: $(MODULE).o
|
||||||
|
|
||||||
|
|
1177
win32/kernel32.c
1177
win32/kernel32.c
File diff suppressed because it is too large
Load Diff
|
@ -17,77 +17,8 @@
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
DECLARE_DEBUG_CHANNEL(dosmem)
|
DECLARE_DEBUG_CHANNEL(win);
|
||||||
DECLARE_DEBUG_CHANNEL(thread)
|
|
||||||
DECLARE_DEBUG_CHANNEL(win)
|
|
||||||
DECLARE_DEBUG_CHANNEL(win32)
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* GetWin16DOSEnv (KERNEL32.34)
|
|
||||||
* Returns some internal value.... probably the default environment database?
|
|
||||||
*/
|
|
||||||
DWORD WINAPI GetWin16DOSEnv()
|
|
||||||
{
|
|
||||||
FIXME_(dosmem)("stub, returning 0\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* GetPK16SysVar (KERNEL32.92)
|
|
||||||
*/
|
|
||||||
LPVOID WINAPI GetPK16SysVar(void)
|
|
||||||
{
|
|
||||||
static BYTE PK16SysVar[128];
|
|
||||||
|
|
||||||
FIXME_(win32)("()\n");
|
|
||||||
return PK16SysVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* CommonUnimpStub (KERNEL32.17)
|
|
||||||
*/
|
|
||||||
void WINAPI CommonUnimpStub( CONTEXT86 *context )
|
|
||||||
{
|
|
||||||
if (EAX_reg(context))
|
|
||||||
MESSAGE( "*** Unimplemented Win32 API: %s\n", (LPSTR)EAX_reg(context) );
|
|
||||||
|
|
||||||
switch ((ECX_reg(context) >> 4) & 0x0f)
|
|
||||||
{
|
|
||||||
case 15: EAX_reg(context) = -1; break;
|
|
||||||
case 14: EAX_reg(context) = 0x78; break;
|
|
||||||
case 13: EAX_reg(context) = 0x32; break;
|
|
||||||
case 1: EAX_reg(context) = 1; break;
|
|
||||||
default: EAX_reg(context) = 0; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_reg(context) += (ECX_reg(context) & 0x0f) * 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* HouseCleanLogicallyDeadHandles (KERNEL32.33)
|
|
||||||
*/
|
|
||||||
void WINAPI HouseCleanLogicallyDeadHandles(void)
|
|
||||||
{
|
|
||||||
/* Whatever this is supposed to do, our handles probably
|
|
||||||
don't need it :-) */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* _KERNEL32_100
|
|
||||||
*/
|
|
||||||
BOOL WINAPI _KERNEL32_100(HANDLE threadid,DWORD exitcode,DWORD x) {
|
|
||||||
FIXME_(thread)("(%d,%ld,0x%08lx): stub\n",threadid,exitcode,x);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* _KERNEL32_99
|
|
||||||
*/
|
|
||||||
DWORD WINAPI _KERNEL32_99(DWORD x) {
|
|
||||||
FIXME_(win32)("(0x%08lx): stub\n",x);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* RegisterShellHookWindow [USER32.459]
|
* RegisterShellHookWindow [USER32.459]
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue