#include "wine/debug.h"
#include "wine/library.h"
-#include "flatthunk.h"
#include "module.h"
-#include "selectors.h"
#include "stackframe.h"
-#include "task.h"
+#include "kernel_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(thunk);
+struct ThunkDataCommon
+{
+ char magic[4]; /* 00 */
+ DWORD checksum; /* 04 */
+};
+
+struct ThunkDataLS16
+{
+ struct ThunkDataCommon common; /* 00 */
+ SEGPTR targetTable; /* 08 */
+ DWORD firstTime; /* 0C */
+};
+
+struct ThunkDataLS32
+{
+ struct ThunkDataCommon common; /* 00 */
+ DWORD * targetTable; /* 08 */
+ char lateBinding[4]; /* 0C */
+ DWORD flags; /* 10 */
+ DWORD reserved1; /* 14 */
+ DWORD reserved2; /* 18 */
+ DWORD offsetQTThunk; /* 1C */
+ DWORD offsetFTProlog; /* 20 */
+};
+
+struct ThunkDataSL16
+{
+ struct ThunkDataCommon common; /* 00 */
+ DWORD flags1; /* 08 */
+ DWORD reserved1; /* 0C */
+ struct ThunkDataSL * fpData; /* 10 */
+ SEGPTR spData; /* 14 */
+ DWORD reserved2; /* 18 */
+ char lateBinding[4]; /* 1C */
+ DWORD flags2; /* 20 */
+ DWORD reserved3; /* 20 */
+ SEGPTR apiDatabase; /* 28 */
+};
+
+struct ThunkDataSL32
+{
+ struct ThunkDataCommon common; /* 00 */
+ DWORD reserved1; /* 08 */
+ struct ThunkDataSL * data; /* 0C */
+ char lateBinding[4]; /* 10 */
+ DWORD flags; /* 14 */
+ DWORD reserved2; /* 18 */
+ DWORD reserved3; /* 1C */
+ DWORD offsetTargetTable; /* 20 */
+};
+
+struct ThunkDataSL
+{
+#if 0
+ This structure differs from the Win95 original,
+ but this should not matter since it is strictly internal to
+ the thunk handling routines in KRNL386 / KERNEL32.
+
+ For reference, here is the Win95 layout:
+
+ struct ThunkDataCommon common; /* 00 */
+ DWORD flags1; /* 08 */
+ SEGPTR apiDatabase; /* 0C */
+ WORD exePtr; /* 10 */
+ WORD segMBA; /* 12 */
+ DWORD lenMBATotal; /* 14 */
+ DWORD lenMBAUsed; /* 18 */
+ DWORD flags2; /* 1C */
+ char pszDll16[256]; /* 20 */
+ char pszDll32[256]; /*120 */
+
+ We do it differently since all our thunk handling is done
+ by 32-bit code. Therefore we do not need do provide
+ easy access to this data, especially the process target
+ table database, for 16-bit code.
+#endif
+
+ struct ThunkDataCommon common;
+ DWORD flags1;
+ struct SLApiDB * apiDB;
+ struct SLTargetDB * targetDB;
+ DWORD flags2;
+ char pszDll16[256];
+ char pszDll32[256];
+};
+
+struct SLTargetDB
+{
+ struct SLTargetDB * next;
+ DWORD process;
+ DWORD * targetTable;
+};
+
+struct SLApiDB
+{
+ DWORD nrArgBytes;
+ DWORD errorReturnValue;
+};
+
#ifdef __i386__
extern void __wine_call_from_16_thunk();
#else
*x++ = 0x0f;*x++=0xb6;*x++=0xd1; /* movzbl edx,cl */
*x++ = 0x8B;*x++=0x14;*x++=0x95;*(DWORD**)x= targetTable;
x+=4; /* mov edx, [4*edx + targetTable] */
- *x++ = 0x68; *(DWORD*)x = (DWORD)GetProcAddress(GetModuleHandleA("KERNEL32"),"FT_Prolog");
+ *x++ = 0x68; *(DWORD*)x = (DWORD)GetProcAddress(kernel32_handle,"FT_Prolog");
x+=4; /* push FT_Prolog */
*x++ = 0xC3; /* lret */
/* fill rest with 0xCC / int 3 */
*x++ = 0x8A;*x++=0x4D;*x++=0xFC; /* movb cl,[ebp-04] */
*x++ = 0x8B;*x++=0x14;*x++=0x8D;*(DWORD**)x= targetTable;
x+=4; /* mov edx, [4*ecx + targetTable */
- *x++ = 0xB8; *(DWORD*)x = (DWORD)GetProcAddress(GetModuleHandleA("KERNEL32"),"QT_Thunk");
+ *x++ = 0xB8; *(DWORD*)x = (DWORD)GetProcAddress(kernel32_handle,"QT_Thunk");
x+=4; /* mov eax , QT_Thunk */
*x++ = 0xFF; *x++ = 0xE0; /* jmp eax */
/* should fill the rest of the 32 bytes with 0xCC */
LPCSTR dll16, /* [in] name of win16 dll */
LPCSTR dll32 /* [in] name of win32 dll */
) {
- HMODULE hkrnl32 = GetModuleHandleA("KERNEL32");
LPDWORD addr,addr2;
/* FIXME: add checks for valid code ... */
/* write pointers to kernel32.89 and kernel32.90 (+ordinal base of 1) */
- *(DWORD*)(thunk+0x35) = (DWORD)GetProcAddress(hkrnl32,(LPSTR)90);
- *(DWORD*)(thunk+0x6D) = (DWORD)GetProcAddress(hkrnl32,(LPSTR)89);
+ *(DWORD*)(thunk+0x35) = (DWORD)GetProcAddress(kernel32_handle,(LPSTR)90);
+ *(DWORD*)(thunk+0x6D) = (DWORD)GetProcAddress(kernel32_handle,(LPSTR)89);
if (!(addr = _loadthunk( dll16, thkbuf, dll32, NULL, len )))
/* jmpl QT_Thunk */
*thunk++ = 0xea;
- *(FARPROC *)thunk = GetProcAddress(GetModuleHandleA("KERNEL32"),"QT_Thunk");
+ *(FARPROC *)thunk = GetProcAddress(kernel32_handle,"QT_Thunk");
thunk += sizeof(FARPROC16);
*(WORD *)thunk = wine_get_cs();
*/
void WINAPI CommonUnimpStub( CONTEXT86 *context )
{
- if (context->Eax)
- MESSAGE( "*** Unimplemented Win32 API: %s\n", (LPSTR)context->Eax );
+ FIXME("generic stub: %s\n", ((LPSTR)context->Eax ? (LPSTR)context->Eax : "?"));
switch ((context->Ecx >> 4) & 0x0f)
{