1 /*
2 * 16-bit kernel initialization code
3 *
4 * Copyright 2000 Alexandre Julliard
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winternl.h"
27 #include "wownt32.h"
28 #include "wine/winuser16.h"
29
30 #include "kernel_private.h"
31 #include "kernel16_private.h"
32 #include "wine/debug.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(module);
35
36 extern DWORD WINAPI GetProcessFlags( DWORD processid );
37
38 static DWORD process_dword;
39
40 /**************************************************************************
41 * DllEntryPoint (KERNEL.669)
42 */
43 BOOL WINAPI KERNEL_DllEntryPoint( DWORD reasion, HINSTANCE16 inst, WORD ds,
44 WORD heap, DWORD reserved1, WORD reserved2 )
45 {
46 static int done;
47
48 /* the entry point can be called multiple times */
49 if (done) return TRUE;
50 done = 1;
51
52 /* Initialize 16-bit thunking entry points */
53 if (!WOWTHUNK_Init()) return FALSE;
54
55 /* Initialize DOS memory */
56 if (!DOSMEM_Init()) return FALSE;
57
58 /* Initialize special KERNEL entry points */
59
60 NE_SetEntryPoint( inst, 178, GetWinFlags16() );
61
62 NE_SetEntryPoint( inst, 454, wine_get_cs() );
63 NE_SetEntryPoint( inst, 455, wine_get_ds() );
64
65 NE_SetEntryPoint( inst, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
66 NE_SetEntryPoint( inst, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
67 NE_SetEntryPoint( inst, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
68 NE_SetEntryPoint( inst, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
69
70 /* Initialize KERNEL.THHOOK */
71 TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( inst, (LPCSTR)332 )));
72
73 /* Initialize the real-mode selector entry points */
74 #define SET_ENTRY_POINT( num, addr ) \
75 NE_SetEntryPoint( inst, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
76 DOSMEM_MapDosToLinear(addr), 0x10000, inst, \
77 WINE_LDT_FLAGS_DATA ))
78
79 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
80 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
81 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
82 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
83 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
84 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
85 #undef SET_ENTRY_POINT
86
87 /* Force loading of some dlls */
88 LoadLibrary16( "system.drv" );
89
90 return TRUE;
91 }
92
93 /***********************************************************************
94 * GetVersion (KERNEL.3)
95 */
96 DWORD WINAPI GetVersion16(void)
97 {
98 static WORD dosver, winver;
99
100 if (!dosver) /* not determined yet */
101 {
102 RTL_OSVERSIONINFOEXW info;
103
104 info.dwOSVersionInfoSize = sizeof(info);
105 if (RtlGetVersion( &info )) return 0;
106
107 if (info.dwMajorVersion <= 3)
108 winver = MAKEWORD( info.dwMajorVersion, info.dwMinorVersion );
109 else
110 winver = MAKEWORD( 3, 95 );
111
112 switch(info.dwPlatformId)
113 {
114 case VER_PLATFORM_WIN32s:
115 switch(MAKELONG( info.dwMinorVersion, info.dwMajorVersion ))
116 {
117 case 0x0200:
118 dosver = 0x0303; /* DOS 3.3 for Windows 2.0 */
119 break;
120 case 0x0300:
121 dosver = 0x0500; /* DOS 5.0 for Windows 3.0 */
122 break;
123 default:
124 dosver = 0x0616; /* DOS 6.22 for Windows 3.1 and later */
125 break;
126 }
127 break;
128 case VER_PLATFORM_WIN32_WINDOWS:
129 /* DOS 8.0 for WinME, 7.0 for Win95/98 */
130 if (info.dwMinorVersion >= 90) dosver = 0x0800;
131 else dosver = 0x0700;
132 break;
133 case VER_PLATFORM_WIN32_NT:
134 dosver = 0x0500; /* always DOS 5.0 for NT */
135 break;
136 }
137 TRACE( "DOS %d.%02d Win %d.%02d\n",
138 HIBYTE(dosver), LOBYTE(dosver), LOBYTE(winver), HIBYTE(winver) );
139 }
140 return MAKELONG( winver, dosver );
141 }
142
143 /***********************************************************************
144 * Reserved1 (KERNEL.77)
145 */
146 SEGPTR WINAPI KERNEL_AnsiNext16(SEGPTR current)
147 {
148 return (*(char *)MapSL(current)) ? current + 1 : current;
149 }
150
151 /***********************************************************************
152 * Reserved2(KERNEL.78)
153 */
154 SEGPTR WINAPI KERNEL_AnsiPrev16( SEGPTR start, SEGPTR current )
155 {
156 return (current==start)?start:current-1;
157 }
158
159 /***********************************************************************
160 * Reserved3 (KERNEL.79)
161 */
162 SEGPTR WINAPI KERNEL_AnsiUpper16( SEGPTR strOrChar )
163 {
164 /* uppercase only one char if strOrChar < 0x10000 */
165 if (HIWORD(strOrChar))
166 {
167 char *s = MapSL(strOrChar);
168 while (*s)
169 {
170 *s = toupper(*s);
171 s++;
172 }
173 return strOrChar;
174 }
175 else return toupper((char)strOrChar);
176 }
177
178 /***********************************************************************
179 * Reserved4 (KERNEL.80)
180 */
181 SEGPTR WINAPI KERNEL_AnsiLower16( SEGPTR strOrChar )
182 {
183 /* lowercase only one char if strOrChar < 0x10000 */
184 if (HIWORD(strOrChar))
185 {
186 char *s = MapSL(strOrChar);
187 while (*s)
188 {
189 *s = tolower(*s);
190 s++;
191 }
192 return strOrChar;
193 }
194 else return tolower((char)strOrChar);
195 }
196
197 /***********************************************************************
198 * Reserved5 (KERNEL.87)
199 */
200 INT16 WINAPI KERNEL_lstrcmp16( LPCSTR str1, LPCSTR str2 )
201 {
202 return (INT16)strcmp( str1, str2 );
203 }
204
205 /***********************************************************************
206 * lstrcpy (KERNEL.88)
207 */
208 SEGPTR WINAPI lstrcpy16( SEGPTR dst, LPCSTR src )
209 {
210 if (!lstrcpyA( MapSL(dst), src )) dst = 0;
211 return dst;
212 }
213
214 /***********************************************************************
215 * lstrcat (KERNEL.89)
216 */
217 SEGPTR WINAPI lstrcat16( SEGPTR dst, LPCSTR src )
218 {
219 /* Windows does not check for NULL pointers here, so we don't either */
220 strcat( MapSL(dst), src );
221 return dst;
222 }
223
224 /***********************************************************************
225 * lstrlen (KERNEL.90)
226 */
227 INT16 WINAPI lstrlen16( LPCSTR str )
228 {
229 return (INT16)lstrlenA( str );
230 }
231
232 /***********************************************************************
233 * OutputDebugString (KERNEL.115)
234 */
235 void WINAPI OutputDebugString16( LPCSTR str )
236 {
237 OutputDebugStringA( str );
238 }
239
240 /***********************************************************************
241 * GetWinFlags (KERNEL.132)
242 */
243 DWORD WINAPI GetWinFlags16(void)
244 {
245 static const long cpuflags[5] = { WF_CPU086, WF_CPU186, WF_CPU286, WF_CPU386, WF_CPU486 };
246 SYSTEM_INFO si;
247 OSVERSIONINFOA ovi;
248 DWORD result;
249
250 GetSystemInfo(&si);
251
252 /* There doesn't seem to be any Pentium flag. */
253 result = cpuflags[min(si.wProcessorLevel, 4)] | WF_ENHANCED | WF_PMODE | WF_80x87 | WF_PAGING;
254 if (si.wProcessorLevel >= 4) result |= WF_HASCPUID;
255 ovi.dwOSVersionInfoSize = sizeof(ovi);
256 GetVersionExA(&ovi);
257 if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT)
258 result |= WF_WIN32WOW; /* undocumented WF_WINNT */
259 return result;
260 }
261
262 /***********************************************************************
263 * GetVersionEx (KERNEL.149)
264 */
265 BOOL16 WINAPI GetVersionEx16(OSVERSIONINFO16 *v)
266 {
267 OSVERSIONINFOA info;
268
269 if (v->dwOSVersionInfoSize < sizeof(OSVERSIONINFO16))
270 {
271 WARN("wrong OSVERSIONINFO size from app\n");
272 return FALSE;
273 }
274
275 info.dwOSVersionInfoSize = sizeof(info);
276 if (!GetVersionExA( &info )) return FALSE;
277
278 v->dwMajorVersion = info.dwMajorVersion;
279 v->dwMinorVersion = info.dwMinorVersion;
280 v->dwBuildNumber = info.dwBuildNumber;
281 v->dwPlatformId = info.dwPlatformId;
282 strcpy( v->szCSDVersion, info.szCSDVersion );
283 return TRUE;
284 }
285
286 /***********************************************************************
287 * DebugBreak (KERNEL.203)
288 */
289 void WINAPI DebugBreak16( CONTEXT *context )
290 {
291 EXCEPTION_RECORD rec;
292
293 rec.ExceptionCode = EXCEPTION_BREAKPOINT;
294 rec.ExceptionFlags = 0;
295 rec.ExceptionRecord = NULL;
296 rec.ExceptionAddress = (LPVOID)context->Eip;
297 rec.NumberParameters = 0;
298 NtRaiseException( &rec, context, TRUE );
299 }
300
301 /***********************************************************************
302 * K329 (KERNEL.329)
303 *
304 * TODO:
305 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
306 */
307 void WINAPI DebugFillBuffer(LPSTR lpBuffer, WORD wBytes)
308 {
309 memset(lpBuffer, 0xf9 /* DBGFILL_BUFFER */, wBytes);
310 }
311
312 /***********************************************************************
313 * DiagQuery (KERNEL.339)
314 *
315 * returns TRUE if Win called with "/b" (bootlog.txt)
316 */
317 BOOL16 WINAPI DiagQuery16(void)
318 {
319 return FALSE;
320 }
321
322 /***********************************************************************
323 * DiagOutput (KERNEL.340)
324 *
325 * writes a debug string into <windir>\bootlog.txt
326 */
327 void WINAPI DiagOutput16(LPCSTR str)
328 {
329 /* FIXME */
330 TRACE("DIAGOUTPUT:%s\n", debugstr_a(str));
331 }
332
333 /***********************************************************************
334 * hmemcpy (KERNEL.348)
335 */
336 void WINAPI hmemcpy16( LPVOID dst, LPCVOID src, LONG count )
337 {
338 memcpy( dst, src, count );
339 }
340
341 /***********************************************************************
342 * lstrcpyn (KERNEL.353)
343 */
344 SEGPTR WINAPI lstrcpyn16( SEGPTR dst, LPCSTR src, INT16 n )
345 {
346 lstrcpynA( MapSL(dst), src, n );
347 return dst;
348 }
349
350 /***********************************************************************
351 * lstrcatn (KERNEL.352)
352 */
353 SEGPTR WINAPI lstrcatn16( SEGPTR dst, LPCSTR src, INT16 n )
354 {
355 LPSTR p = MapSL(dst);
356 LPSTR start = p;
357
358 while (*p) p++;
359 if ((n -= (p - start)) <= 0) return dst;
360 lstrcpynA( p, src, n );
361 return dst;
362 }
363
364 #if 0 /* Not used at this time. This is here for documentation only */
365
366 /* WINDEBUGINFO flags values */
367 #define WDI_OPTIONS 0x0001
368 #define WDI_FILTER 0x0002
369 #define WDI_ALLOCBREAK 0x0004
370
371 /* dwOptions values */
372 #define DBO_CHECKHEAP 0x0001
373 #define DBO_BUFFERFILL 0x0004
374 #define DBO_DISABLEGPTRAPPING 0x0010
375 #define DBO_CHECKFREE 0x0020
376
377 #define DBO_SILENT 0x8000
378
379 #define DBO_TRACEBREAK 0x2000
380 #define DBO_WARNINGBREAK 0x1000
381 #define DBO_NOERRORBREAK 0x0800
382 #define DBO_NOFATALBREAK 0x0400
383 #define DBO_INT3BREAK 0x0100
384
385 /* DebugOutput flags values */
386 #define DBF_TRACE 0x0000
387 #define DBF_WARNING 0x4000
388 #define DBF_ERROR 0x8000
389 #define DBF_FATAL 0xc000
390
391 /* dwFilter values */
392 #define DBF_KERNEL 0x1000
393 #define DBF_KRN_MEMMAN 0x0001
394 #define DBF_KRN_LOADMODULE 0x0002
395 #define DBF_KRN_SEGMENTLOAD 0x0004
396 #define DBF_USER 0x0800
397 #define DBF_GDI 0x0400
398 #define DBF_MMSYSTEM 0x0040
399 #define DBF_PENWIN 0x0020
400 #define DBF_APPLICATION 0x0008
401 #define DBF_DRIVER 0x0010
402
403 #endif /* NOLOGERROR */
404
405 /***********************************************************************
406 * GetWinDebugInfo (KERNEL.355)
407 */
408 BOOL16 WINAPI GetWinDebugInfo16(WINDEBUGINFO16 *lpwdi, UINT16 flags)
409 {
410 FIXME("(%8lx,%d): stub returning 0\n",
411 (unsigned long)lpwdi, flags);
412 /* 0 means not in debugging mode/version */
413 /* Can this type of debugging be used in wine ? */
414 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
415 return 0;
416 }
417
418 /***********************************************************************
419 * SetWinDebugInfo (KERNEL.356)
420 */
421 BOOL16 WINAPI SetWinDebugInfo16(WINDEBUGINFO16 *lpwdi)
422 {
423 FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi);
424 /* 0 means not in debugging mode/version */
425 /* Can this type of debugging be used in wine ? */
426 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
427 return 0;
428 }
429
430 /***********************************************************************
431 * UnicodeToAnsi (KERNEL.434)
432 */
433 INT16 WINAPI UnicodeToAnsi16( LPCWSTR src, LPSTR dst, INT16 codepage )
434 {
435 if ( codepage == -1 ) codepage = CP_ACP;
436 return WideCharToMultiByte( codepage, 0, src, -1, dst, 0x7fffffff, NULL, NULL );
437 }
438
439 /***********************************************************************
440 * VWin32_EventCreate (KERNEL.442)
441 */
442 HANDLE WINAPI VWin32_EventCreate(VOID)
443 {
444 HANDLE hEvent = CreateEventW( NULL, FALSE, 0, NULL );
445 return ConvertToGlobalHandle( hEvent );
446 }
447
448 /***********************************************************************
449 * VWin32_EventDestroy (KERNEL.443)
450 */
451 VOID WINAPI VWin32_EventDestroy(HANDLE event)
452 {
453 CloseHandle( event );
454 }
455
456 /***********************************************************************
457 * VWin32_EventWait (KERNEL.450)
458 */
459 VOID WINAPI VWin32_EventWait(HANDLE event)
460 {
461 DWORD mutex_count;
462
463 ReleaseThunkLock( &mutex_count );
464 WaitForSingleObject( event, INFINITE );
465 RestoreThunkLock( mutex_count );
466 }
467
468 /***********************************************************************
469 * VWin32_EventSet (KERNEL.451)
470 * KERNEL_479 (KERNEL.479)
471 */
472 VOID WINAPI VWin32_EventSet(HANDLE event)
473 {
474 SetEvent( event );
475 }
476
477 /***********************************************************************
478 * GetProcAddress32 (KERNEL.453)
479 */
480 FARPROC WINAPI GetProcAddress32_16( HMODULE hModule, LPCSTR function )
481 {
482 /* FIXME: we used to disable snoop when returning proc for Win16 subsystem */
483 return GetProcAddress( hModule, function );
484 }
485
486 /***********************************************************************
487 * CreateW32Event (KERNEL.457)
488 */
489 HANDLE WINAPI CreateW32Event( BOOL manual_reset, BOOL initial_state )
490 {
491 return CreateEventW( NULL, manual_reset, initial_state, NULL );
492 }
493
494 /***********************************************************************
495 * SetW32Event (KERNEL.458)
496 */
497 BOOL WINAPI SetW32Event( HANDLE handle )
498 {
499 return SetEvent( handle );
500 }
501
502 /***********************************************************************
503 * ResetW32Event (KERNEL.459)
504 */
505 BOOL WINAPI ResetW32Event( HANDLE handle )
506 {
507 return ResetEvent( handle );
508 }
509
510 /***********************************************************************
511 * WaitForSingleObject (KERNEL.460)
512 */
513 DWORD WINAPI WaitForSingleObject16( HANDLE handle, DWORD timeout )
514 {
515 DWORD retval, mutex_count;
516
517 ReleaseThunkLock( &mutex_count );
518 retval = WaitForSingleObject( handle, timeout );
519 RestoreThunkLock( mutex_count );
520 return retval;
521 }
522
523 /***********************************************************************
524 * WaitForMultipleObjects (KERNEL.461)
525 */
526 DWORD WINAPI WaitForMultipleObjects16( DWORD count, const HANDLE *handles,
527 BOOL wait_all, DWORD timeout )
528 {
529 DWORD retval, mutex_count;
530
531 ReleaseThunkLock( &mutex_count );
532 retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, FALSE );
533 RestoreThunkLock( mutex_count );
534 return retval;
535 }
536
537 /***********************************************************************
538 * GetCurrentThreadId (KERNEL.462)
539 */
540 DWORD WINAPI GetCurrentThreadId16(void)
541 {
542 return GetCurrentThreadId();
543 }
544
545 /***********************************************************************
546 * ExitProcess (KERNEL.466)
547 */
548 void WINAPI ExitProcess16( WORD status )
549 {
550 DWORD count;
551 ReleaseThunkLock( &count );
552 ExitProcess( status );
553 }
554
555 /***********************************************************************
556 * GetCurrentProcessId (KERNEL.471)
557 */
558 DWORD WINAPI GetCurrentProcessId16(void)
559 {
560 return GetCurrentProcessId();
561 }
562
563 /*********************************************************************
564 * CloseW32Handle (KERNEL.474)
565 */
566 BOOL WINAPI CloseW32Handle( HANDLE handle )
567 {
568 return CloseHandle( handle );
569 }
570
571 /***********************************************************************
572 * ConvertToGlobalHandle (KERNEL.476)
573 */
574 HANDLE WINAPI ConvertToGlobalHandle16( HANDLE handle )
575 {
576 return ConvertToGlobalHandle( handle );
577 }
578
579 /*********************************************************************
580 * MapProcessHandle (KERNEL.483)
581 */
582 DWORD WINAPI MapProcessHandle( HANDLE hProcess )
583 {
584 return GetProcessId( hProcess );
585 }
586
587 /***********************************************************************
588 * SetProcessDword (KERNEL.484)
589 * 'Of course you cannot directly access Windows internal structures'
590 */
591 void WINAPI SetProcessDword16( DWORD dwProcessID, INT offset, DWORD value )
592 {
593 TRACE("(%d, %d)\n", dwProcessID, offset );
594
595 if (dwProcessID && dwProcessID != GetCurrentProcessId())
596 {
597 ERR("%d: process %x not accessible\n", offset, dwProcessID);
598 return;
599 }
600
601 switch ( offset )
602 {
603 case GPD_APP_COMPAT_FLAGS:
604 case GPD_LOAD_DONE_EVENT:
605 case GPD_HINSTANCE16:
606 case GPD_WINDOWS_VERSION:
607 case GPD_THDB:
608 case GPD_PDB:
609 case GPD_STARTF_SHELLDATA:
610 case GPD_STARTF_HOTKEY:
611 case GPD_STARTF_SHOWWINDOW:
612 case GPD_STARTF_SIZE:
613 case GPD_STARTF_POSITION:
614 case GPD_STARTF_FLAGS:
615 case GPD_PARENT:
616 case GPD_FLAGS:
617 ERR("Not allowed to modify offset %d\n", offset );
618 break;
619 case GPD_USERDATA:
620 process_dword = value;
621 break;
622 default:
623 ERR("Unknown offset %d\n", offset );
624 break;
625 }
626 }
627
628 /***********************************************************************
629 * GetProcessDword (KERNEL.485)
630 * 'Of course you cannot directly access Windows internal structures'
631 */
632 DWORD WINAPI GetProcessDword16( DWORD dwProcessID, INT offset )
633 {
634 DWORD x, y;
635 STARTUPINFOW siw;
636
637 TRACE("(%d, %d)\n", dwProcessID, offset );
638
639 if (dwProcessID && dwProcessID != GetCurrentProcessId())
640 {
641 ERR("%d: process %x not accessible\n", offset, dwProcessID);
642 return 0;
643 }
644
645 switch ( offset )
646 {
647 case GPD_APP_COMPAT_FLAGS:
648 return GetAppCompatFlags16(0);
649 case GPD_LOAD_DONE_EVENT:
650 return 0;
651 case GPD_HINSTANCE16:
652 return GetTaskDS16();
653 case GPD_WINDOWS_VERSION:
654 return GetExeVersion16();
655 case GPD_THDB:
656 return (DWORD_PTR)NtCurrentTeb() - 0x10 /* FIXME */;
657 case GPD_PDB:
658 return (DWORD_PTR)NtCurrentTeb()->Peb; /* FIXME: truncating a pointer */
659 case GPD_STARTF_SHELLDATA: /* return stdoutput handle from startupinfo ??? */
660 GetStartupInfoW(&siw);
661 return HandleToULong(siw.hStdOutput);
662 case GPD_STARTF_HOTKEY: /* return stdinput handle from startupinfo ??? */
663 GetStartupInfoW(&siw);
664 return HandleToULong(siw.hStdInput);
665 case GPD_STARTF_SHOWWINDOW:
666 GetStartupInfoW(&siw);
667 return siw.wShowWindow;
668 case GPD_STARTF_SIZE:
669 GetStartupInfoW(&siw);
670 x = siw.dwXSize;
671 if ( (INT)x == CW_USEDEFAULT ) x = CW_USEDEFAULT16;
672 y = siw.dwYSize;
673 if ( (INT)y == CW_USEDEFAULT ) y = CW_USEDEFAULT16;
674 return MAKELONG( x, y );
675 case GPD_STARTF_POSITION:
676 GetStartupInfoW(&siw);
677 x = siw.dwX;
678 if ( (INT)x == CW_USEDEFAULT ) x = CW_USEDEFAULT16;
679 y = siw.dwY;
680 if ( (INT)y == CW_USEDEFAULT ) y = CW_USEDEFAULT16;
681 return MAKELONG( x, y );
682 case GPD_STARTF_FLAGS:
683 GetStartupInfoW(&siw);
684 return siw.dwFlags;
685 case GPD_PARENT:
686 return 0;
687 case GPD_FLAGS:
688 return GetProcessFlags(0);
689 case GPD_USERDATA:
690 return process_dword;
691 default:
692 ERR("Unknown offset %d\n", offset );
693 return 0;
694 }
695 }
696
697 /***********************************************************************
698 * FreeLibrary32 (KERNEL.486)
699 */
700 BOOL WINAPI FreeLibrary32_16( HINSTANCE module )
701 {
702 return FreeLibrary( module );
703 }
704
705 /***********************************************************************
706 * GetModuleFileName32 (KERNEL.487)
707 */
708 DWORD WINAPI GetModuleFileName32_16( HMODULE module, LPSTR buffer, DWORD size )
709 {
710 return GetModuleFileNameA( module, buffer, size );
711 }
712
713 /***********************************************************************
714 * GetModuleHandle32 (KERNEL.488)
715 */
716 HMODULE WINAPI GetModuleHandle32_16(LPCSTR module)
717 {
718 return GetModuleHandleA( module );
719 }
720
721 /***********************************************************************
722 * RegisterServiceProcess (KERNEL.491)
723 */
724 DWORD WINAPI RegisterServiceProcess16( DWORD dwProcessId, DWORD dwType )
725 {
726 return 1; /* success */
727 }
728
729 /***********************************************************************
730 * WaitForMultipleObjectsEx (KERNEL.495)
731 */
732 DWORD WINAPI WaitForMultipleObjectsEx16( DWORD count, const HANDLE *handles,
733 BOOL wait_all, DWORD timeout, BOOL alertable )
734 {
735 DWORD retval, mutex_count;
736
737 ReleaseThunkLock( &mutex_count );
738 retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, alertable );
739 RestoreThunkLock( mutex_count );
740 return retval;
741 }
742
743 /**********************************************************************
744 * VWin32_BoostThreadGroup (KERNEL.535)
745 */
746 VOID WINAPI VWin32_BoostThreadGroup( DWORD threadId, INT boost )
747 {
748 FIXME("(0x%08x,%d): stub\n", threadId, boost);
749 }
750
751
752 /**********************************************************************
753 * VWin32_BoostThreadStatic (KERNEL.536)
754 */
755 VOID WINAPI VWin32_BoostThreadStatic( DWORD threadId, INT boost )
756 {
757 FIXME("(0x%08x,%d): stub\n", threadId, boost);
758 }
759
760 /***********************************************************************
761 * EnableDos (KERNEL.41)
762 * DisableDos (KERNEL.42)
763 * GetLastDiskChange (KERNEL.98)
764 * ValidateCodeSegments (KERNEL.100)
765 * KbdRst (KERNEL.123)
766 * EnableKernel (KERNEL.124)
767 * DisableKernel (KERNEL.125)
768 * ValidateFreeSpaces (KERNEL.200)
769 * K237 (KERNEL.237)
770 * BUNNY_351 (KERNEL.351)
771 * PIGLET_361 (KERNEL.361)
772 *
773 * Entry point for kernel functions that do nothing.
774 */
775 LONG WINAPI KERNEL_nop(void)
776 {
777 return 0;
778 }
779
780 /***********************************************************************
781 * ToolHelpHook (KERNEL.341)
782 * see "Undocumented Windows"
783 */
784 FARPROC16 WINAPI ToolHelpHook16(FARPROC16 func)
785 {
786 static FARPROC16 hook;
787
788 FIXME("(%p), stub.\n", func);
789 return InterlockedExchangePointer( (void **)&hook, func );
790 }
791
792 /* thunk for 16-bit CreateThread */
793 struct thread_args
794 {
795 FARPROC16 proc;
796 DWORD param;
797 };
798
799 static DWORD CALLBACK start_thread16( LPVOID threadArgs )
800 {
801 struct thread_args args = *(struct thread_args *)threadArgs;
802 HeapFree( GetProcessHeap(), 0, threadArgs );
803 return K32WOWCallback16( (DWORD)args.proc, args.param );
804 }
805
806 /***********************************************************************
807 * CreateThread16 (KERNEL.441)
808 */
809 HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
810 FARPROC16 start, SEGPTR param,
811 DWORD flags, LPDWORD id )
812 {
813 struct thread_args *args = HeapAlloc( GetProcessHeap(), 0, sizeof(*args) );
814 if (!args) return INVALID_HANDLE_VALUE;
815 args->proc = start;
816 args->param = param;
817 return CreateThread( sa, stack, start_thread16, args, flags, id );
818 }
819
820 /***********************************************************************
821 * _DebugOutput (KERNEL.328)
822 */
823 void WINAPIV _DebugOutput( WORD flags, LPCSTR spec, VA_LIST16 valist )
824 {
825 char caller[101];
826
827 /* Decode caller address */
828 if (!GetModuleName16( GetExePtr(CURRENT_STACK16->cs), caller, sizeof(caller) ))
829 sprintf( caller, "%04X:%04X", CURRENT_STACK16->cs, CURRENT_STACK16->ip );
830
831 /* FIXME: cannot use wvsnprintf16 from kernel */
832 /* wvsnprintf16( temp, sizeof(temp), spec, valist ); */
833
834 /* Output */
835 FIXME("%s %04x %s\n", caller, flags, debugstr_a(spec) );
836 }
837
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.