kernel32: Update Italian translation.
[wine/testsucceed.git] / dlls / krnl386.exe16 / kernel.c
blob437eed1ae4688c9897b4f9261fbf9058038aa862
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 int done;
95 /* the entry point can be called multiple times */
96 if (done) return TRUE;
97 done = 1;
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 return (INT16)strcmp( str1, str2 );
260 /***********************************************************************
261 * lstrcpy (KERNEL.88)
263 SEGPTR WINAPI lstrcpy16( SEGPTR dst, LPCSTR src )
265 if (!lstrcpyA( MapSL(dst), src )) dst = 0;
266 return dst;
269 /***********************************************************************
270 * lstrcat (KERNEL.89)
272 SEGPTR WINAPI lstrcat16( SEGPTR dst, LPCSTR src )
274 /* Windows does not check for NULL pointers here, so we don't either */
275 strcat( MapSL(dst), src );
276 return dst;
279 /***********************************************************************
280 * lstrlen (KERNEL.90)
282 INT16 WINAPI lstrlen16( LPCSTR str )
284 return (INT16)lstrlenA( str );
287 /***********************************************************************
288 * OutputDebugString (KERNEL.115)
290 void WINAPI OutputDebugString16( LPCSTR str )
292 OutputDebugStringA( str );
295 /***********************************************************************
296 * GetWinFlags (KERNEL.132)
298 DWORD WINAPI GetWinFlags16(void)
300 static const long cpuflags[5] = { WF_CPU086, WF_CPU186, WF_CPU286, WF_CPU386, WF_CPU486 };
301 SYSTEM_INFO si;
302 OSVERSIONINFOA ovi;
303 DWORD result;
305 GetSystemInfo(&si);
307 /* There doesn't seem to be any Pentium flag. */
308 result = cpuflags[min(si.wProcessorLevel, 4)] | WF_ENHANCED | WF_PMODE | WF_80x87 | WF_PAGING;
309 if (si.wProcessorLevel >= 4) result |= WF_HASCPUID;
310 ovi.dwOSVersionInfoSize = sizeof(ovi);
311 GetVersionExA(&ovi);
312 if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT)
313 result |= WF_WIN32WOW; /* undocumented WF_WINNT */
314 return result;
317 /***********************************************************************
318 * GetVersionEx (KERNEL.149)
320 BOOL16 WINAPI GetVersionEx16(OSVERSIONINFO16 *v)
322 OSVERSIONINFOA info;
324 if (v->dwOSVersionInfoSize < sizeof(OSVERSIONINFO16))
326 WARN("wrong OSVERSIONINFO size from app\n");
327 return FALSE;
330 info.dwOSVersionInfoSize = sizeof(info);
331 if (!GetVersionExA( &info )) return FALSE;
333 v->dwMajorVersion = info.dwMajorVersion;
334 v->dwMinorVersion = info.dwMinorVersion;
335 v->dwBuildNumber = info.dwBuildNumber;
336 v->dwPlatformId = info.dwPlatformId;
337 strcpy( v->szCSDVersion, info.szCSDVersion );
338 return TRUE;
341 /***********************************************************************
342 * DebugBreak (KERNEL.203)
344 void WINAPI DebugBreak16( CONTEXT *context )
346 EXCEPTION_RECORD rec;
348 rec.ExceptionCode = EXCEPTION_BREAKPOINT;
349 rec.ExceptionFlags = 0;
350 rec.ExceptionRecord = NULL;
351 rec.ExceptionAddress = (LPVOID)context->Eip;
352 rec.NumberParameters = 0;
353 NtRaiseException( &rec, context, TRUE );
356 /***********************************************************************
357 * K329 (KERNEL.329)
359 * TODO:
360 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
362 void WINAPI DebugFillBuffer(LPSTR lpBuffer, WORD wBytes)
364 memset(lpBuffer, 0xf9 /* DBGFILL_BUFFER */, wBytes);
367 /***********************************************************************
368 * DiagQuery (KERNEL.339)
370 * returns TRUE if Win called with "/b" (bootlog.txt)
372 BOOL16 WINAPI DiagQuery16(void)
374 return FALSE;
377 /***********************************************************************
378 * DiagOutput (KERNEL.340)
380 * writes a debug string into <windir>\bootlog.txt
382 void WINAPI DiagOutput16(LPCSTR str)
384 /* FIXME */
385 TRACE("DIAGOUTPUT:%s\n", debugstr_a(str));
388 /***********************************************************************
389 * hmemcpy (KERNEL.348)
391 void WINAPI hmemcpy16( LPVOID dst, LPCVOID src, LONG count )
393 memcpy( dst, src, count );
396 /***********************************************************************
397 * lstrcpyn (KERNEL.353)
399 SEGPTR WINAPI lstrcpyn16( SEGPTR dst, LPCSTR src, INT16 n )
401 if (!lstrcpynA( MapSL(dst), src, n )) return 0;
402 return dst;
405 /***********************************************************************
406 * lstrcatn (KERNEL.352)
408 SEGPTR WINAPI lstrcatn16( SEGPTR dst, LPCSTR src, INT16 n )
410 LPSTR p = MapSL(dst);
411 LPSTR start = p;
413 while (*p) p++;
414 if ((n -= (p - start)) <= 0) return dst;
415 lstrcpynA( p, src, n );
416 return dst;
419 #if 0 /* Not used at this time. This is here for documentation only */
421 /* WINDEBUGINFO flags values */
422 #define WDI_OPTIONS 0x0001
423 #define WDI_FILTER 0x0002
424 #define WDI_ALLOCBREAK 0x0004
426 /* dwOptions values */
427 #define DBO_CHECKHEAP 0x0001
428 #define DBO_BUFFERFILL 0x0004
429 #define DBO_DISABLEGPTRAPPING 0x0010
430 #define DBO_CHECKFREE 0x0020
432 #define DBO_SILENT 0x8000
434 #define DBO_TRACEBREAK 0x2000
435 #define DBO_WARNINGBREAK 0x1000
436 #define DBO_NOERRORBREAK 0x0800
437 #define DBO_NOFATALBREAK 0x0400
438 #define DBO_INT3BREAK 0x0100
440 /* DebugOutput flags values */
441 #define DBF_TRACE 0x0000
442 #define DBF_WARNING 0x4000
443 #define DBF_ERROR 0x8000
444 #define DBF_FATAL 0xc000
446 /* dwFilter values */
447 #define DBF_KERNEL 0x1000
448 #define DBF_KRN_MEMMAN 0x0001
449 #define DBF_KRN_LOADMODULE 0x0002
450 #define DBF_KRN_SEGMENTLOAD 0x0004
451 #define DBF_USER 0x0800
452 #define DBF_GDI 0x0400
453 #define DBF_MMSYSTEM 0x0040
454 #define DBF_PENWIN 0x0020
455 #define DBF_APPLICATION 0x0008
456 #define DBF_DRIVER 0x0010
458 #endif /* NOLOGERROR */
460 /***********************************************************************
461 * GetWinDebugInfo (KERNEL.355)
463 BOOL16 WINAPI GetWinDebugInfo16(WINDEBUGINFO16 *lpwdi, UINT16 flags)
465 FIXME("(%8lx,%d): stub returning 0\n",
466 (unsigned long)lpwdi, flags);
467 /* 0 means not in debugging mode/version */
468 /* Can this type of debugging be used in wine ? */
469 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
470 return 0;
473 /***********************************************************************
474 * SetWinDebugInfo (KERNEL.356)
476 BOOL16 WINAPI SetWinDebugInfo16(WINDEBUGINFO16 *lpwdi)
478 FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi);
479 /* 0 means not in debugging mode/version */
480 /* Can this type of debugging be used in wine ? */
481 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
482 return 0;
485 /***********************************************************************
486 * UnicodeToAnsi (KERNEL.434)
488 INT16 WINAPI UnicodeToAnsi16( LPCWSTR src, LPSTR dst, INT16 codepage )
490 if ( codepage == -1 ) codepage = CP_ACP;
491 return WideCharToMultiByte( codepage, 0, src, -1, dst, 0x7fffffff, NULL, NULL );
494 /***********************************************************************
495 * VWin32_EventCreate (KERNEL.442)
497 HANDLE WINAPI VWin32_EventCreate(VOID)
499 HANDLE hEvent = CreateEventW( NULL, FALSE, 0, NULL );
500 return ConvertToGlobalHandle( hEvent );
503 /***********************************************************************
504 * VWin32_EventDestroy (KERNEL.443)
506 VOID WINAPI VWin32_EventDestroy(HANDLE event)
508 CloseHandle( event );
511 /***********************************************************************
512 * VWin32_EventWait (KERNEL.450)
514 VOID WINAPI VWin32_EventWait(HANDLE event)
516 DWORD mutex_count;
518 ReleaseThunkLock( &mutex_count );
519 WaitForSingleObject( event, INFINITE );
520 RestoreThunkLock( mutex_count );
523 /***********************************************************************
524 * VWin32_EventSet (KERNEL.451)
525 * KERNEL_479 (KERNEL.479)
527 VOID WINAPI VWin32_EventSet(HANDLE event)
529 SetEvent( event );
532 /***********************************************************************
533 * GetProcAddress32 (KERNEL.453)
535 FARPROC WINAPI GetProcAddress32_16( HMODULE hModule, LPCSTR function )
537 /* FIXME: we used to disable snoop when returning proc for Win16 subsystem */
538 return GetProcAddress( hModule, function );
541 /***********************************************************************
542 * CreateW32Event (KERNEL.457)
544 HANDLE WINAPI CreateW32Event( BOOL manual_reset, BOOL initial_state )
546 return CreateEventW( NULL, manual_reset, initial_state, NULL );
549 /***********************************************************************
550 * SetW32Event (KERNEL.458)
552 BOOL WINAPI SetW32Event( HANDLE handle )
554 return SetEvent( handle );
557 /***********************************************************************
558 * ResetW32Event (KERNEL.459)
560 BOOL WINAPI ResetW32Event( HANDLE handle )
562 return ResetEvent( handle );
565 /***********************************************************************
566 * WaitForSingleObject (KERNEL.460)
568 DWORD WINAPI WaitForSingleObject16( HANDLE handle, DWORD timeout )
570 DWORD retval, mutex_count;
572 ReleaseThunkLock( &mutex_count );
573 retval = WaitForSingleObject( handle, timeout );
574 RestoreThunkLock( mutex_count );
575 return retval;
578 /***********************************************************************
579 * WaitForMultipleObjects (KERNEL.461)
581 DWORD WINAPI WaitForMultipleObjects16( DWORD count, const HANDLE *handles,
582 BOOL wait_all, DWORD timeout )
584 DWORD retval, mutex_count;
586 ReleaseThunkLock( &mutex_count );
587 retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, FALSE );
588 RestoreThunkLock( mutex_count );
589 return retval;
592 /***********************************************************************
593 * GetCurrentThreadId (KERNEL.462)
595 DWORD WINAPI GetCurrentThreadId16(void)
597 return GetCurrentThreadId();
600 /***********************************************************************
601 * ExitProcess (KERNEL.466)
603 void WINAPI ExitProcess16( WORD status )
605 DWORD count;
606 ReleaseThunkLock( &count );
607 ExitProcess( status );
610 /***********************************************************************
611 * GetCurrentProcessId (KERNEL.471)
613 DWORD WINAPI GetCurrentProcessId16(void)
615 return GetCurrentProcessId();
618 /*********************************************************************
619 * CloseW32Handle (KERNEL.474)
621 BOOL WINAPI CloseW32Handle( HANDLE handle )
623 return CloseHandle( handle );
626 /***********************************************************************
627 * ConvertToGlobalHandle (KERNEL.476)
629 HANDLE WINAPI ConvertToGlobalHandle16( HANDLE handle )
631 return ConvertToGlobalHandle( handle );
634 /*********************************************************************
635 * MapProcessHandle (KERNEL.483)
637 DWORD WINAPI MapProcessHandle( HANDLE hProcess )
639 return GetProcessId( hProcess );
642 /***********************************************************************
643 * SetProcessDword (KERNEL.484)
644 * 'Of course you cannot directly access Windows internal structures'
646 void WINAPI SetProcessDword16( DWORD dwProcessID, INT offset, DWORD value )
648 TRACE("(%d, %d)\n", dwProcessID, offset );
650 if (dwProcessID && dwProcessID != GetCurrentProcessId())
652 ERR("%d: process %x not accessible\n", offset, dwProcessID);
653 return;
656 switch ( offset )
658 case GPD_APP_COMPAT_FLAGS:
659 case GPD_LOAD_DONE_EVENT:
660 case GPD_HINSTANCE16:
661 case GPD_WINDOWS_VERSION:
662 case GPD_THDB:
663 case GPD_PDB:
664 case GPD_STARTF_SHELLDATA:
665 case GPD_STARTF_HOTKEY:
666 case GPD_STARTF_SHOWWINDOW:
667 case GPD_STARTF_SIZE:
668 case GPD_STARTF_POSITION:
669 case GPD_STARTF_FLAGS:
670 case GPD_PARENT:
671 case GPD_FLAGS:
672 ERR("Not allowed to modify offset %d\n", offset );
673 break;
674 case GPD_USERDATA:
675 process_dword = value;
676 break;
677 default:
678 ERR("Unknown offset %d\n", offset );
679 break;
683 /***********************************************************************
684 * GetProcessDword (KERNEL.485)
685 * 'Of course you cannot directly access Windows internal structures'
687 DWORD WINAPI GetProcessDword16( DWORD dwProcessID, INT offset )
689 DWORD x, y;
690 STARTUPINFOW siw;
692 TRACE("(%d, %d)\n", dwProcessID, offset );
694 if (dwProcessID && dwProcessID != GetCurrentProcessId())
696 ERR("%d: process %x not accessible\n", offset, dwProcessID);
697 return 0;
700 switch ( offset )
702 case GPD_APP_COMPAT_FLAGS:
703 return GetAppCompatFlags16(0);
704 case GPD_LOAD_DONE_EVENT:
705 return 0;
706 case GPD_HINSTANCE16:
707 return GetTaskDS16();
708 case GPD_WINDOWS_VERSION:
709 return GetExeVersion16();
710 case GPD_THDB:
711 return (DWORD_PTR)NtCurrentTeb() - 0x10 /* FIXME */;
712 case GPD_PDB:
713 return (DWORD_PTR)NtCurrentTeb()->Peb; /* FIXME: truncating a pointer */
714 case GPD_STARTF_SHELLDATA: /* return stdoutput handle from startupinfo ??? */
715 GetStartupInfoW(&siw);
716 return HandleToULong(siw.hStdOutput);
717 case GPD_STARTF_HOTKEY: /* return stdinput handle from startupinfo ??? */
718 GetStartupInfoW(&siw);
719 return HandleToULong(siw.hStdInput);
720 case GPD_STARTF_SHOWWINDOW:
721 GetStartupInfoW(&siw);
722 return siw.wShowWindow;
723 case GPD_STARTF_SIZE:
724 GetStartupInfoW(&siw);
725 x = siw.dwXSize;
726 if ( (INT)x == CW_USEDEFAULT ) x = CW_USEDEFAULT16;
727 y = siw.dwYSize;
728 if ( (INT)y == CW_USEDEFAULT ) y = CW_USEDEFAULT16;
729 return MAKELONG( x, y );
730 case GPD_STARTF_POSITION:
731 GetStartupInfoW(&siw);
732 x = siw.dwX;
733 if ( (INT)x == CW_USEDEFAULT ) x = CW_USEDEFAULT16;
734 y = siw.dwY;
735 if ( (INT)y == CW_USEDEFAULT ) y = CW_USEDEFAULT16;
736 return MAKELONG( x, y );
737 case GPD_STARTF_FLAGS:
738 GetStartupInfoW(&siw);
739 return siw.dwFlags;
740 case GPD_PARENT:
741 return 0;
742 case GPD_FLAGS:
743 return GetProcessFlags(0);
744 case GPD_USERDATA:
745 return process_dword;
746 default:
747 ERR("Unknown offset %d\n", offset );
748 return 0;
752 /***********************************************************************
753 * FreeLibrary32 (KERNEL.486)
755 BOOL WINAPI FreeLibrary32_16( HINSTANCE module )
757 return FreeLibrary( module );
760 /***********************************************************************
761 * GetModuleFileName32 (KERNEL.487)
763 DWORD WINAPI GetModuleFileName32_16( HMODULE module, LPSTR buffer, DWORD size )
765 return GetModuleFileNameA( module, buffer, size );
768 /***********************************************************************
769 * GetModuleHandle32 (KERNEL.488)
771 HMODULE WINAPI GetModuleHandle32_16(LPCSTR module)
773 return GetModuleHandleA( module );
776 /***********************************************************************
777 * RegisterServiceProcess (KERNEL.491)
779 DWORD WINAPI RegisterServiceProcess16( DWORD dwProcessId, DWORD dwType )
781 return 1; /* success */
784 /***********************************************************************
785 * WaitForMultipleObjectsEx (KERNEL.495)
787 DWORD WINAPI WaitForMultipleObjectsEx16( DWORD count, const HANDLE *handles,
788 BOOL wait_all, DWORD timeout, BOOL alertable )
790 DWORD retval, mutex_count;
792 ReleaseThunkLock( &mutex_count );
793 retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, alertable );
794 RestoreThunkLock( mutex_count );
795 return retval;
798 /**********************************************************************
799 * VWin32_BoostThreadGroup (KERNEL.535)
801 VOID WINAPI VWin32_BoostThreadGroup( DWORD threadId, INT boost )
803 FIXME("(0x%08x,%d): stub\n", threadId, boost);
807 /**********************************************************************
808 * VWin32_BoostThreadStatic (KERNEL.536)
810 VOID WINAPI VWin32_BoostThreadStatic( DWORD threadId, INT boost )
812 FIXME("(0x%08x,%d): stub\n", threadId, boost);
815 /***********************************************************************
816 * EnableDos (KERNEL.41)
817 * DisableDos (KERNEL.42)
818 * GetLastDiskChange (KERNEL.98)
819 * ValidateCodeSegments (KERNEL.100)
820 * KbdRst (KERNEL.123)
821 * EnableKernel (KERNEL.124)
822 * DisableKernel (KERNEL.125)
823 * ValidateFreeSpaces (KERNEL.200)
824 * K237 (KERNEL.237)
825 * BUNNY_351 (KERNEL.351)
826 * PIGLET_361 (KERNEL.361)
828 * Entry point for kernel functions that do nothing.
830 LONG WINAPI KERNEL_nop(void)
832 return 0;
835 /***********************************************************************
836 * ToolHelpHook (KERNEL.341)
837 * see "Undocumented Windows"
839 FARPROC16 WINAPI ToolHelpHook16(FARPROC16 func)
841 static FARPROC16 hook;
843 FIXME("(%p), stub.\n", func);
844 return InterlockedExchangePointer( (void **)&hook, func );
847 /* thunk for 16-bit CreateThread */
848 struct thread_args
850 FARPROC16 proc;
851 DWORD param;
854 static DWORD CALLBACK start_thread16( LPVOID threadArgs )
856 struct thread_args args = *(struct thread_args *)threadArgs;
857 HeapFree( GetProcessHeap(), 0, threadArgs );
858 return K32WOWCallback16( (DWORD)args.proc, args.param );
861 /***********************************************************************
862 * CreateThread16 (KERNEL.441)
864 HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
865 FARPROC16 start, SEGPTR param,
866 DWORD flags, LPDWORD id )
868 struct thread_args *args = HeapAlloc( GetProcessHeap(), 0, sizeof(*args) );
869 if (!args) return INVALID_HANDLE_VALUE;
870 args->proc = start;
871 args->param = param;
872 return CreateThread( sa, stack, start_thread16, args, flags, id );
875 /***********************************************************************
876 * _DebugOutput (KERNEL.328)
878 void WINAPIV _DebugOutput( WORD flags, LPCSTR spec, VA_LIST16 valist )
880 char caller[101];
882 /* Decode caller address */
883 if (!GetModuleName16( GetExePtr(CURRENT_STACK16->cs), caller, sizeof(caller) ))
884 sprintf( caller, "%04X:%04X", CURRENT_STACK16->cs, CURRENT_STACK16->ip );
886 /* FIXME: cannot use wvsnprintf16 from kernel */
887 /* wvsnprintf16( temp, sizeof(temp), spec, valist ); */
889 /* Output */
890 FIXME("%s %04x %s\n", caller, flags, debugstr_a(spec) );