2 * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include "wine/winbase16.h"
34 #include "wine/library.h"
41 extern void CODEPAGE_Init(void);
42 extern BOOL
RELAY_Init(void);
44 extern int __wine_set_signal_handler(unsigned, int (*)(unsigned));
45 extern int CONSOLE_HandleCtrlC(unsigned);
47 extern int main_create_flags
;
49 /***********************************************************************
50 * KERNEL process initialisation routine
52 static BOOL
process_attach(void)
57 FILE_umask
= umask(0777);
60 /* Setup codepage info */
63 /* Initialize relay entry points */
64 if (!RELAY_Init()) return FALSE
;
66 /* Initialize DOS memory */
67 if (!DOSMEM_Init(0)) return FALSE
;
69 if ((hModule
= LoadLibrary16( "krnl386.exe" )) < 32) return FALSE
;
71 /* Initialize special KERNEL entry points */
73 /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
74 NE_SetEntryPoint( hModule
, 178, GetWinFlags16() );
76 /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
77 NE_SetEntryPoint( hModule
, 454, wine_get_cs() );
78 NE_SetEntryPoint( hModule
, 455, wine_get_ds() );
80 /* Initialize KERNEL.THHOOK */
81 TASK_InstallTHHook(MapSL((SEGPTR
)GetProcAddress16( hModule
, (LPCSTR
)332 )));
83 /* Initialize the real-mode selector entry points */
84 #define SET_ENTRY_POINT( num, addr ) \
85 NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
86 DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
87 WINE_LDT_FLAGS_DATA ))
89 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
90 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
91 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
92 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
93 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
94 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
95 NE_SetEntryPoint( hModule
, 183, DOSMEM_0000H
); /* KERNEL.183: __0000H */
96 NE_SetEntryPoint( hModule
, 173, DOSMEM_BiosSysSeg
); /* KERNEL.173: __ROMBIOS */
97 NE_SetEntryPoint( hModule
, 193, DOSMEM_BiosDataSeg
); /* KERNEL.193: __0040H */
98 NE_SetEntryPoint( hModule
, 194, DOSMEM_BiosSysSeg
); /* KERNEL.194: __F000H */
99 #undef SET_ENTRY_POINT
101 /* Force loading of some dlls */
102 if (LoadLibrary16( "system" ) < 32) return FALSE
;
104 /* Create 16-bit task */
105 TASK_CreateMainTask();
107 /* Create the shared heap for broken win95 native dlls */
108 HeapCreate( HEAP_SHARED
, 0, 0 );
110 /* finish the process initialisation, if needed */
111 __wine_set_signal_handler(SIGINT
, CONSOLE_HandleCtrlC
);
113 if (main_create_flags
& CREATE_NEW_CONSOLE
)
115 HMODULE mod
= GetModuleHandleA(0);
116 if (RtlImageNtHeader(mod
)->OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_CUI
)
123 /***********************************************************************
124 * KERNEL initialisation routine
126 BOOL WINAPI
MAIN_KernelInit( HINSTANCE hinst
, DWORD reason
, LPVOID reserved
)
130 case DLL_PROCESS_ATTACH
:
131 return process_attach();
132 case DLL_PROCESS_DETACH
:
133 WriteOutProfiles16();
139 /***********************************************************************
140 * EnableDos (KERNEL.41)
141 * DisableDos (KERNEL.42)
142 * GetLastDiskChange (KERNEL.98)
143 * ValidateCodeSegments (KERNEL.100)
144 * KbdRst (KERNEL.123)
145 * EnableKernel (KERNEL.124)
146 * DisableKernel (KERNEL.125)
147 * ValidateFreeSpaces (KERNEL.200)
149 * BUNNY_351 (KERNEL.351)
150 * PIGLET_361 (KERNEL.361)
152 * Entry point for kernel functions that do nothing.
154 LONG WINAPI
KERNEL_nop(void)