2 * Win32 WOW Generic Thunk API
4 * Copyright 1999 Ulrich Weigand
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/port.h"
27 #include "wine/winbase16.h"
38 #include "stackframe.h"
39 #include "kernel_private.h"
40 #include "wine/exception.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(thunk);
44 WINE_DECLARE_DEBUG_CHANNEL(relay);
45 WINE_DECLARE_DEBUG_CHANNEL(snoop);
48 * These are the 16-bit side WOW routines. They reside in wownt16.h
49 * in the SDK; since we don't support Win16 source code anyway, I've
50 * placed them here for compilation with Wine ...
53 DWORD WINAPI GetVDMPointer32W16(SEGPTR,UINT16);
55 DWORD WINAPI LoadLibraryEx32W16(LPCSTR,DWORD,DWORD);
56 DWORD WINAPI GetProcAddress32W16(DWORD,LPCSTR);
57 DWORD WINAPI FreeLibrary32W16(DWORD);
59 #define CPEX_DEST_STDCALL 0x00000000L
60 #define CPEX_DEST_CDECL 0x80000000L
62 /* thunk for 16-bit CreateThread */
69 static DWORD CALLBACK start_thread16( LPVOID threadArgs )
71 struct thread_args args = *(struct thread_args *)threadArgs;
72 HeapFree( GetProcessHeap(), 0, threadArgs );
73 return K32WOWCallback16( (DWORD)args.proc, args.param );
79 /* symbols exported from relay16.s */
80 extern DWORD WINAPI wine_call_to_16( FARPROC16 target, DWORD cbArgs, PEXCEPTION_HANDLER handler );
81 extern void WINAPI wine_call_to_16_regs( CONTEXT86 *context, DWORD cbArgs, PEXCEPTION_HANDLER handler );
82 extern void Call16_Ret_Start(), Call16_Ret_End();
83 extern void CallTo16_Ret();
84 extern void CALL32_CBClient_Ret();
85 extern void CALL32_CBClientEx_Ret();
86 extern DWORD CallTo16_DataSelector;
87 extern SEGPTR CALL32_CBClient_RetAddr;
88 extern SEGPTR CALL32_CBClientEx_RetAddr;
89 extern BYTE Call16_Start;
90 extern BYTE Call16_End;
92 extern void RELAY16_InitDebugLists(void);
94 static SEGPTR call16_ret_addr; /* segptr to CallTo16_Ret routine */
96 /***********************************************************************
99 BOOL WOWTHUNK_Init(void)
101 /* allocate the code selector for CallTo16 routines */
102 WORD codesel = SELECTOR_AllocBlock( (void *)Call16_Ret_Start,
103 (char *)Call16_Ret_End - (char *)Call16_Ret_Start,
104 WINE_LDT_FLAGS_CODE | WINE_LDT_FLAGS_32BIT );
105 if (!codesel) return FALSE;
107 /* Patch the return addresses for CallTo16 routines */
109 CallTo16_DataSelector = wine_get_ds();
110 call16_ret_addr = MAKESEGPTR( codesel, (char*)CallTo16_Ret - (char*)Call16_Ret_Start );
111 CALL32_CBClient_RetAddr =
112 MAKESEGPTR( codesel, (char*)CALL32_CBClient_Ret - (char*)Call16_Ret_Start );
113 CALL32_CBClientEx_RetAddr =
114 MAKESEGPTR( codesel, (char*)CALL32_CBClientEx_Ret - (char*)Call16_Ret_Start );
116 if (TRACE_ON(relay) || TRACE_ON(snoop)) RELAY16_InitDebugLists();
121 /*************************************************************
124 * Fix a selector load that caused an exception if it's in the
127 static BOOL fix_selector( CONTEXT *context )
130 BYTE *instr = (BYTE *)context->Eip;
132 if (instr < &Call16_Start || instr >= &Call16_End) return FALSE;
135 while (*instr == 0x66 || *instr == 0x67) instr++;
139 case 0x07: /* pop es */
140 case 0x17: /* pop ss */
141 case 0x1f: /* pop ds */
143 case 0x0f: /* extended instruction */
146 case 0xa1: /* pop fs */
147 case 0xa9: /* pop gs */
156 stack = wine_ldt_get_ptr( context->SegSs, context->Esp );
157 TRACE( "fixing up selector %x for pop instruction\n", *stack );
163 /*************************************************************
166 * Handler for exceptions occurring in 16-bit code.
168 static DWORD call16_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
169 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **pdispatcher )
171 if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
173 /* unwinding: restore the stack pointer in the TEB, and leave the Win16 mutex */
174 STACK32FRAME *frame32 = (STACK32FRAME *)((char *)frame - offsetof(STACK32FRAME,frame));
175 NtCurrentTeb()->cur_stack = frame32->frame16;
178 else if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
179 record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION)
181 if (IS_SELECTOR_SYSTEM(context->SegCs))
183 if (fix_selector( context )) return ExceptionContinueExecution;
188 DWORD ret = INSTR_EmulateInstruction( record, context );
190 if (ret != ExceptionContinueSearch) return ret;
192 /* check for Win16 __GP handler */
193 if ((gpHandler = HasGPHandler16( MAKESEGPTR( context->SegCs, context->Eip ) )))
195 WORD *stack = wine_ldt_get_ptr( context->SegSs, context->Esp );
196 *--stack = context->SegCs;
197 *--stack = context->Eip;
199 if (!IS_SELECTOR_32BIT(context->SegSs))
200 context->Esp = MAKELONG( LOWORD(context->Esp - 2*sizeof(WORD)),
201 HIWORD(context->Esp) );
203 context->Esp -= 2*sizeof(WORD);
205 context->SegCs = SELECTOROF( gpHandler );
206 context->Eip = OFFSETOF( gpHandler );
207 return ExceptionContinueExecution;
211 return ExceptionContinueSearch;
215 /*************************************************************
218 * Handler for exceptions occurring in vm86 code.
220 static DWORD vm86_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
221 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **pdispatcher )
223 if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
224 return ExceptionContinueSearch;
226 if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
227 record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION)
229 return INSTR_EmulateInstruction( record, context );
232 return ExceptionContinueSearch;
238 BOOL WOWTHUNK_Init(void)
243 #endif /* __i386__ */
247 * 32-bit WOW routines (in WOW32, but actually forwarded to KERNEL32)
250 /**********************************************************************
251 * K32WOWGetDescriptor (KERNEL32.70)
253 BOOL WINAPI K32WOWGetDescriptor( SEGPTR segptr, LPLDT_ENTRY ldtent )
255 return GetThreadSelectorEntry( GetCurrentThread(),
256 segptr >> 16, ldtent );
259 /**********************************************************************
260 * K32WOWGetVDMPointer (KERNEL32.56)
262 LPVOID WINAPI K32WOWGetVDMPointer( DWORD vp, DWORD dwBytes, BOOL fProtectedMode )
264 /* FIXME: add size check too */
266 if ( fProtectedMode )
269 return DOSMEM_MapRealToLinear( vp );
272 /**********************************************************************
273 * K32WOWGetVDMPointerFix (KERNEL32.68)
275 LPVOID WINAPI K32WOWGetVDMPointerFix( DWORD vp, DWORD dwBytes, BOOL fProtectedMode )
278 * Hmmm. According to the docu, we should call:
280 * GlobalFix16( SELECTOROF(vp) );
282 * But this is unnecessary under Wine, as we never move global
283 * memory segments in linear memory anyway.
285 * (I'm not so sure what we are *supposed* to do if
286 * fProtectedMode is TRUE, anyway ...)
289 return K32WOWGetVDMPointer( vp, dwBytes, fProtectedMode );
292 /**********************************************************************
293 * K32WOWGetVDMPointerUnfix (KERNEL32.69)
295 VOID WINAPI K32WOWGetVDMPointerUnfix( DWORD vp )
298 * See above why we don't call:
300 * GlobalUnfix16( SELECTOROF(vp) );
305 /**********************************************************************
306 * K32WOWGlobalAlloc16 (KERNEL32.59)
308 WORD WINAPI K32WOWGlobalAlloc16( WORD wFlags, DWORD cb )
310 return (WORD)GlobalAlloc16( wFlags, cb );
313 /**********************************************************************
314 * K32WOWGlobalFree16 (KERNEL32.62)
316 WORD WINAPI K32WOWGlobalFree16( WORD hMem )
318 return (WORD)GlobalFree16( (HGLOBAL16)hMem );
321 /**********************************************************************
322 * K32WOWGlobalUnlock16 (KERNEL32.61)
324 BOOL WINAPI K32WOWGlobalUnlock16( WORD hMem )
326 return (BOOL)GlobalUnlock16( (HGLOBAL16)hMem );
329 /**********************************************************************
330 * K32WOWGlobalAllocLock16 (KERNEL32.63)
332 DWORD WINAPI K32WOWGlobalAllocLock16( WORD wFlags, DWORD cb, WORD *phMem )
334 WORD hMem = K32WOWGlobalAlloc16( wFlags, cb );
335 if (phMem) *phMem = hMem;
337 return K32WOWGlobalLock16( hMem );
340 /**********************************************************************
341 * K32WOWGlobalLockSize16 (KERNEL32.65)
343 DWORD WINAPI K32WOWGlobalLockSize16( WORD hMem, PDWORD pcb )
346 *pcb = GlobalSize16( (HGLOBAL16)hMem );
348 return K32WOWGlobalLock16( hMem );
351 /**********************************************************************
352 * K32WOWGlobalUnlockFree16 (KERNEL32.64)
354 WORD WINAPI K32WOWGlobalUnlockFree16( DWORD vpMem )
356 if ( !K32WOWGlobalUnlock16( HIWORD(vpMem) ) )
359 return K32WOWGlobalFree16( HIWORD(vpMem) );
363 /**********************************************************************
364 * K32WOWYield16 (KERNEL32.66)
366 VOID WINAPI K32WOWYield16( void )
369 * This does the right thing for both Win16 and Win32 tasks.
370 * More or less, at least :-/
375 /**********************************************************************
376 * K32WOWDirectedYield16 (KERNEL32.67)
378 VOID WINAPI K32WOWDirectedYield16( WORD htask16 )
381 * Argh. Our scheduler doesn't like DirectedYield by Win32
382 * tasks at all. So we do hope that this routine is indeed
383 * only ever called by Win16 tasks that have thunked up ...
385 DirectedYield16( (HTASK16)htask16 );
389 /***********************************************************************
390 * K32WOWHandle32 (KERNEL32.57)
392 HANDLE WINAPI K32WOWHandle32( WORD handle, WOW_HANDLE_TYPE type )
403 case WOW_TYPE_HBITMAP:
404 case WOW_TYPE_HBRUSH:
405 case WOW_TYPE_HPALETTE:
407 case WOW_TYPE_HACCEL:
408 return (HANDLE)(ULONG_PTR)handle;
410 case WOW_TYPE_HMETAFILE:
411 FIXME( "conversion of metafile handles not supported yet\n" );
412 return (HANDLE)(ULONG_PTR)handle;
415 return ((TDB *)GlobalLock16(handle))->teb->ClientId.UniqueThread;
417 case WOW_TYPE_FULLHWND:
418 FIXME( "conversion of full window handles not supported yet\n" );
419 return (HANDLE)(ULONG_PTR)handle;
422 ERR( "handle 0x%04x of unknown type %d\n", handle, type );
423 return (HANDLE)(ULONG_PTR)handle;
427 /***********************************************************************
428 * K32WOWHandle16 (KERNEL32.58)
430 WORD WINAPI K32WOWHandle16( HANDLE handle, WOW_HANDLE_TYPE type )
441 case WOW_TYPE_HBITMAP:
442 case WOW_TYPE_HBRUSH:
443 case WOW_TYPE_HPALETTE:
445 case WOW_TYPE_HACCEL:
446 case WOW_TYPE_FULLHWND:
447 if ( HIWORD(handle ) )
448 ERR( "handle %p of type %d has non-zero HIWORD\n", handle, type );
449 return LOWORD(handle);
451 case WOW_TYPE_HMETAFILE:
452 FIXME( "conversion of metafile handles not supported yet\n" );
453 return LOWORD(handle);
456 return TASK_GetTaskFromThread( (DWORD)handle );
459 ERR( "handle %p of unknown type %d\n", handle, type );
460 return LOWORD(handle);
464 /**********************************************************************
465 * K32WOWCallback16Ex (KERNEL32.55)
467 BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
468 DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode )
472 * Arguments must be prepared in the correct order by the caller
473 * (both for PASCAL and CDECL calling convention), so we simply
474 * copy them to the 16-bit stack ...
476 WORD *stack = (WORD *)CURRENT_STACK16 - cbArgs / sizeof(WORD);
478 memcpy( stack, pArgs, cbArgs );
480 if (dwFlags & (WCB16_REGS|WCB16_REGS_LONG))
482 CONTEXT *context = (CONTEXT *)pdwRetCode;
486 DWORD count = cbArgs / sizeof(WORD);
488 DPRINTF("%04lx:CallTo16(func=%04lx:%04x,ds=%04lx",
489 GetCurrentThreadId(),
490 context->SegCs, LOWORD(context->Eip), context->SegDs );
491 while (count) DPRINTF( ",%04x", stack[--count] );
492 DPRINTF(") ss:sp=%04x:%04x",
493 SELECTOROF(NtCurrentTeb()->cur_stack), OFFSETOF(NtCurrentTeb()->cur_stack) );
494 DPRINTF(" ax=%04x bx=%04x cx=%04x dx=%04x si=%04x di=%04x bp=%04x es=%04x fs=%04x\n",
495 (WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx,
496 (WORD)context->Edx, (WORD)context->Esi, (WORD)context->Edi,
497 (WORD)context->Ebp, (WORD)context->SegEs, (WORD)context->SegFs );
498 SYSLEVEL_CheckNotLevel( 2 );
503 EXCEPTION_REGISTRATION_RECORD frame;
504 frame.Handler = vm86_handler;
505 __wine_push_frame( &frame );
506 __wine_enter_vm86( context );
507 __wine_pop_frame( &frame );
511 /* push return address */
512 if (dwFlags & WCB16_REGS_LONG)
514 *((DWORD *)stack - 1) = HIWORD(call16_ret_addr);
515 *((DWORD *)stack - 2) = LOWORD(call16_ret_addr);
516 cbArgs += 2 * sizeof(DWORD);
520 *((SEGPTR *)stack - 1) = call16_ret_addr;
521 cbArgs += sizeof(SEGPTR);
525 wine_call_to_16_regs( context, cbArgs, call16_handler );
531 DPRINTF("%04lx:RetFrom16() ss:sp=%04x:%04x ",
532 GetCurrentThreadId(), SELECTOROF(NtCurrentTeb()->cur_stack),
533 OFFSETOF(NtCurrentTeb()->cur_stack));
534 DPRINTF(" ax=%04x bx=%04x cx=%04x dx=%04x bp=%04x sp=%04x\n",
535 (WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx,
536 (WORD)context->Edx, (WORD)context->Ebp, (WORD)context->Esp );
537 SYSLEVEL_CheckNotLevel( 2 );
546 DWORD count = cbArgs / sizeof(WORD);
548 DPRINTF("%04lx:CallTo16(func=%04x:%04x,ds=%04x",
549 GetCurrentThreadId(), HIWORD(vpfn16), LOWORD(vpfn16),
550 SELECTOROF(NtCurrentTeb()->cur_stack) );
551 while (count) DPRINTF( ",%04x", stack[--count] );
552 DPRINTF(") ss:sp=%04x:%04x\n",
553 SELECTOROF(NtCurrentTeb()->cur_stack), OFFSETOF(NtCurrentTeb()->cur_stack) );
554 SYSLEVEL_CheckNotLevel( 2 );
557 /* push return address */
558 *((SEGPTR *)stack - 1) = call16_ret_addr;
559 cbArgs += sizeof(SEGPTR);
562 * Actually, we should take care whether the called routine cleans up
563 * its stack or not. Fortunately, our wine_call_to_16 core doesn't rely on
564 * the callee to do so; after the routine has returned, the 16-bit
565 * stack pointer is always reset to the position it had before.
568 ret = wine_call_to_16( (FARPROC16)vpfn16, cbArgs, call16_handler );
569 if (pdwRetCode) *pdwRetCode = ret;
574 DPRINTF("%04lx:RetFrom16() ss:sp=%04x:%04x retval=%08lx\n",
575 GetCurrentThreadId(), SELECTOROF(NtCurrentTeb()->cur_stack),
576 OFFSETOF(NtCurrentTeb()->cur_stack), ret);
577 SYSLEVEL_CheckNotLevel( 2 );
581 assert(0); /* cannot call to 16-bit on non-Intel architectures */
582 #endif /* __i386__ */
584 return TRUE; /* success */
587 /**********************************************************************
588 * K32WOWCallback16 (KERNEL32.54)
590 DWORD WINAPI K32WOWCallback16( DWORD vpfn16, DWORD dwParam )
594 if ( !K32WOWCallback16Ex( vpfn16, WCB16_PASCAL,
595 sizeof(DWORD), &dwParam, &ret ) )
603 * 16-bit WOW routines (in KERNEL)
606 /**********************************************************************
607 * GetVDMPointer32W (KERNEL.516)
609 DWORD WINAPI GetVDMPointer32W16( SEGPTR vp, UINT16 fMode )
611 GlobalPageLock16(GlobalHandle16(SELECTOROF(vp)));
612 return (DWORD)K32WOWGetVDMPointer( vp, 0, (DWORD)fMode );
615 /***********************************************************************
616 * LoadLibraryEx32W (KERNEL.513)
618 DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags )
621 DOS_FULL_NAME full_name;
623 UNICODE_STRING libfileW;
625 static const WCHAR dllW[] = {'.','D','L','L',0};
629 SetLastError(ERROR_INVALID_PARAMETER);
633 if (!RtlCreateUnicodeStringFromAsciiz(&libfileW, lpszLibFile))
635 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
639 /* if the file can not be found, call LoadLibraryExA anyway, since it might be
640 a buildin module. This case is handled in MODULE_LoadLibraryExA */
642 filenameW = libfileW.Buffer;
643 if ( DIR_SearchPath( NULL, filenameW, dllW, &full_name, FALSE ) )
644 filenameW = full_name.short_name;
646 ReleaseThunkLock( &mutex_count );
647 hModule = LoadLibraryExW( filenameW, (HANDLE)hFile, dwFlags );
648 RestoreThunkLock( mutex_count );
650 RtlFreeUnicodeString(&libfileW);
652 return (DWORD)hModule;
655 /***********************************************************************
656 * GetProcAddress32W (KERNEL.515)
658 DWORD WINAPI GetProcAddress32W16( DWORD hModule, LPCSTR lpszProc )
660 return (DWORD)GetProcAddress( (HMODULE)hModule, lpszProc );
663 /***********************************************************************
664 * FreeLibrary32W (KERNEL.514)
666 DWORD WINAPI FreeLibrary32W16( DWORD hLibModule )
671 ReleaseThunkLock( &mutex_count );
672 retv = FreeLibrary( (HMODULE)hLibModule );
673 RestoreThunkLock( mutex_count );
678 /**********************************************************************
681 static DWORD WOW_CallProc32W16( FARPROC proc32, DWORD nrofargs, DWORD *args )
686 ReleaseThunkLock( &mutex_count );
689 * FIXME: If ( nrofargs & CPEX_DEST_CDECL ) != 0, we should call a
690 * 32-bit CDECL routine ...
693 if (!proc32) ret = 0;
694 else switch (nrofargs)
696 case 0: ret = proc32();
698 case 1: ret = proc32(args[0]);
700 case 2: ret = proc32(args[0],args[1]);
702 case 3: ret = proc32(args[0],args[1],args[2]);
704 case 4: ret = proc32(args[0],args[1],args[2],args[3]);
706 case 5: ret = proc32(args[0],args[1],args[2],args[3],args[4]);
708 case 6: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5]);
710 case 7: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6]);
712 case 8: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]);
714 case 9: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]);
716 case 10:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9]);
718 case 11:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10]);
720 case 12:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11]);
722 case 13:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12]);
724 case 14:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12],args[13]);
726 case 15:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12],args[13],args[14]);
729 /* FIXME: should go up to 32 arguments */
730 ERR("Unsupported number of arguments %ld, please report.\n",nrofargs);
735 RestoreThunkLock( mutex_count );
737 TRACE("returns %08lx\n",ret);
741 /**********************************************************************
742 * CallProc32W (KERNEL.517)
744 DWORD WINAPIV CallProc32W16( DWORD nrofargs, DWORD argconvmask, FARPROC proc32, VA_LIST16 valist )
749 TRACE("(%ld,%ld,%p args[",nrofargs,argconvmask,proc32);
751 for (i=0;i<nrofargs;i++)
753 if (argconvmask & (1<<i))
755 SEGPTR ptr = VA_ARG16( valist, SEGPTR );
756 /* pascal convention, have to reverse the arguments order */
757 args[nrofargs - i - 1] = (DWORD)MapSL(ptr);
758 TRACE("%08lx(%p),",ptr,MapSL(ptr));
762 DWORD arg = VA_ARG16( valist, DWORD );
763 /* pascal convention, have to reverse the arguments order */
764 args[nrofargs - i - 1] = arg;
770 /* POP nrofargs DWORD arguments and 3 DWORD parameters */
771 stack16_pop( (3 + nrofargs) * sizeof(DWORD) );
773 return WOW_CallProc32W16( proc32, nrofargs, args );
776 /**********************************************************************
777 * _CallProcEx32W (KERNEL.518)
779 DWORD WINAPIV CallProcEx32W16( DWORD nrofargs, DWORD argconvmask, FARPROC proc32, VA_LIST16 valist )
784 TRACE("(%ld,%ld,%p args[",nrofargs,argconvmask,proc32);
786 for (i=0;i<nrofargs;i++)
788 if (argconvmask & (1<<i))
790 SEGPTR ptr = VA_ARG16( valist, SEGPTR );
791 args[i] = (DWORD)MapSL(ptr);
792 TRACE("%08lx(%p),",ptr,MapSL(ptr));
796 DWORD arg = VA_ARG16( valist, DWORD );
802 return WOW_CallProc32W16( proc32, nrofargs, args );
806 /**********************************************************************
807 * WOW16Call (KERNEL.500)
812 DWORD WINAPIV WOW16Call(WORD x, WORD y, WORD z, VA_LIST16 args)
816 FIXME("(0x%04x,0x%04x,%d),calling (",x,y,z);
818 for (i=0;i<x/2;i++) {
819 WORD a = VA_ARG16(args,WORD);
822 calladdr = VA_ARG16(args,DWORD);
823 stack16_pop( 3*sizeof(WORD) + x + sizeof(DWORD) );
824 DPRINTF(") calling address was 0x%08lx\n",calladdr);
829 /***********************************************************************
830 * CreateThread16 (KERNEL.441)
832 HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
833 FARPROC16 start, SEGPTR param,
834 DWORD flags, LPDWORD id )
836 struct thread_args *args = HeapAlloc( GetProcessHeap(), 0, sizeof(*args) );
837 if (!args) return INVALID_HANDLE_VALUE;
840 return CreateThread( sa, stack, start_thread16, args, flags, id );