wined3d: Do not change the texture unit when binding surfaces.
[wine/multimedia.git] / dlls / kernel32 / kernel16.c
blob50b11a057dc06ca665e125e00b9b9135530825ed
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>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winternl.h"
26 #include "wownt32.h"
28 #include "toolhelp.h"
29 #include "kernel_private.h"
30 #include "kernel16_private.h"
32 /**************************************************************************
33 * DllEntryPoint (KERNEL.669)
35 BOOL WINAPI KERNEL_DllEntryPoint( DWORD reasion, HINSTANCE16 inst, WORD ds,
36 WORD heap, DWORD reserved1, WORD reserved2 )
38 static int done;
40 /* the entry point can be called multiple times */
41 if (done) return TRUE;
42 done = 1;
44 /* Initialize 16-bit thunking entry points */
45 if (!WOWTHUNK_Init()) return FALSE;
47 /* Initialize DOS memory */
48 if (!DOSMEM_Init()) return FALSE;
50 /* Initialize special KERNEL entry points */
52 NE_SetEntryPoint( inst, 178, GetWinFlags16() );
54 NE_SetEntryPoint( inst, 454, wine_get_cs() );
55 NE_SetEntryPoint( inst, 455, wine_get_ds() );
57 NE_SetEntryPoint( inst, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
58 NE_SetEntryPoint( inst, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
59 NE_SetEntryPoint( inst, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
60 NE_SetEntryPoint( inst, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
62 /* Initialize KERNEL.THHOOK */
63 TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( inst, (LPCSTR)332 )));
65 /* Initialize the real-mode selector entry points */
66 #define SET_ENTRY_POINT( num, addr ) \
67 NE_SetEntryPoint( inst, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
68 DOSMEM_MapDosToLinear(addr), 0x10000, inst, \
69 WINE_LDT_FLAGS_DATA ))
71 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
72 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
73 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
74 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
75 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
76 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
77 #undef SET_ENTRY_POINT
79 /* Force loading of some dlls */
80 LoadLibrary16( "system.drv" );
82 return TRUE;
85 /***********************************************************************
86 * EnableDos (KERNEL.41)
87 * DisableDos (KERNEL.42)
88 * GetLastDiskChange (KERNEL.98)
89 * ValidateCodeSegments (KERNEL.100)
90 * KbdRst (KERNEL.123)
91 * EnableKernel (KERNEL.124)
92 * DisableKernel (KERNEL.125)
93 * ValidateFreeSpaces (KERNEL.200)
94 * K237 (KERNEL.237)
95 * BUNNY_351 (KERNEL.351)
96 * PIGLET_361 (KERNEL.361)
98 * Entry point for kernel functions that do nothing.
100 LONG WINAPI KERNEL_nop(void)
102 return 0;
106 /* thunk for 16-bit CreateThread */
107 struct thread_args
109 FARPROC16 proc;
110 DWORD param;
113 static DWORD CALLBACK start_thread16( LPVOID threadArgs )
115 struct thread_args args = *(struct thread_args *)threadArgs;
116 HeapFree( GetProcessHeap(), 0, threadArgs );
117 return K32WOWCallback16( (DWORD)args.proc, args.param );
120 /***********************************************************************
121 * CreateThread16 (KERNEL.441)
123 HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
124 FARPROC16 start, SEGPTR param,
125 DWORD flags, LPDWORD id )
127 struct thread_args *args = HeapAlloc( GetProcessHeap(), 0, sizeof(*args) );
128 if (!args) return INVALID_HANDLE_VALUE;
129 args->proc = start;
130 args->param = param;
131 return CreateThread( sa, stack, start_thread16, args, flags, id );