kernel32: Link directly to the thunk functions instead of looking up their entry point.

This commit is contained in:
Alexandre Julliard 2009-12-28 17:37:44 +01:00
parent 9ff8da5499
commit 84e51e73b4
1 changed files with 10 additions and 7 deletions

View File

@ -151,6 +151,10 @@ SEGPTR CALL32_CBClientEx_RetAddr = 0;
extern int call_entry_point( void *func, int nb_args, const DWORD *args );
extern void __wine_call_from_16_thunk(void);
extern void FT_Prolog(void);
extern void FT_PrologPrime(void);
extern void QT_Thunk(void);
extern void QT_ThunkPrime(void);
/* Push a DWORD on the 32-bit stack */
static inline void stack32_push( CONTEXT86 *context, DWORD val )
@ -229,7 +233,7 @@ static void _write_ftprolog(LPBYTE relayCode ,DWORD *targetTable) {
*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(kernel32_handle,"FT_Prolog");
*x++ = 0x68; *(void **)x = FT_Prolog;
x+=4; /* push FT_Prolog */
*x++ = 0xC3; /* lret */
/* fill rest with 0xCC / int 3 */
@ -256,7 +260,7 @@ static void _write_qtthunk(
*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(kernel32_handle,"QT_Thunk");
*x++ = 0xB8; *(void **)x = QT_Thunk;
x+=4; /* mov eax , QT_Thunk */
*x++ = 0xFF; *x++ = 0xE0; /* jmp eax */
/* should fill the rest of the 32 bytes with 0xCC */
@ -867,9 +871,8 @@ LPVOID WINAPI ThunkInitLSF(
/* FIXME: add checks for valid code ... */
/* write pointers to kernel32.89 and kernel32.90 (+ordinal base of 1) */
*(DWORD*)(thunk+0x35) = (DWORD)GetProcAddress(kernel32_handle,(LPSTR)90);
*(DWORD*)(thunk+0x6D) = (DWORD)GetProcAddress(kernel32_handle,(LPSTR)89);
*(void **)(thunk+0x35) = QT_ThunkPrime;
*(void **)(thunk+0x6D) = FT_PrologPrime;
if (!(addr = _loadthunk( dll16, thkbuf, dll32, NULL, len )))
return 0;
@ -1645,7 +1648,7 @@ static BOOL THUNK_Init(void)
{
LPBYTE thunk;
ThunkletHeap = HeapCreate( 0, 0x10000, 0x10000 );
ThunkletHeap = HeapCreate( HEAP_CREATE_ENABLE_EXECUTE, 0x10000, 0x10000 );
if (!ThunkletHeap) return FALSE;
ThunkletCodeSel = SELECTOR_AllocBlock( ThunkletHeap, 0x10000, WINE_LDT_FLAGS_CODE );
@ -2095,7 +2098,7 @@ SEGPTR WINAPI Get16DLLAddress(HMODULE16 handle, LPSTR func_name)
/* jmpl QT_Thunk */
*thunk++ = 0xea;
*(FARPROC *)thunk = GetProcAddress(kernel32_handle,"QT_Thunk");
*(void **)thunk = QT_Thunk;
thunk += sizeof(FARPROC16);
*(WORD *)thunk = wine_get_cs();