Commit e5cef3b0 authored by Alexandre Julliard's avatar Alexandre Julliard

Moved CreateThread16 to kernel, and made it use WOWCallback16.

parent 41018add
......@@ -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 );
}
......@@ -331,31 +331,6 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T stack,
}
/***********************************************************************
* 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
*
* RETURNS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment