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"
39 #include "stackframe.h"
40 #include "wine/exception.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(thunk);
44 WINE_DECLARE_DEBUG_CHANNEL(relay);
47 * These are the 16-bit side WOW routines. They reside in wownt16.h
48 * in the SDK; since we don't support Win16 source code anyway, I've
49 * placed them here for compilation with Wine ...
52 DWORD WINAPI GetVDMPointer32W16(SEGPTR,UINT16);
54 DWORD WINAPI LoadLibraryEx32W16(LPCSTR,DWORD,DWORD);
55 DWORD WINAPI GetProcAddress32W16(DWORD,LPCSTR);
56 DWORD WINAPI FreeLibrary32W16(DWORD);
58 #define CPEX_DEST_STDCALL 0x00000000L
59 #define CPEX_DEST_CDECL 0x80000000L
61 /* thunk for 16-bit CreateThread */
68 static DWORD CALLBACK start_thread16( LPVOID threadArgs )
70 struct thread_args args = *(struct thread_args *)threadArgs;
71 HeapFree( GetProcessHeap(), 0, threadArgs );
72 return K32WOWCallback16( (DWORD)args.proc, args.param );
78 /* symbols exported from relay16.s */
79 extern DWORD WINAPI wine_call_to_16( FARPROC16 target, DWORD cbArgs, PEXCEPTION_HANDLER handler );
80 extern void WINAPI wine_call_to_16_regs( CONTEXT86 *context, DWORD cbArgs, PEXCEPTION_HANDLER handler );
81 extern void Call16_Ret_Start(), Call16_Ret_End();
82 extern void CallTo16_Ret();
83 extern void CALL32_CBClient_Ret();
84 extern void CALL32_CBClientEx_Ret();
85 extern DWORD CallTo16_DataSelector;
86 extern SEGPTR CALL32_CBClient_RetAddr;
87 extern SEGPTR CALL32_CBClientEx_RetAddr;
88 extern BYTE Call16_Start;
89 extern BYTE Call16_End;
91 static SEGPTR call16_ret_addr; /* segptr to CallTo16_Ret routine */
93 /***********************************************************************
96 BOOL WOWTHUNK_Init(void)
98 /* allocate the code selector for CallTo16 routines */
99 WORD codesel = SELECTOR_AllocBlock( (void *)Call16_Ret_Start,
100 (char *)Call16_Ret_End - (char *)Call16_Ret_Start,
101 WINE_LDT_FLAGS_CODE | WINE_LDT_FLAGS_32BIT );
102 if (!codesel) return FALSE;
104 /* Patch the return addresses for CallTo16 routines */
106 CallTo16_DataSelector = wine_get_ds();
107 call16_ret_addr = MAKESEGPTR( codesel, (char*)CallTo16_Ret - (char*)Call16_Ret_Start );
108 CALL32_CBClient_RetAddr =
109 MAKESEGPTR( codesel, (char*)CALL32_CBClient_Ret - (char*)Call16_Ret_Start );
110 CALL32_CBClientEx_RetAddr =
111 MAKESEGPTR( codesel, (char*)CALL32_CBClientEx_Ret - (char*)Call16_Ret_Start );
116 /*************************************************************
119 * Fix a selector load that caused an exception if it's in the
122 static BOOL fix_selector( CONTEXT *context )
125 BYTE *instr = (BYTE *)context->Eip;
127 if (instr < &Call16_Start || instr >= &Call16_End) return FALSE;
130 while (*instr == 0x66 || *instr == 0x67) instr++;
134 case 0x07: /* pop es */
135 case 0x17: /* pop ss */
136 case 0x1f: /* pop ds */
138 case 0x0f: /* extended instruction */
141 case 0xa1: /* pop fs */
142 case 0xa9: /* pop gs */
151 stack = wine_ldt_get_ptr( context->SegSs, context->Esp );
152 TRACE( "fixing up selector %x for pop instruction\n", *stack );
158 /*************************************************************
161 * Handler for exceptions occurring in 16-bit code.
163 static DWORD call16_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
164 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **pdispatcher )
166 if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
168 /* unwinding: restore the stack pointer in the TEB, and leave the Win16 mutex */
169 STACK32FRAME *frame32 = (STACK32FRAME *)((char *)frame - offsetof(STACK32FRAME,frame));
170 NtCurrentTeb()->cur_stack = frame32->frame16;
175 if (IS_SELECTOR_SYSTEM(context->SegCs))
177 if (fix_selector( context )) return ExceptionContinueExecution;
179 else /* check for Win16 __GP handler */
181 SEGPTR gpHandler = HasGPHandler16( MAKESEGPTR( context->SegCs, context->Eip ) );
184 WORD *stack = wine_ldt_get_ptr( context->SegSs, context->Esp );
185 *--stack = context->SegCs;
186 *--stack = context->Eip;
188 if (!IS_SELECTOR_32BIT(context->SegSs))
189 context->Esp = MAKELONG( LOWORD(context->Esp - 2*sizeof(WORD)),
190 HIWORD(context->Esp) );
192 context->Esp -= 2*sizeof(WORD);
194 context->SegCs = SELECTOROF( gpHandler );
195 context->Eip = OFFSETOF( gpHandler );
196 return ExceptionContinueExecution;
200 return ExceptionContinueSearch;
205 BOOL WOWTHUNK_Init(void)
210 #endif /* __i386__ */
214 * 32-bit WOW routines (in WOW32, but actually forwarded to KERNEL32)
217 /**********************************************************************
218 * K32WOWGetDescriptor (KERNEL32.70)
220 BOOL WINAPI K32WOWGetDescriptor( SEGPTR segptr, LPLDT_ENTRY ldtent )
222 return GetThreadSelectorEntry( GetCurrentThread(),
223 segptr >> 16, ldtent );
226 /**********************************************************************
227 * K32WOWGetVDMPointer (KERNEL32.56)
229 LPVOID WINAPI K32WOWGetVDMPointer( DWORD vp, DWORD dwBytes, BOOL fProtectedMode )
231 /* FIXME: add size check too */
233 if ( fProtectedMode )
236 return DOSMEM_MapRealToLinear( vp );
239 /**********************************************************************
240 * K32WOWGetVDMPointerFix (KERNEL32.68)
242 LPVOID WINAPI K32WOWGetVDMPointerFix( DWORD vp, DWORD dwBytes, BOOL fProtectedMode )
245 * Hmmm. According to the docu, we should call:
247 * GlobalFix16( SELECTOROF(vp) );
249 * But this is unnecessary under Wine, as we never move global
250 * memory segments in linear memory anyway.
252 * (I'm not so sure what we are *supposed* to do if
253 * fProtectedMode is TRUE, anyway ...)
256 return K32WOWGetVDMPointer( vp, dwBytes, fProtectedMode );
259 /**********************************************************************
260 * K32WOWGetVDMPointerUnfix (KERNEL32.69)
262 VOID WINAPI K32WOWGetVDMPointerUnfix( DWORD vp )
265 * See above why we don't call:
267 * GlobalUnfix16( SELECTOROF(vp) );
272 /**********************************************************************
273 * K32WOWGlobalAlloc16 (KERNEL32.59)
275 WORD WINAPI K32WOWGlobalAlloc16( WORD wFlags, DWORD cb )
277 return (WORD)GlobalAlloc16( wFlags, cb );
280 /**********************************************************************
281 * K32WOWGlobalFree16 (KERNEL32.62)
283 WORD WINAPI K32WOWGlobalFree16( WORD hMem )
285 return (WORD)GlobalFree16( (HGLOBAL16)hMem );
288 /**********************************************************************
289 * K32WOWGlobalUnlock16 (KERNEL32.61)
291 BOOL WINAPI K32WOWGlobalUnlock16( WORD hMem )
293 return (BOOL)GlobalUnlock16( (HGLOBAL16)hMem );
296 /**********************************************************************
297 * K32WOWGlobalAllocLock16 (KERNEL32.63)
299 DWORD WINAPI K32WOWGlobalAllocLock16( WORD wFlags, DWORD cb, WORD *phMem )
301 WORD hMem = K32WOWGlobalAlloc16( wFlags, cb );
302 if (phMem) *phMem = hMem;
304 return K32WOWGlobalLock16( hMem );
307 /**********************************************************************
308 * K32WOWGlobalLockSize16 (KERNEL32.65)
310 DWORD WINAPI K32WOWGlobalLockSize16( WORD hMem, PDWORD pcb )
313 *pcb = GlobalSize16( (HGLOBAL16)hMem );
315 return K32WOWGlobalLock16( hMem );
318 /**********************************************************************
319 * K32WOWGlobalUnlockFree16 (KERNEL32.64)
321 WORD WINAPI K32WOWGlobalUnlockFree16( DWORD vpMem )
323 if ( !K32WOWGlobalUnlock16( HIWORD(vpMem) ) )
326 return K32WOWGlobalFree16( HIWORD(vpMem) );
330 /**********************************************************************
331 * K32WOWYield16 (KERNEL32.66)
333 VOID WINAPI K32WOWYield16( void )
336 * This does the right thing for both Win16 and Win32 tasks.
337 * More or less, at least :-/
342 /**********************************************************************
343 * K32WOWDirectedYield16 (KERNEL32.67)
345 VOID WINAPI K32WOWDirectedYield16( WORD htask16 )
348 * Argh. Our scheduler doesn't like DirectedYield by Win32
349 * tasks at all. So we do hope that this routine is indeed
350 * only ever called by Win16 tasks that have thunked up ...
352 DirectedYield16( (HTASK16)htask16 );
356 /***********************************************************************
357 * K32WOWHandle32 (KERNEL32.57)
359 HANDLE WINAPI K32WOWHandle32( WORD handle, WOW_HANDLE_TYPE type )
370 case WOW_TYPE_HBITMAP:
371 case WOW_TYPE_HBRUSH:
372 case WOW_TYPE_HPALETTE:
374 case WOW_TYPE_HACCEL:
375 return (HANDLE)(ULONG_PTR)handle;
377 case WOW_TYPE_HMETAFILE:
378 FIXME( "conversion of metafile handles not supported yet\n" );
379 return (HANDLE)(ULONG_PTR)handle;
382 return ((TDB *)GlobalLock16(handle))->teb->ClientId.UniqueThread;
384 case WOW_TYPE_FULLHWND:
385 FIXME( "conversion of full window handles not supported yet\n" );
386 return (HANDLE)(ULONG_PTR)handle;
389 ERR( "handle 0x%04x of unknown type %d\n", handle, type );
390 return (HANDLE)(ULONG_PTR)handle;
394 /***********************************************************************
395 * K32WOWHandle16 (KERNEL32.58)
397 WORD WINAPI K32WOWHandle16( HANDLE handle, WOW_HANDLE_TYPE type )
408 case WOW_TYPE_HBITMAP:
409 case WOW_TYPE_HBRUSH:
410 case WOW_TYPE_HPALETTE:
412 case WOW_TYPE_HACCEL:
413 case WOW_TYPE_FULLHWND:
414 if ( HIWORD(handle ) )
415 ERR( "handle %p of type %d has non-zero HIWORD\n", handle, type );
416 return LOWORD(handle);
418 case WOW_TYPE_HMETAFILE:
419 FIXME( "conversion of metafile handles not supported yet\n" );
420 return LOWORD(handle);
423 return TASK_GetTaskFromThread( (DWORD)handle );
426 ERR( "handle %p of unknown type %d\n", handle, type );
427 return LOWORD(handle);
431 /**********************************************************************
432 * K32WOWCallback16Ex (KERNEL32.55)
434 BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
435 DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode )
439 * Arguments must be prepared in the correct order by the caller
440 * (both for PASCAL and CDECL calling convention), so we simply
441 * copy them to the 16-bit stack ...
443 WORD *stack = (WORD *)CURRENT_STACK16 - cbArgs / sizeof(WORD);
445 memcpy( stack, pArgs, cbArgs );
447 if (dwFlags & (WCB16_REGS|WCB16_REGS_LONG))
449 CONTEXT *context = (CONTEXT *)pdwRetCode;
453 DWORD count = cbArgs / sizeof(WORD);
455 DPRINTF("%04lx:CallTo16(func=%04lx:%04x,ds=%04lx",
456 GetCurrentThreadId(),
457 context->SegCs, LOWORD(context->Eip), context->SegDs );
458 while (count) DPRINTF( ",%04x", stack[--count] );
459 DPRINTF(") ss:sp=%04x:%04x",
460 SELECTOROF(NtCurrentTeb()->cur_stack), OFFSETOF(NtCurrentTeb()->cur_stack) );
461 DPRINTF(" ax=%04x bx=%04x cx=%04x dx=%04x si=%04x di=%04x bp=%04x es=%04x fs=%04x\n",
462 (WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx,
463 (WORD)context->Edx, (WORD)context->Esi, (WORD)context->Edi,
464 (WORD)context->Ebp, (WORD)context->SegEs, (WORD)context->SegFs );
465 SYSLEVEL_CheckNotLevel( 2 );
468 /* push return address */
469 if (dwFlags & WCB16_REGS_LONG)
471 *((DWORD *)stack - 1) = HIWORD(call16_ret_addr);
472 *((DWORD *)stack - 2) = LOWORD(call16_ret_addr);
473 cbArgs += 2 * sizeof(DWORD);
477 *((SEGPTR *)stack - 1) = call16_ret_addr;
478 cbArgs += sizeof(SEGPTR);
482 wine_call_to_16_regs( context, cbArgs, call16_handler );
487 DPRINTF("%04lx:RetFrom16() ss:sp=%04x:%04x ",
488 GetCurrentThreadId(), SELECTOROF(NtCurrentTeb()->cur_stack),
489 OFFSETOF(NtCurrentTeb()->cur_stack));
490 DPRINTF(" ax=%04x bx=%04x cx=%04x dx=%04x bp=%04x sp=%04x\n",
491 (WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx,
492 (WORD)context->Edx, (WORD)context->Ebp, (WORD)context->Esp );
493 SYSLEVEL_CheckNotLevel( 2 );
502 DWORD count = cbArgs / sizeof(WORD);
504 DPRINTF("%04lx:CallTo16(func=%04x:%04x,ds=%04x",
505 GetCurrentThreadId(), HIWORD(vpfn16), LOWORD(vpfn16),
506 SELECTOROF(NtCurrentTeb()->cur_stack) );
507 while (count) DPRINTF( ",%04x", stack[--count] );
508 DPRINTF(") ss:sp=%04x:%04x\n",
509 SELECTOROF(NtCurrentTeb()->cur_stack), OFFSETOF(NtCurrentTeb()->cur_stack) );
510 SYSLEVEL_CheckNotLevel( 2 );
513 /* push return address */
514 *((SEGPTR *)stack - 1) = call16_ret_addr;
515 cbArgs += sizeof(SEGPTR);
518 * Actually, we should take care whether the called routine cleans up
519 * its stack or not. Fortunately, our wine_call_to_16 core doesn't rely on
520 * the callee to do so; after the routine has returned, the 16-bit
521 * stack pointer is always reset to the position it had before.
524 ret = wine_call_to_16( (FARPROC16)vpfn16, cbArgs, call16_handler );
525 if (pdwRetCode) *pdwRetCode = ret;
530 DPRINTF("%04lx:RetFrom16() ss:sp=%04x:%04x retval=%08lx\n",
531 GetCurrentThreadId(), SELECTOROF(NtCurrentTeb()->cur_stack),
532 OFFSETOF(NtCurrentTeb()->cur_stack), ret);
533 SYSLEVEL_CheckNotLevel( 2 );
537 assert(0); /* cannot call to 16-bit on non-Intel architectures */
538 #endif /* __i386__ */
540 return TRUE; /* success */
543 /**********************************************************************
544 * K32WOWCallback16 (KERNEL32.54)
546 DWORD WINAPI K32WOWCallback16( DWORD vpfn16, DWORD dwParam )
550 if ( !K32WOWCallback16Ex( vpfn16, WCB16_PASCAL,
551 sizeof(DWORD), &dwParam, &ret ) )
559 * 16-bit WOW routines (in KERNEL)
562 /**********************************************************************
563 * GetVDMPointer32W (KERNEL.516)
565 DWORD WINAPI GetVDMPointer32W16( SEGPTR vp, UINT16 fMode )
567 GlobalPageLock16(GlobalHandle16(SELECTOROF(vp)));
568 return (DWORD)K32WOWGetVDMPointer( vp, 0, (DWORD)fMode );
571 /***********************************************************************
572 * LoadLibraryEx32W (KERNEL.513)
574 DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags )
577 DOS_FULL_NAME full_name;
579 UNICODE_STRING libfileW;
581 static const WCHAR dllW[] = {'.','D','L','L',0};
585 SetLastError(ERROR_INVALID_PARAMETER);
589 if (!RtlCreateUnicodeStringFromAsciiz(&libfileW, lpszLibFile))
591 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
595 /* if the file can not be found, call LoadLibraryExA anyway, since it might be
596 a buildin module. This case is handled in MODULE_LoadLibraryExA */
598 filenameW = libfileW.Buffer;
599 if ( DIR_SearchPath( NULL, filenameW, dllW, &full_name, FALSE ) )
600 filenameW = full_name.short_name;
602 ReleaseThunkLock( &mutex_count );
603 hModule = LoadLibraryExW( filenameW, (HANDLE)hFile, dwFlags );
604 RestoreThunkLock( mutex_count );
606 RtlFreeUnicodeString(&libfileW);
608 return (DWORD)hModule;
611 /***********************************************************************
612 * GetProcAddress32W (KERNEL.515)
614 DWORD WINAPI GetProcAddress32W16( DWORD hModule, LPCSTR lpszProc )
616 return (DWORD)GetProcAddress( (HMODULE)hModule, lpszProc );
619 /***********************************************************************
620 * FreeLibrary32W (KERNEL.514)
622 DWORD WINAPI FreeLibrary32W16( DWORD hLibModule )
627 ReleaseThunkLock( &mutex_count );
628 retv = FreeLibrary( (HMODULE)hLibModule );
629 RestoreThunkLock( mutex_count );
634 /**********************************************************************
637 static DWORD WOW_CallProc32W16( FARPROC proc32, DWORD nrofargs, DWORD *args )
642 ReleaseThunkLock( &mutex_count );
645 * FIXME: If ( nrofargs & CPEX_DEST_CDECL ) != 0, we should call a
646 * 32-bit CDECL routine ...
649 if (!proc32) ret = 0;
650 else switch (nrofargs)
652 case 0: ret = proc32();
654 case 1: ret = proc32(args[0]);
656 case 2: ret = proc32(args[0],args[1]);
658 case 3: ret = proc32(args[0],args[1],args[2]);
660 case 4: ret = proc32(args[0],args[1],args[2],args[3]);
662 case 5: ret = proc32(args[0],args[1],args[2],args[3],args[4]);
664 case 6: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5]);
666 case 7: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6]);
668 case 8: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]);
670 case 9: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]);
672 case 10:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9]);
674 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]);
676 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]);
678 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]);
680 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]);
682 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]);
685 /* FIXME: should go up to 32 arguments */
686 ERR("Unsupported number of arguments %ld, please report.\n",nrofargs);
691 RestoreThunkLock( mutex_count );
693 TRACE("returns %08lx\n",ret);
697 /**********************************************************************
698 * CallProc32W (KERNEL.517)
700 DWORD WINAPIV CallProc32W16( DWORD nrofargs, DWORD argconvmask, FARPROC proc32, VA_LIST16 valist )
705 TRACE("(%ld,%ld,%p args[",nrofargs,argconvmask,proc32);
707 for (i=0;i<nrofargs;i++)
709 if (argconvmask & (1<<i))
711 SEGPTR ptr = VA_ARG16( valist, SEGPTR );
712 /* pascal convention, have to reverse the arguments order */
713 args[nrofargs - i - 1] = (DWORD)MapSL(ptr);
714 TRACE("%08lx(%p),",ptr,MapSL(ptr));
718 DWORD arg = VA_ARG16( valist, DWORD );
719 /* pascal convention, have to reverse the arguments order */
720 args[nrofargs - i - 1] = arg;
726 /* POP nrofargs DWORD arguments and 3 DWORD parameters */
727 stack16_pop( (3 + nrofargs) * sizeof(DWORD) );
729 return WOW_CallProc32W16( proc32, nrofargs, args );
732 /**********************************************************************
733 * _CallProcEx32W (KERNEL.518)
735 DWORD WINAPIV CallProcEx32W16( DWORD nrofargs, DWORD argconvmask, FARPROC proc32, VA_LIST16 valist )
740 TRACE("(%ld,%ld,%p args[",nrofargs,argconvmask,proc32);
742 for (i=0;i<nrofargs;i++)
744 if (argconvmask & (1<<i))
746 SEGPTR ptr = VA_ARG16( valist, SEGPTR );
747 args[i] = (DWORD)MapSL(ptr);
748 TRACE("%08lx(%p),",ptr,MapSL(ptr));
752 DWORD arg = VA_ARG16( valist, DWORD );
758 return WOW_CallProc32W16( proc32, nrofargs, args );
762 /**********************************************************************
763 * WOW16Call (KERNEL.500)
768 DWORD WINAPIV WOW16Call(WORD x, WORD y, WORD z, VA_LIST16 args)
772 FIXME("(0x%04x,0x%04x,%d),calling (",x,y,z);
774 for (i=0;i<x/2;i++) {
775 WORD a = VA_ARG16(args,WORD);
778 calladdr = VA_ARG16(args,DWORD);
779 stack16_pop( 3*sizeof(WORD) + x + sizeof(DWORD) );
780 DPRINTF(") calling address was 0x%08lx\n",calladdr);
785 /***********************************************************************
786 * CreateThread16 (KERNEL.441)
788 HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
789 FARPROC16 start, SEGPTR param,
790 DWORD flags, LPDWORD id )
792 struct thread_args *args = HeapAlloc( GetProcessHeap(), 0, sizeof(*args) );
793 if (!args) return INVALID_HANDLE_VALUE;
796 return CreateThread( sa, stack, start_thread16, args, flags, id );