From e5cef3b0fbdd606a98f8bff20fb20347c0b51336 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 27 Feb 2003 01:57:16 +0000 Subject: [PATCH] Moved CreateThread16 to kernel, and made it use WOWCallback16. --- dlls/kernel/wowthunk.c | 30 +++++++++++++++++++++++++++++- scheduler/thread.c | 25 ------------------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/dlls/kernel/wowthunk.c b/dlls/kernel/wowthunk.c index 8267dc247cd..194cab6755b 100644 --- a/dlls/kernel/wowthunk.c +++ b/dlls/kernel/wowthunk.c @@ -52,6 +52,20 @@ DWORD WINAPI FreeLibrary32W16(DWORD); DWORD WINAPI CallProcExW16(VOID); DWORD WINAPI CallProcEx32W16(VOID); +/* thunk for 16-bit CreateThread */ +struct thread_args +{ + FARPROC16 proc; + DWORD param; +}; + +static DWORD CALLBACK start_thread16( LPVOID threadArgs ) +{ + struct thread_args args = *(struct thread_args *)threadArgs; + HeapFree( GetProcessHeap(), 0, threadArgs ); + return K32WOWCallback16( (DWORD)args.proc, args.param ); +} + /* * 32-bit WOW routines (in WOW32, but actually forwarded to KERNEL32) */ @@ -285,7 +299,6 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, */ memcpy( (LPBYTE)CURRENT_STACK16 - cbArgs, (LPBYTE)pArgs, cbArgs ); - /* * Actually, we should take care whether the called routine cleans up * its stack or not. Fortunately, our wine_call_to_16 core doesn't rely on @@ -537,3 +550,18 @@ DWORD WINAPI WOW16Call(WORD x,WORD y,WORD z) DPRINTF(") calling address was 0x%08lx\n",calladdr); return 0; } + + +/*********************************************************************** + * CreateThread16 (KERNEL.441) + */ +HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack, + FARPROC16 start, SEGPTR param, + DWORD flags, LPDWORD id ) +{ + struct thread_args *args = HeapAlloc( GetProcessHeap(), 0, sizeof(*args) ); + if (!args) return INVALID_HANDLE_VALUE; + args->proc = start; + args->param = param; + return CreateThread( sa, stack, start_thread16, args, flags, id ); +} diff --git a/scheduler/thread.c b/scheduler/thread.c index 42329679cc2..5b6160a5d53 100644 --- a/scheduler/thread.c +++ b/scheduler/thread.c @@ -330,31 +330,6 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T 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 wine_call_to_16( 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.@] Ends a thread *