winex11: Don't reset OpenGL swap interval of window on SetParent().
[wine.git] / dlls / krnl386.exe16 / kernel.c
blob6b0081a1322aa50b9b086644674d1fc71b86e373
1 /*
2 * 16-bit kernel initialization code
4 * Copyright 2000 Alexandre Julliard
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define WINE_NO_INLINE_STRING
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winternl.h"
28 #include "wownt32.h"
29 #include "wine/winuser16.h"
31 #include "kernel16_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(module);
36 extern DWORD WINAPI GetProcessFlags( DWORD processid );
38 static DWORD process_dword;
40 /***********************************************************************
41 * KERNEL thread initialisation routine
43 static void thread_attach(void)
45 /* allocate the 16-bit stack (FIXME: should be done lazily) */
46 HGLOBAL16 hstack = WOWGlobalAlloc16( GMEM_FIXED, 0x10000 );
47 kernel_get_thread_data()->stack_sel = GlobalHandleToSel16( hstack );
48 NtCurrentTeb()->WOW32Reserved = (void *)MAKESEGPTR( kernel_get_thread_data()->stack_sel,
49 0x10000 - sizeof(STACK16FRAME) );
50 memset( (char *)GlobalLock16(hstack) + 0x10000 - sizeof(STACK16FRAME), 0, sizeof(STACK16FRAME) );
54 /***********************************************************************
55 * KERNEL thread finalisation routine
57 static void thread_detach(void)
59 /* free the 16-bit stack */
60 WOWGlobalFree16( kernel_get_thread_data()->stack_sel );
61 NtCurrentTeb()->WOW32Reserved = 0;
62 if (NtCurrentTeb()->Tib.SubSystemTib) TASK_ExitTask();
66 /**************************************************************************
67 * DllMain
69 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
71 switch(reason)
73 case DLL_PROCESS_ATTACH:
74 LoadLibrary16( "krnl386.exe" );
75 /* fall through */
76 case DLL_THREAD_ATTACH:
77 thread_attach();
78 break;
79 case DLL_THREAD_DETACH:
80 thread_detach();
81 break;
83 return TRUE;
87 /**************************************************************************
88 * DllEntryPoint (KERNEL.669)
90 BOOL WINAPI KERNEL_DllEntryPoint( DWORD reasion, HINSTANCE16 inst, WORD ds,
91 WORD heap, DWORD reserved1, WORD reserved2 )
93 static BOOL done;
95 /* the entry point can be called multiple times */
96 if (done) return TRUE;
97 done = TRUE;
99 /* create the shared heap for broken win95 native dlls */
100 HeapCreate( HEAP_SHARED, 0, 0 );
102 /* setup emulation of protected instructions from 32-bit code */
103 if (GetVersion() & 0x80000000) RtlAddVectoredExceptionHandler( TRUE, INSTR_vectored_handler );
105 /* Initialize 16-bit thunking entry points */
106 if (!WOWTHUNK_Init()) return FALSE;
108 /* Initialize DOS memory */
109 if (!DOSMEM_Init()) return FALSE;
111 /* Initialize special KERNEL entry points */
113 NE_SetEntryPoint( inst, 178, GetWinFlags16() );
115 NE_SetEntryPoint( inst, 454, wine_get_cs() );
116 NE_SetEntryPoint( inst, 455, wine_get_ds() );
118 NE_SetEntryPoint( inst, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
119 NE_SetEntryPoint( inst, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
120 NE_SetEntryPoint( inst, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
121 NE_SetEntryPoint( inst, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
123 /* Initialize KERNEL.THHOOK */
124 TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( inst, (LPCSTR)332 )));
125 TASK_CreateMainTask();
127 /* Initialize the real-mode selector entry points */
128 #define SET_ENTRY_POINT( num, addr ) \
129 NE_SetEntryPoint( inst, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
130 DOSMEM_MapDosToLinear(addr), 0x10000, inst, \
131 WINE_LDT_FLAGS_DATA ))
133 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
134 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
135 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
136 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
137 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
138 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
139 #undef SET_ENTRY_POINT
141 /* Force loading of some dlls */
142 LoadLibrary16( "system.drv" );
143 LoadLibrary16( "comm.drv" );
145 return TRUE;
148 /***********************************************************************
149 * GetVersion (KERNEL.3)
151 DWORD WINAPI GetVersion16(void)
153 static WORD dosver, winver;
155 if (!dosver) /* not determined yet */
157 RTL_OSVERSIONINFOEXW info;
159 info.dwOSVersionInfoSize = sizeof(info);
160 if (RtlGetVersion( &info )) return 0;
162 if (info.dwMajorVersion <= 3)
163 winver = MAKEWORD( info.dwMajorVersion, info.dwMinorVersion );
164 else
165 winver = MAKEWORD( 3, 95 );
167 switch(info.dwPlatformId)
169 case VER_PLATFORM_WIN32s:
170 switch(MAKELONG( info.dwMinorVersion, info.dwMajorVersion ))
172 case 0x0200:
173 dosver = 0x0303; /* DOS 3.3 for Windows 2.0 */
174 break;
175 case 0x0300:
176 dosver = 0x0500; /* DOS 5.0 for Windows 3.0 */
177 break;
178 default:
179 dosver = 0x0616; /* DOS 6.22 for Windows 3.1 and later */
180 break;
182 break;
183 case VER_PLATFORM_WIN32_WINDOWS:
184 /* DOS 8.0 for WinME, 7.0 for Win95/98 */
185 if (info.dwMinorVersion >= 90) dosver = 0x0800;
186 else dosver = 0x0700;
187 break;
188 case VER_PLATFORM_WIN32_NT:
189 dosver = 0x0500; /* always DOS 5.0 for NT */
190 break;
192 TRACE( "DOS %d.%02d Win %d.%02d\n",
193 HIBYTE(dosver), LOBYTE(dosver), LOBYTE(winver), HIBYTE(winver) );
195 return MAKELONG( winver, dosver );
198 /***********************************************************************
199 * Reserved1 (KERNEL.77)
201 SEGPTR WINAPI KERNEL_AnsiNext16(SEGPTR current)
203 return (*(char *)MapSL(current)) ? current + 1 : current;
206 /***********************************************************************
207 * Reserved2(KERNEL.78)
209 SEGPTR WINAPI KERNEL_AnsiPrev16( SEGPTR start, SEGPTR current )
211 return (current==start)?start:current-1;
214 /***********************************************************************
215 * Reserved3 (KERNEL.79)
217 SEGPTR WINAPI KERNEL_AnsiUpper16( SEGPTR strOrChar )
219 /* uppercase only one char if strOrChar < 0x10000 */
220 if (HIWORD(strOrChar))
222 char *s = MapSL(strOrChar);
223 while (*s)
225 *s = toupper(*s);
226 s++;
228 return strOrChar;
230 else return toupper((char)strOrChar);
233 /***********************************************************************
234 * Reserved4 (KERNEL.80)
236 SEGPTR WINAPI KERNEL_AnsiLower16( SEGPTR strOrChar )
238 /* lowercase only one char if strOrChar < 0x10000 */
239 if (HIWORD(strOrChar))
241 char *s = MapSL(strOrChar);
242 while (*s)
244 *s = tolower(*s);
245 s++;
247 return strOrChar;
249 else return tolower((char)strOrChar);
252 /***********************************************************************
253 * Reserved5 (KERNEL.87)
255 INT16 WINAPI KERNEL_lstrcmp16( LPCSTR str1, LPCSTR str2 )
257 int ret = strcmp( str1, str2 );
259 /* Looks too complicated, but in optimized strcpy we might get
260 * a 32bit wide difference and would truncate it to 16 bit, so
261 * erroneously returning equality. */
262 if (ret < 0) return -1;
263 if (ret > 0) return 1;
264 return 0;
267 /***********************************************************************
268 * lstrcpy (KERNEL.88)
270 SEGPTR WINAPI lstrcpy16( SEGPTR dst, LPCSTR src )
272 if (!lstrcpyA( MapSL(dst), src )) dst = 0;
273 return dst;
276 /***********************************************************************
277 * lstrcat (KERNEL.89)
279 SEGPTR WINAPI lstrcat16( SEGPTR dst, LPCSTR src )
281 /* Windows does not check for NULL pointers here, so we don't either */
282 strcat( MapSL(dst), src );
283 return dst;
286 /***********************************************************************
287 * lstrlen (KERNEL.90)
289 INT16 WINAPI lstrlen16( LPCSTR str )
291 return (INT16)lstrlenA( str );
294 /***********************************************************************
295 * OutputDebugString (KERNEL.115)
297 void WINAPI OutputDebugString16( LPCSTR str )
299 OutputDebugStringA( str );
302 /***********************************************************************
303 * GetWinFlags (KERNEL.132)
305 DWORD WINAPI GetWinFlags16(void)
307 static const long cpuflags[5] = { WF_CPU086, WF_CPU186, WF_CPU286, WF_CPU386, WF_CPU486 };
308 SYSTEM_INFO si;
309 OSVERSIONINFOA ovi;
310 DWORD result;
312 GetSystemInfo(&si);
314 /* There doesn't seem to be any Pentium flag. */
315 result = cpuflags[min(si.wProcessorLevel, 4)] | WF_ENHANCED | WF_PMODE | WF_80x87 | WF_PAGING;
316 if (si.wProcessorLevel >= 4) result |= WF_HASCPUID;
317 ovi.dwOSVersionInfoSize = sizeof(ovi);
318 GetVersionExA(&ovi);
319 if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT)
320 result |= WF_WIN32WOW; /* undocumented WF_WINNT */
321 return result;
324 /***********************************************************************
325 * GetVersionEx (KERNEL.149)
327 BOOL16 WINAPI GetVersionEx16(OSVERSIONINFO16 *v)
329 OSVERSIONINFOA info;
331 if (v->dwOSVersionInfoSize < sizeof(OSVERSIONINFO16))
333 WARN("wrong OSVERSIONINFO size from app\n");
334 return FALSE;
337 info.dwOSVersionInfoSize = sizeof(info);
338 if (!GetVersionExA( &info )) return FALSE;
340 v->dwMajorVersion = info.dwMajorVersion;
341 v->dwMinorVersion = info.dwMinorVersion;
342 v->dwBuildNumber = info.dwBuildNumber;
343 v->dwPlatformId = info.dwPlatformId;
344 strcpy( v->szCSDVersion, info.szCSDVersion );
345 return TRUE;
348 /***********************************************************************
349 * DebugBreak (KERNEL.203)
351 void WINAPI DebugBreak16( CONTEXT *context )
353 EXCEPTION_RECORD rec;
355 rec.ExceptionCode = EXCEPTION_BREAKPOINT;
356 rec.ExceptionFlags = 0;
357 rec.ExceptionRecord = NULL;
358 rec.ExceptionAddress = (LPVOID)context->Eip;
359 rec.NumberParameters = 0;
360 NtRaiseException( &rec, context, TRUE );
363 /***********************************************************************
364 * K329 (KERNEL.329)
366 * TODO:
367 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
369 void WINAPI DebugFillBuffer(LPSTR lpBuffer, WORD wBytes)
371 memset(lpBuffer, 0xf9 /* DBGFILL_BUFFER */, wBytes);
374 /***********************************************************************
375 * DiagQuery (KERNEL.339)
377 * returns TRUE if Win called with "/b" (bootlog.txt)
379 BOOL16 WINAPI DiagQuery16(void)
381 return FALSE;
384 /***********************************************************************
385 * DiagOutput (KERNEL.340)
387 * writes a debug string into <windir>\bootlog.txt
389 void WINAPI DiagOutput16(LPCSTR str)
391 /* FIXME */
392 TRACE("DIAGOUTPUT:%s\n", debugstr_a(str));
395 /***********************************************************************
396 * hmemcpy (KERNEL.348)
398 void WINAPI hmemcpy16( LPVOID dst, LPCVOID src, LONG count )
400 memcpy( dst, src, count );
403 /***********************************************************************
404 * lstrcpyn (KERNEL.353)
406 SEGPTR WINAPI lstrcpyn16( SEGPTR dst, LPCSTR src, INT16 n )
408 if (!lstrcpynA( MapSL(dst), src, n )) return 0;
409 return dst;
412 /***********************************************************************
413 * lstrcatn (KERNEL.352)
415 SEGPTR WINAPI lstrcatn16( SEGPTR dst, LPCSTR src, INT16 n )
417 LPSTR p = MapSL(dst);
418 LPSTR start = p;
420 while (*p) p++;
421 if ((n -= (p - start)) <= 0) return dst;
422 lstrcpynA( p, src, n );
423 return dst;
426 #if 0 /* Not used at this time. This is here for documentation only */
428 /* WINDEBUGINFO flags values */
429 #define WDI_OPTIONS 0x0001
430 #define WDI_FILTER 0x0002
431 #define WDI_ALLOCBREAK 0x0004
433 /* dwOptions values */
434 #define DBO_CHECKHEAP 0x0001
435 #define DBO_BUFFERFILL 0x0004
436 #define DBO_DISABLEGPTRAPPING 0x0010
437 #define DBO_CHECKFREE 0x0020
439 #define DBO_SILENT 0x8000
441 #define DBO_TRACEBREAK 0x2000
442 #define DBO_WARNINGBREAK 0x1000
443 #define DBO_NOERRORBREAK 0x0800
444 #define DBO_NOFATALBREAK 0x0400
445 #define DBO_INT3BREAK 0x0100
447 /* DebugOutput flags values */
448 #define DBF_TRACE 0x0000
449 #define DBF_WARNING 0x4000
450 #define DBF_ERROR 0x8000
451 #define DBF_FATAL 0xc000
453 /* dwFilter values */
454 #define DBF_KERNEL 0x1000
455 #define DBF_KRN_MEMMAN 0x0001
456 #define DBF_KRN_LOADMODULE 0x0002
457 #define DBF_KRN_SEGMENTLOAD 0x0004
458 #define DBF_USER 0x0800
459 #define DBF_GDI 0x0400
460 #define DBF_MMSYSTEM 0x0040
461 #define DBF_PENWIN 0x0020
462 #define DBF_APPLICATION 0x0008
463 #define DBF_DRIVER 0x0010
465 #endif /* NOLOGERROR */
467 /***********************************************************************
468 * GetWinDebugInfo (KERNEL.355)
470 BOOL16 WINAPI GetWinDebugInfo16(WINDEBUGINFO16 *lpwdi, UINT16 flags)
472 FIXME("(%p,%d): stub returning FALSE\n", lpwdi, flags);
473 /* FALSE means not in debugging mode/version */
474 /* Can this type of debugging be used in wine ? */
475 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
476 return FALSE;
479 /***********************************************************************
480 * SetWinDebugInfo (KERNEL.356)
482 BOOL16 WINAPI SetWinDebugInfo16(WINDEBUGINFO16 *lpwdi)
484 FIXME("(%p): stub returning FALSE\n", lpwdi);
485 /* FALSE means not in debugging mode/version */
486 /* Can this type of debugging be used in wine ? */
487 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
488 return FALSE;
491 /***********************************************************************
492 * UnicodeToAnsi (KERNEL.434)
494 INT16 WINAPI UnicodeToAnsi16( LPCWSTR src, LPSTR dst, INT16 codepage )
496 if ( codepage == -1 ) codepage = CP_ACP;
497 return WideCharToMultiByte( codepage, 0, src, -1, dst, 0x7fffffff, NULL, NULL );
500 /***********************************************************************
501 * VWin32_EventCreate (KERNEL.442)
503 HANDLE WINAPI VWin32_EventCreate(VOID)
505 HANDLE hEvent = CreateEventW( NULL, FALSE, 0, NULL );
506 return ConvertToGlobalHandle( hEvent );
509 /***********************************************************************
510 * VWin32_EventDestroy (KERNEL.443)
512 VOID WINAPI VWin32_EventDestroy(HANDLE event)
514 CloseHandle( event );
517 /***********************************************************************
518 * VWin32_EventWait (KERNEL.450)
520 VOID WINAPI VWin32_EventWait(HANDLE event)
522 DWORD mutex_count;
524 ReleaseThunkLock( &mutex_count );
525 WaitForSingleObject( event, INFINITE );
526 RestoreThunkLock( mutex_count );
529 /***********************************************************************
530 * VWin32_EventSet (KERNEL.451)
531 * KERNEL_479 (KERNEL.479)
533 VOID WINAPI VWin32_EventSet(HANDLE event)
535 SetEvent( event );
538 /***********************************************************************
539 * GetProcAddress32 (KERNEL.453)
541 FARPROC WINAPI GetProcAddress32_16( HMODULE hModule, LPCSTR function )
543 /* FIXME: we used to disable snoop when returning proc for Win16 subsystem */
544 return GetProcAddress( hModule, function );
547 /***********************************************************************
548 * CreateW32Event (KERNEL.457)
550 HANDLE WINAPI CreateW32Event( BOOL manual_reset, BOOL initial_state )
552 return CreateEventW( NULL, manual_reset, initial_state, NULL );
555 /***********************************************************************
556 * SetW32Event (KERNEL.458)
558 BOOL WINAPI SetW32Event( HANDLE handle )
560 return SetEvent( handle );
563 /***********************************************************************
564 * ResetW32Event (KERNEL.459)
566 BOOL WINAPI ResetW32Event( HANDLE handle )
568 return ResetEvent( handle );
571 /***********************************************************************
572 * WaitForSingleObject (KERNEL.460)
574 DWORD WINAPI WaitForSingleObject16( HANDLE handle, DWORD timeout )
576 DWORD retval, mutex_count;
578 ReleaseThunkLock( &mutex_count );
579 retval = WaitForSingleObject( handle, timeout );
580 RestoreThunkLock( mutex_count );
581 return retval;
584 /***********************************************************************
585 * WaitForMultipleObjects (KERNEL.461)
587 DWORD WINAPI WaitForMultipleObjects16( DWORD count, const HANDLE *handles,
588 BOOL wait_all, DWORD timeout )
590 DWORD retval, mutex_count;
592 ReleaseThunkLock( &mutex_count );
593 retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, FALSE );
594 RestoreThunkLock( mutex_count );
595 return retval;
598 /***********************************************************************
599 * GetCurrentThreadId (KERNEL.462)
601 DWORD WINAPI GetCurrentThreadId16(void)
603 return GetCurrentThreadId();
606 /***********************************************************************
607 * ExitProcess (KERNEL.466)
609 void WINAPI ExitProcess16( WORD status )
611 DWORD count;
612 ReleaseThunkLock( &count );
613 ExitProcess( status );
616 /***********************************************************************
617 * GetCurrentProcessId (KERNEL.471)
619 DWORD WINAPI GetCurrentProcessId16(void)
621 return GetCurrentProcessId();
624 /*********************************************************************
625 * CloseW32Handle (KERNEL.474)
627 BOOL WINAPI CloseW32Handle( HANDLE handle )
629 return CloseHandle( handle );
632 /***********************************************************************
633 * ConvertToGlobalHandle (KERNEL.476)
635 HANDLE WINAPI ConvertToGlobalHandle16( HANDLE handle )
637 return ConvertToGlobalHandle( handle );
640 /*********************************************************************
641 * MapProcessHandle (KERNEL.483)
643 DWORD WINAPI MapProcessHandle( HANDLE hProcess )
645 return GetProcessId( hProcess );
648 /***********************************************************************
649 * SetProcessDword (KERNEL.484)
650 * 'Of course you cannot directly access Windows internal structures'
652 void WINAPI SetProcessDword( DWORD dwProcessID, INT offset, DWORD value )
654 TRACE("(%d, %d)\n", dwProcessID, offset );
656 if (dwProcessID && dwProcessID != GetCurrentProcessId())
658 ERR("%d: process %x not accessible\n", offset, dwProcessID);
659 return;
662 switch ( offset )
664 case GPD_APP_COMPAT_FLAGS:
665 case GPD_LOAD_DONE_EVENT:
666 case GPD_HINSTANCE16:
667 case GPD_WINDOWS_VERSION:
668 case GPD_THDB:
669 case GPD_PDB:
670 case GPD_STARTF_SHELLDATA:
671 case GPD_STARTF_HOTKEY:
672 case GPD_STARTF_SHOWWINDOW:
673 case GPD_STARTF_SIZE:
674 case GPD_STARTF_POSITION:
675 case GPD_STARTF_FLAGS:
676 case GPD_PARENT:
677 case GPD_FLAGS:
678 ERR("Not allowed to modify offset %d\n", offset );
679 break;
680 case GPD_USERDATA:
681 process_dword = value;
682 break;
683 default:
684 ERR("Unknown offset %d\n", offset );
685 break;
689 /***********************************************************************
690 * GetProcessDword (KERNEL.485)
691 * 'Of course you cannot directly access Windows internal structures'
693 DWORD WINAPI GetProcessDword( DWORD dwProcessID, INT offset )
695 DWORD x, y;
696 STARTUPINFOW siw;
698 TRACE("(%d, %d)\n", dwProcessID, offset );
700 if (dwProcessID && dwProcessID != GetCurrentProcessId())
702 ERR("%d: process %x not accessible\n", offset, dwProcessID);
703 return 0;
706 switch ( offset )
708 case GPD_APP_COMPAT_FLAGS:
709 return GetAppCompatFlags16(0);
710 case GPD_LOAD_DONE_EVENT:
711 return 0;
712 case GPD_HINSTANCE16:
713 return GetTaskDS16();
714 case GPD_WINDOWS_VERSION:
715 return GetExeVersion16();
716 case GPD_THDB:
717 return (DWORD_PTR)NtCurrentTeb() - 0x10 /* FIXME */;
718 case GPD_PDB:
719 return (DWORD_PTR)NtCurrentTeb()->Peb; /* FIXME: truncating a pointer */
720 case GPD_STARTF_SHELLDATA: /* return stdoutput handle from startupinfo ??? */
721 GetStartupInfoW(&siw);
722 return HandleToULong(siw.hStdOutput);
723 case GPD_STARTF_HOTKEY: /* return stdinput handle from startupinfo ??? */
724 GetStartupInfoW(&siw);
725 return HandleToULong(siw.hStdInput);
726 case GPD_STARTF_SHOWWINDOW:
727 GetStartupInfoW(&siw);
728 return siw.wShowWindow;
729 case GPD_STARTF_SIZE:
730 GetStartupInfoW(&siw);
731 x = siw.dwXSize;
732 if ( (INT)x == CW_USEDEFAULT ) x = CW_USEDEFAULT16;
733 y = siw.dwYSize;
734 if ( (INT)y == CW_USEDEFAULT ) y = CW_USEDEFAULT16;
735 return MAKELONG( x, y );
736 case GPD_STARTF_POSITION:
737 GetStartupInfoW(&siw);
738 x = siw.dwX;
739 if ( (INT)x == CW_USEDEFAULT ) x = CW_USEDEFAULT16;
740 y = siw.dwY;
741 if ( (INT)y == CW_USEDEFAULT ) y = CW_USEDEFAULT16;
742 return MAKELONG( x, y );
743 case GPD_STARTF_FLAGS:
744 GetStartupInfoW(&siw);
745 return siw.dwFlags;
746 case GPD_PARENT:
747 return 0;
748 case GPD_FLAGS:
749 return GetProcessFlags(0);
750 case GPD_USERDATA:
751 return process_dword;
752 default:
753 ERR("Unknown offset %d\n", offset );
754 return 0;
758 /***********************************************************************
759 * FreeLibrary32 (KERNEL.486)
761 BOOL WINAPI FreeLibrary32_16( HINSTANCE module )
763 return FreeLibrary( module );
766 /***********************************************************************
767 * GetModuleFileName32 (KERNEL.487)
769 DWORD WINAPI GetModuleFileName32_16( HMODULE module, LPSTR buffer, DWORD size )
771 return GetModuleFileNameA( module, buffer, size );
774 /***********************************************************************
775 * GetModuleHandle32 (KERNEL.488)
777 HMODULE WINAPI GetModuleHandle32_16(LPCSTR module)
779 return GetModuleHandleA( module );
782 /***********************************************************************
783 * RegisterServiceProcess (KERNEL.491)
785 DWORD WINAPI RegisterServiceProcess16( DWORD dwProcessId, DWORD dwType )
787 return 1; /* success */
790 /***********************************************************************
791 * WaitForMultipleObjectsEx (KERNEL.495)
793 DWORD WINAPI WaitForMultipleObjectsEx16( DWORD count, const HANDLE *handles,
794 BOOL wait_all, DWORD timeout, BOOL alertable )
796 DWORD retval, mutex_count;
798 ReleaseThunkLock( &mutex_count );
799 retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, alertable );
800 RestoreThunkLock( mutex_count );
801 return retval;
804 /**********************************************************************
805 * VWin32_BoostThreadGroup (KERNEL.535)
807 VOID WINAPI VWin32_BoostThreadGroup( DWORD threadId, INT boost )
809 FIXME("(0x%08x,%d): stub\n", threadId, boost);
813 /**********************************************************************
814 * VWin32_BoostThreadStatic (KERNEL.536)
816 VOID WINAPI VWin32_BoostThreadStatic( DWORD threadId, INT boost )
818 FIXME("(0x%08x,%d): stub\n", threadId, boost);
821 /***********************************************************************
822 * EnableDos (KERNEL.41)
823 * DisableDos (KERNEL.42)
824 * GetLastDiskChange (KERNEL.98)
825 * ValidateCodeSegments (KERNEL.100)
826 * KbdRst (KERNEL.123)
827 * EnableKernel (KERNEL.124)
828 * DisableKernel (KERNEL.125)
829 * ValidateFreeSpaces (KERNEL.200)
830 * K237 (KERNEL.237)
831 * BUNNY_351 (KERNEL.351)
832 * PIGLET_361 (KERNEL.361)
834 * Entry point for kernel functions that do nothing.
836 LONG WINAPI KERNEL_nop(void)
838 return 0;
841 /***********************************************************************
842 * ToolHelpHook (KERNEL.341)
843 * see "Undocumented Windows"
845 FARPROC16 WINAPI ToolHelpHook16(FARPROC16 func)
847 static FARPROC16 hook;
849 FIXME("(%p), stub.\n", func);
850 return InterlockedExchangePointer( (void **)&hook, func );
853 /* thunk for 16-bit CreateThread */
854 struct thread_args
856 FARPROC16 proc;
857 DWORD param;
860 static DWORD CALLBACK start_thread16( LPVOID threadArgs )
862 struct thread_args args = *(struct thread_args *)threadArgs;
863 HeapFree( GetProcessHeap(), 0, threadArgs );
864 return K32WOWCallback16( (DWORD)args.proc, args.param );
867 /***********************************************************************
868 * CreateThread16 (KERNEL.441)
870 HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
871 FARPROC16 start, SEGPTR param,
872 DWORD flags, LPDWORD id )
874 struct thread_args *args = HeapAlloc( GetProcessHeap(), 0, sizeof(*args) );
875 if (!args) return INVALID_HANDLE_VALUE;
876 args->proc = start;
877 args->param = param;
878 return CreateThread( sa, stack, start_thread16, args, flags, id );
881 /***********************************************************************
882 * _DebugOutput (KERNEL.328)
884 void WINAPIV _DebugOutput( WORD flags, LPCSTR spec, VA_LIST16 valist )
886 char caller[101];
888 /* Decode caller address */
889 if (!GetModuleName16( GetExePtr(CURRENT_STACK16->cs), caller, sizeof(caller) ))
890 sprintf( caller, "%04X:%04X", CURRENT_STACK16->cs, CURRENT_STACK16->ip );
892 /* FIXME: cannot use wvsnprintf16 from kernel */
893 /* wvsnprintf16( temp, sizeof(temp), spec, valist ); */
895 /* Output */
896 FIXME("%s %04x %s\n", caller, flags, debugstr_a(spec) );