shell32: Update Lithuanian translation.
[wine/multimedia.git] / dlls / kernel32 / kernel16.c
blob094156dfbf8443ae8de36a9e6855e9c8f3c51515
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 #include "windef.h"
25 #include "winbase.h"
26 #include "winternl.h"
27 #include "wownt32.h"
29 #include "toolhelp.h"
30 #include "kernel_private.h"
31 #include "kernel16_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(module);
36 /**************************************************************************
37 * DllEntryPoint (KERNEL.669)
39 BOOL WINAPI KERNEL_DllEntryPoint( DWORD reasion, HINSTANCE16 inst, WORD ds,
40 WORD heap, DWORD reserved1, WORD reserved2 )
42 static int done;
44 /* the entry point can be called multiple times */
45 if (done) return TRUE;
46 done = 1;
48 /* Initialize 16-bit thunking entry points */
49 if (!WOWTHUNK_Init()) return FALSE;
51 /* Initialize DOS memory */
52 if (!DOSMEM_Init()) return FALSE;
54 /* Initialize special KERNEL entry points */
56 NE_SetEntryPoint( inst, 178, GetWinFlags16() );
58 NE_SetEntryPoint( inst, 454, wine_get_cs() );
59 NE_SetEntryPoint( inst, 455, wine_get_ds() );
61 NE_SetEntryPoint( inst, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
62 NE_SetEntryPoint( inst, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
63 NE_SetEntryPoint( inst, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
64 NE_SetEntryPoint( inst, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
66 /* Initialize KERNEL.THHOOK */
67 TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( inst, (LPCSTR)332 )));
69 /* Initialize the real-mode selector entry points */
70 #define SET_ENTRY_POINT( num, addr ) \
71 NE_SetEntryPoint( inst, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
72 DOSMEM_MapDosToLinear(addr), 0x10000, inst, \
73 WINE_LDT_FLAGS_DATA ))
75 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
76 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
77 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
78 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
79 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
80 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
81 #undef SET_ENTRY_POINT
83 /* Force loading of some dlls */
84 LoadLibrary16( "system.drv" );
86 return TRUE;
89 /***********************************************************************
90 * EnableDos (KERNEL.41)
91 * DisableDos (KERNEL.42)
92 * GetLastDiskChange (KERNEL.98)
93 * ValidateCodeSegments (KERNEL.100)
94 * KbdRst (KERNEL.123)
95 * EnableKernel (KERNEL.124)
96 * DisableKernel (KERNEL.125)
97 * ValidateFreeSpaces (KERNEL.200)
98 * K237 (KERNEL.237)
99 * BUNNY_351 (KERNEL.351)
100 * PIGLET_361 (KERNEL.361)
102 * Entry point for kernel functions that do nothing.
104 LONG WINAPI KERNEL_nop(void)
106 return 0;
110 /* thunk for 16-bit CreateThread */
111 struct thread_args
113 FARPROC16 proc;
114 DWORD param;
117 static DWORD CALLBACK start_thread16( LPVOID threadArgs )
119 struct thread_args args = *(struct thread_args *)threadArgs;
120 HeapFree( GetProcessHeap(), 0, threadArgs );
121 return K32WOWCallback16( (DWORD)args.proc, args.param );
124 /***********************************************************************
125 * CreateThread16 (KERNEL.441)
127 HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
128 FARPROC16 start, SEGPTR param,
129 DWORD flags, LPDWORD id )
131 struct thread_args *args = HeapAlloc( GetProcessHeap(), 0, sizeof(*args) );
132 if (!args) return INVALID_HANDLE_VALUE;
133 args->proc = start;
134 args->param = param;
135 return CreateThread( sa, stack, start_thread16, args, flags, id );
138 /***********************************************************************
139 * _DebugOutput (KERNEL.328)
141 void WINAPIV _DebugOutput( WORD flags, LPCSTR spec, VA_LIST16 valist )
143 char caller[101];
145 /* Decode caller address */
146 if (!GetModuleName16( GetExePtr(CURRENT_STACK16->cs), caller, sizeof(caller) ))
147 sprintf( caller, "%04X:%04X", CURRENT_STACK16->cs, CURRENT_STACK16->ip );
149 /* FIXME: cannot use wvsnprintf16 from kernel */
150 /* wvsnprintf16( temp, sizeof(temp), spec, valist ); */
152 /* Output */
153 FIXME("%s %04x %s\n", caller, flags, debugstr_a(spec) );