From f0a1c2f741898f8e511d3d5dce4ca098446a5f84 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Mon, 20 Sep 1999 18:45:28 +0000 Subject: [PATCH] Don't create thunk for CreateThread16 proc, call it directly. --- scheduler/thread.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scheduler/thread.c b/scheduler/thread.c index 16ecbc9576..a53a23cabe 100644 --- a/scheduler/thread.c +++ b/scheduler/thread.c @@ -27,6 +27,7 @@ #include "server.h" #include "services.h" #include "stackframe.h" +#include "builtin16.h" #include "debugtools.h" #include "queue.h" #include "hook.h" @@ -307,6 +308,30 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack, return handle; } +/*********************************************************************** + * CreateThread16 (KERNEL.441) + */ +static DWORD CALLBACK THREAD_StartThread16( LPVOID threadArgs ) +{ + FARPROC16 start = ((FARPROC16 *)threadArgs)[0]; + DWORD param = ((DWORD *)threadArgs)[1]; + HeapFree( GetProcessHeap(), 0, threadArgs ); + + ((LPDWORD)CURRENT_STACK16)[-1] = param; + return CallTo16Long( start, sizeof(DWORD) ); +} +HANDLE WINAPI 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_VALUE; + threadArgs[0] = (DWORD)start; + threadArgs[1] = (DWORD)param; + + return CreateThread( sa, stack, THREAD_StartThread16, threadArgs, flags, id ); +} + /*********************************************************************** * ExitThread [KERNEL32.215] Ends a thread