source: trunk/src/kernel32/initsystem.cpp@ 4474

Last change on this file since 4474 was 4474, checked in by sandervl, 25 years ago

pe loader fixes, add system32\drivers dir during installation, add build date + time during kernel32 load

File size: 26.4 KB
Line 
1/* $Id: initsystem.cpp,v 1.18 2000-10-10 17:14:04 sandervl Exp $ */
2/*
3 * Odin system initialization (registry, directories & environment)
4 *
5 * Called from the WarpIn install program to create the desktop directories and
6 * to setup the registry
7 *
8 * InitSystemAndRegistry creates:
9 * - SYSTEMDIR\drivers
10 * - WINDOWSDIR\SYSTEM
11 * - WINDOWSDIR\AppData
12 * - WINDOWSDIR\Cache
13 * - WINDOWSDIR\Cookies
14 * - WINDOWSDIR\Desktop
15 * - WINDOWSDIR\Favorites
16 * - WINDOWSDIR\Fonts
17 * - WINDOWSDIR\History
18 * - WINDOWSDIR\NetHood
19 * - WINDOWSDIR\My Documents
20 * - WINDOWSDIR\PrintHood
21 * - WINDOWSDIR\Recent
22 * - WINDOWSDIR\SendTo
23 * - WINDOWSDIR\Start Menu
24 * - WINDOWSDIR\Start Menu\Programs
25 * - WINDOWSDIR\Start Menu\Programs\Startup
26 * - WINDOWSDIR\ShellNew
27 * - x:\Program Files
28 * - x:\Program Files\Common Files
29 * - and a minimal system registry
30 *
31 * Copyright 1999-2000 Sander van Leeuwen (sandervl@xs4all.nl)
32 *
33 * Project Odin Software License can be found in LICENSE.TXT
34 */
35
36#include <os2win.h>
37#include <ctype.h>
38#include <string.h>
39#include "winreg.h"
40#include "global.h"
41#include "winnt.h"
42#include "winerror.h"
43#include "winreg.h"
44#include "debugtools.h"
45#include "cpuhlp.h"
46#include <odininst.h>
47#include "directory.h"
48#include <versionos2.h>
49
50#define DBG_LOCALLOG DBG_initsystem
51#include "dbglocal.h"
52
53#define DDRAW_CLASSID "{D7B70EE0-4340-11CF-B063-0020AFC2CD35}"
54#define DDRAW_DEFAULT "DirectDraw Object"
55#define DDRAW_CLIPPER_CLASSID "{593817A0-7DB3-11CF-A2DE-00AA00B93356}"
56#define DDRAW_CLIPPER_DEFAULT "DirectDraw Clipper Object"
57#define DDRAW_DLL "ddraw.dll"
58#define DSOUND_CLASSID "{47D4D946-62E8-11cf-93BC-444553540000}"
59#define DSOUND_DEFAULT "DirectSound Object"
60#define DSOUND_DLL "dsound.dll"
61#define CLASS_DESKTOP "Desktop"
62#define CLASS_SHORTCUT "Shortcut"
63#define CLASS_SHELL32DLL "shell32.dll"
64#define COM_CLASS_ID "CLSID"
65#define COM_INPROCSERVER "InprocServer32"
66#define COM_THREADMODEL "ThreadingModel"
67#define COM_THREAD_APARTMENT "Apartment"
68#define THREAD_BOTH "Both"
69#define INITREG_ERROR "InitRegistry: Unable to register system information"
70#define DIR_PROGRAM "ProgramFilesDir"
71#define DIR_PROGRAM_COMMON "CommonFilesDir"
72#define DIR_SHARED "SharedDir"
73#define HARDWARE_VIDEO_GRADD "\\REGISTRY\\Machine\\System\\CurrentControlSet\\Services\\Gradd\\Device0"
74#define HARDWARE_VIDEO_GRADD_DESCRIPTION "OS/2 Display driver"
75#define HARDWARE_VIDEO_VGA "\\REGISTRY\\Machine\\System\\CurrentControlSet\\Services\\VgaSave\\Device0"
76#define HARDWARE_VIDEO_VGA_DESCRIPTION "OS/2 VGA Display driver"
77#define HARDWARE_VIDEO_COMPATIBLE "\\Device\\Video1"
78#define DIRECTX_RC "0"
79#define DIRECTX_VERSION "4.04.1381.276"
80#define DIRECTX_INSTALLED_VERSION 0x0004
81#define ODIN_WINMM_PLAYBACK "OS/2 Dart Audio Playback"
82#define ODIN_WINMM_RECORD "OS/2 Dart Audio Record"
83
84#define KEY_DEVICE_TYPE "Type"
85#define KEY_DEVICE_START "Start"
86#define KEY_DEVICE_GROUP "Group"
87#define KEY_DEVICE_ERRORCONTROL "ErrorControl"
88#define KEY_DEVICE_AUTORUN "Autorun"
89#define KEY_DEVICE_TAG "Tag"
90#define DEVICE_GROUP_FILESYSTEM "File system"
91#define DEVICE_GROUP_SCSICDROM "SCSI CDROM Class"
92
93//******************************************************************************
94//******************************************************************************
95//******************************************************************************
96//[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows]
97//"Directory"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,00
98//"SystemDirectory"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,73,79,73,74,65,\
99// 6d,33,32,00
100//"ErrorMode"=dword:00000000
101//"NoInteractiveServices"=dword:00000000
102//"CSDVersion"=dword:00000300
103BYTE ShutdownTime[] = {0x44,0x5e,0xf2,0xbb,0x84,0x41,0xbf,0x01};
104//******************************************************************************
105BOOL InitSystemAndRegistry()
106{
107 HKEY hkey, hkey1;
108 char *buf;
109 DWORD val;
110 char digbuf[16];
111 char shellpath[260];
112
113 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Windows",&hkey)!=ERROR_SUCCESS) {
114 dprintf(("InitRegistry: Unable to register system information\n"));
115 return FALSE;
116 }
117 buf = InternalGetWindowsDirectoryA();
118 RegSetValueExA(hkey,"Directory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
119 buf = InternalGetSystemDirectoryA();
120 RegSetValueExA(hkey,"SystemDirectory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
121 val = 0;
122 RegSetValueExA(hkey,"ErrorMode",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
123 val = 0;
124 RegSetValueExA(hkey,"NoInteractiveServices",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
125 val = ODINNT_BUILD_NR;
126 RegSetValueExA(hkey,"CSDVersion",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
127 RegSetValueExA(hkey,"ShutdownTime",0,REG_DWORD, (LPBYTE)ShutdownTime, sizeof(ShutdownTime));
128 RegCloseKey(hkey);
129
130 //Software\Microsoft\Windows\CurrentVersion\RunOnce
131 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce",&hkey)!=ERROR_SUCCESS) {
132 dprintf(("InitRegistry: Unable to register system information (2)"));
133 return FALSE;
134 }
135 RegCloseKey(hkey);
136
137 //System\CurrentControlSet\Control\Session Manager
138 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\Control\\Session Manager",&hkey)!=ERROR_SUCCESS) {
139 dprintf(("InitRegistry: Unable to register system information (2)"));
140 return FALSE;
141 }
142 RegCloseKey(hkey);
143
144 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\iexplore.exe",&hkey)!=ERROR_SUCCESS) {
145 dprintf(("InitRegistry: Unable to register system information (2)"));
146 return FALSE;
147 }
148 strcpy(shellpath, InternalGetWindowsDirectoryA());
149 strcat(shellpath, "\\IEXPLORE.EXE");
150 RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
151 RegCloseKey(hkey);
152
153
154 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
155 dprintf(("InitRegistry: Unable to register system information (2)"));
156 return FALSE;
157 }
158 buf = InternalGetSystemDirectoryA();
159 RegSetValueExA(hkey,"SystemRoot",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
160 RegSetValueExA(hkey,"PathName",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
161 sprintf(digbuf, "%d", ODINNT_BUILD_NR);
162 RegSetValueExA(hkey,"CurrentBuildNumber",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
163 RegSetValueExA(hkey,"CurrentType",0,REG_SZ, (LPBYTE)ODINNT_OSTYPE_UNI, sizeof(ODINNT_OSTYPE_UNI));
164 RegSetValueExA(hkey,"CSDVersion",0,REG_SZ, (LPBYTE)ODINNT_CSDVERSION, sizeof(ODINNT_CSDVERSION));
165 RegSetValueExA(hkey,"SoftwareType",0,REG_SZ, (LPBYTE)ODINNT_SOFTWARE_TYPE, sizeof(ODINNT_SOFTWARE_TYPE));
166
167 sprintf(digbuf, "%d.%d", ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION);
168 RegSetValueExA(hkey,"CurrentVersion",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
169
170 val = (DWORD)time(NULL); //todo: Correct format???
171 RegSetValueExA(hkey,"InstallDate",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
172
173 RegCloseKey(hkey);
174 //todo: productid, registered org/owner, sourcepath,
175
176 //Create Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders keys
177 //"Favorites"="C:\WINDOWS\Favorites"
178 //"StartUp"="C:\WINDOWS\Start Menu\Programs\Startup"
179 //"Desktop"="C:\WINDOWS\Desktop"
180 //"Programs"="C:\WINDOWS\Start Menu\Programs"
181 //"Fonts"="C:\WINDOWS\Fonts"
182 //"SendTo"="C:\WINDOWS\SendTo"
183 //"Start Menu"="C:\WINDOWS\Start Menu"
184 //"Templates"="C:\WINDOWS\ShellNew"
185 //"Recent"="C:\WINDOWS\Recent"
186 //"NetHood"="C:\WINDOWS\NetHood"
187 //"Personal"="C:\My Documents"
188
189 if(RegCreateKeyA(HKEY_CURRENT_USER,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",&hkey)!=ERROR_SUCCESS) {
190 dprintf(("InitRegistry: Unable to register system information (3)"));
191 return FALSE;
192 }
193// if(RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey) != ERROR_SUCCESS)
194// {
195 //system32\drivers dir
196 strcpy(shellpath, InternalGetSystemDirectoryA());
197 strcat(shellpath, "\\Drivers");
198 CreateDirectoryA(shellpath, NULL);
199
200 //SYSTEM dir
201 strcpy(shellpath, InternalGetWindowsDirectoryA());
202 strcat(shellpath, "\\SYSTEM");
203 CreateDirectoryA(shellpath, NULL);
204
205 //AppData
206 strcpy(shellpath, InternalGetWindowsDirectoryA());
207 strcat(shellpath, "\\Application Data");
208 CreateDirectoryA(shellpath, NULL);
209 RegSetValueExA(hkey,"AppData",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
210 //Cache
211 strcpy(shellpath, InternalGetWindowsDirectoryA());
212 strcat(shellpath, "\\Temporary Internet Files");
213 CreateDirectoryA(shellpath, NULL);
214 RegSetValueExA(hkey,"Cache",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
215 //Cookies
216 strcpy(shellpath, InternalGetWindowsDirectoryA());
217 strcat(shellpath, "\\Cookies");
218 CreateDirectoryA(shellpath, NULL);
219 RegSetValueExA(hkey,"Cookies",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
220 //Desktop
221 strcpy(shellpath, InternalGetWindowsDirectoryA());
222 strcat(shellpath, "\\Desktop");
223 CreateDirectoryA(shellpath, NULL);
224 RegSetValueExA(hkey,"Desktop",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
225 //Favorites
226 strcpy(shellpath, InternalGetWindowsDirectoryA());
227 strcat(shellpath, "\\Favorites");
228 CreateDirectoryA(shellpath, NULL);
229 RegSetValueExA(hkey,"Favorites",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
230 //Fonts
231 strcpy(shellpath, InternalGetWindowsDirectoryA());
232 strcat(shellpath, "\\Fonts");
233 CreateDirectoryA(shellpath, NULL);
234 RegSetValueExA(hkey,"Fonts",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
235 //History
236 strcpy(shellpath, InternalGetWindowsDirectoryA());
237 strcat(shellpath, "\\History");
238 CreateDirectoryA(shellpath, NULL);
239 RegSetValueExA(hkey,"History",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
240 //NetHood
241 strcpy(shellpath, InternalGetWindowsDirectoryA());
242 strcat(shellpath, "\\NetHood");
243 CreateDirectoryA(shellpath, NULL);
244 RegSetValueExA(hkey,"NetHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
245 //Personal
246 strcpy(shellpath, InternalGetWindowsDirectoryA());
247 strcat(shellpath, "\\My Documents");
248 CreateDirectoryA(shellpath, NULL);
249 RegSetValueExA(hkey,"Personal",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
250 //PrintHood
251 strcpy(shellpath, InternalGetWindowsDirectoryA());
252 strcat(shellpath, "\\PrintHood");
253 CreateDirectoryA(shellpath, NULL);
254 RegSetValueExA(hkey,"PrintHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
255 //Recent
256 strcpy(shellpath, InternalGetWindowsDirectoryA());
257 strcat(shellpath, "\\Recent");
258 CreateDirectoryA(shellpath, NULL);
259 RegSetValueExA(hkey,"Recent",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
260 //SendTo
261 strcpy(shellpath, InternalGetWindowsDirectoryA());
262 strcat(shellpath, "\\SendTo");
263 CreateDirectoryA(shellpath, NULL);
264 RegSetValueExA(hkey,"SendTo",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
265 //Start Menu
266 strcpy(shellpath, InternalGetWindowsDirectoryA());
267 strcat(shellpath, "\\Start Menu");
268 CreateDirectoryA(shellpath, NULL);
269 RegSetValueExA(hkey,"Start Menu",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
270 //Programs
271 strcpy(shellpath, InternalGetWindowsDirectoryA());
272 strcat(shellpath, "\\Start Menu\\Programs");
273 CreateDirectoryA(shellpath, NULL);
274 RegSetValueExA(hkey,"Programs",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
275 //Startup
276 strcat(shellpath, "\\Startup");
277 CreateDirectoryA(shellpath, NULL);
278 RegSetValueExA(hkey,"Startup",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
279 //ShellNew
280 strcpy(shellpath, InternalGetWindowsDirectoryA());
281 strcat(shellpath, "\\ShellNew");
282 CreateDirectoryA(shellpath, NULL);
283 RegSetValueExA(hkey,"Templates",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
284// }
285 RegCloseKey(hkey);
286
287 //Shell32 & IE related keys
288 //[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00021400-0000-0000-C000-000000000046}]
289 //@="Desktop"
290 //[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00021400-0000-0000-C000-000000000046}\InProcServer32]
291 //@="shell32.dll"
292 //ThreadingModel="Apartment"
293 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021400-0000-0000-C000-000000000046}",&hkey)!=ERROR_SUCCESS) {
294 goto initreg_error;
295 }
296 RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)CLASS_DESKTOP, sizeof(CLASS_DESKTOP));
297 RegCloseKey(hkey);
298 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021400-0000-0000-C000-000000000046}\\InProcServer32",&hkey)!=ERROR_SUCCESS) {
299 goto initreg_error;
300 }
301 RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)CLASS_SHELL32DLL, sizeof(CLASS_SHELL32DLL));
302 RegSetValueExA(hkey, COM_THREADMODEL, 0, REG_SZ, (LPBYTE)COM_THREAD_APARTMENT, sizeof(COM_THREAD_APARTMENT));
303 RegCloseKey(hkey);
304 //[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00021401-0000-0000-C000-000000000046}]
305 //@="Shortcut"
306 //[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00021401-0000-0000-C000-000000000046}\InProcServer32]
307 //@="shell32.dll"
308 //"ThreadingModel"="Apartment"
309 //[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00021401-0000-0000-C000-000000000046}\shellex\MayChangeDefaultMenu]
310 //@=""
311 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021401-0000-0000-C000-000000000046}",&hkey)!=ERROR_SUCCESS) {
312 goto initreg_error;
313 }
314 RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)CLASS_SHORTCUT, sizeof(CLASS_SHORTCUT));
315 RegCloseKey(hkey);
316 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021401-0000-0000-C000-000000000046}\\InProcServer32",&hkey)!=ERROR_SUCCESS) {
317 goto initreg_error;
318 }
319 RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)CLASS_SHELL32DLL, sizeof(CLASS_SHELL32DLL));
320 RegSetValueExA(hkey, COM_THREADMODEL, 0, REG_SZ, (LPBYTE)COM_THREAD_APARTMENT, sizeof(COM_THREAD_APARTMENT));
321 RegCloseKey(hkey);
322 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021401-0000-0000-C000-000000000046}\\shellex\\MayChangeDefaultMenu",&hkey)!=ERROR_SUCCESS) {
323 goto initreg_error;
324 }
325 RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)"", 0);
326 RegCloseKey(hkey);
327
328 //Now the Ddraw & dsound registry keys:
329 //HKEY_CLASSES_ROOT\DirectDraw = DirectDraw Object
330 //HKEY_CLASSES_ROOT\DirectDraw\CLSID = {D7B70EE0-4340-11CF-B063-0020AFC2CD35}
331 //HKEY_CLASSES_ROOT\CLSID\{D7B70EE0-4340-11CF-B063-0020AFC2CD35} = DirectDraw Object
332 //HKEY_CLASSES_ROOT\CLSID\{D7B70EE0-4340-11CF-B063-0020AFC2CD35}\InprocServer32 = ddraw.dll
333 if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectDraw",&hkey)!=ERROR_SUCCESS) {
334 goto initreg_error;
335 }
336 RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)DDRAW_DEFAULT, sizeof(DDRAW_DEFAULT));
337 if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
338 RegCloseKey(hkey);
339 goto initreg_error;
340 }
341 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_CLASSID, sizeof(DDRAW_CLASSID));
342 RegCloseKey(hkey1);
343 RegCloseKey(hkey);
344
345 if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DDRAW_CLASSID ,&hkey)!=ERROR_SUCCESS) {
346 goto initreg_error;
347 }
348 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_DEFAULT, sizeof(DDRAW_DEFAULT));
349 if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
350 RegCloseKey(hkey);
351 goto initreg_error;
352 }
353 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_DLL, sizeof(DDRAW_DLL));
354 RegSetValueExA(hkey1, COM_THREADMODEL, 0,REG_SZ, (LPBYTE)THREAD_BOTH, sizeof(THREAD_BOTH));
355 RegCloseKey(hkey1);
356 RegCloseKey(hkey);
357
358 //HKEY_CLASSES_ROOT\DirectDrawClipper = DirectDraw Clipper Object
359 //HKEY_CLASSES_ROOT\DirectDrawClipper\CLSID = {593817A0-7DB3-11CF-A2DE-00AA00B93356}
360 //HKEY_CLASSES_ROOT\CLSID\{593817A0-7DB3-11CF-A2DE-00AA00B93356} = DirectDraw Clipper Object
361 //HKEY_CLASSES_ROOT\CLSID\{593817A0-7DB3-11CF-A2DE-00AA00B93356}\InprocServer32 = ddraw.dll
362 if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectDrawClipper",&hkey)!=ERROR_SUCCESS) {
363 goto initreg_error;
364 }
365 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_DEFAULT, sizeof(DDRAW_CLIPPER_DEFAULT));
366 if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
367 RegCloseKey(hkey);
368 goto initreg_error;
369 }
370 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_CLASSID, sizeof(DDRAW_CLIPPER_CLASSID));
371 RegCloseKey(hkey1);
372 RegCloseKey(hkey);
373
374 if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DDRAW_CLIPPER_CLASSID,&hkey)!=ERROR_SUCCESS) {
375 goto initreg_error;
376 }
377 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_DEFAULT, sizeof(DDRAW_CLIPPER_DEFAULT));
378 if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
379 RegCloseKey(hkey);
380 goto initreg_error;
381 }
382 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_DLL, sizeof(DDRAW_DLL));
383 RegSetValueExA(hkey1, COM_THREADMODEL, 0,REG_SZ, (LPBYTE)THREAD_BOTH, sizeof(THREAD_BOTH));
384 RegCloseKey(hkey1);
385 RegCloseKey(hkey);
386
387 //HKEY_CLASSES_ROOT\DirectSound = DirectSound Object
388 //HKEY_CLASSES_ROOT\DirectSound\CLSID = {47D4D946-62E8-11cf-93BC-444553540000}
389 //HKEY_CLASSES_ROOT\CLSID\{47D4D946-62E8-11cf-93BC-444553540000} = DirectSound Object
390 //HKEY_CLASSES_ROOT\CLSID\{47D4D946-62E8-11cf-93BC-444553540000}\InprocServer32 = dsound.dll
391 if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectSound",&hkey)!=ERROR_SUCCESS) {
392 goto initreg_error;
393 }
394 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DSOUND_DEFAULT, sizeof(DSOUND_DEFAULT));
395 if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
396 RegCloseKey(hkey);
397 goto initreg_error;
398 }
399 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DSOUND_CLASSID, sizeof(DSOUND_CLASSID));
400 RegCloseKey(hkey1);
401 RegCloseKey(hkey);
402
403 if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DSOUND_CLASSID ,&hkey)!=ERROR_SUCCESS) {
404 goto initreg_error;
405 }
406 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DSOUND_DEFAULT, sizeof(DSOUND_DEFAULT));
407 if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
408 RegCloseKey(hkey);
409 goto initreg_error;
410 }
411 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DSOUND_DLL, sizeof(DSOUND_DLL));
412 RegSetValueExA(hkey1, COM_THREADMODEL, 0,REG_SZ, (LPBYTE)THREAD_BOTH, sizeof(THREAD_BOTH));
413 RegCloseKey(hkey1);
414 RegCloseKey(hkey);
415
416 //[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
417 //"ProgramFilesDir"="C:\Program Files"
418 //"CommonFilesDir"="C:\Program Files\Common Files"
419 //# This is intended for a centrally managed (server) directory where system files and e.g. fonts can reside. Most installs have this set to C:\WINDOWS, though.
420 //"SharedDir"="C:\WINDOWS"
421 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
422 goto initreg_error;
423 }
424 //Create x:\Program Files directory
425 strcpy(shellpath, InternalGetWindowsDirectoryA());
426 shellpath[2] = 0; //get drive
427 strcat(shellpath, "\\Program Files");
428 CreateDirectoryA(shellpath, NULL);
429 RegSetValueExA(hkey, DIR_PROGRAM, 0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
430
431 //Create x:\Program Files\Common Files directory
432 strcat(shellpath, "\\Common Files");
433 CreateDirectoryA(shellpath, NULL);
434 RegSetValueExA(hkey, DIR_PROGRAM_COMMON, 0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
435
436 strcpy(shellpath, InternalGetWindowsDirectoryA());
437 RegSetValueExA(hkey, DIR_SHARED, 0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
438
439 RegCloseKey(hkey);
440
441 //[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\VIDEO]
442 //"\\Device\\Video0"="\\REGISTRY\\Machine\\System\\ControlSet001\\Services\\mga64\\Device0"
443 //"\\Device\\Video1"="\\REGISTRY\\Machine\\System\\ControlSet001\\Services\\VgaSave\\Device0"
444 //"VgaCompatible"="\\Device\\Video1"
445 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\VIDEO",&hkey)!=ERROR_SUCCESS) {
446 goto initreg_error;
447 }
448 RegSetValueExA(hkey,"\\Device\\Video0",0,REG_SZ, (LPBYTE)HARDWARE_VIDEO_GRADD, sizeof(HARDWARE_VIDEO_GRADD));
449 RegSetValueExA(hkey,"\\Device\\Video1",0,REG_SZ, (LPBYTE)HARDWARE_VIDEO_VGA, sizeof(HARDWARE_VIDEO_VGA));
450 RegSetValueExA(hkey, "VgaCompatible", 0,REG_SZ, (LPBYTE)HARDWARE_VIDEO_COMPATIBLE, sizeof(HARDWARE_VIDEO_COMPATIBLE));
451 RegCloseKey(hkey);
452
453 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\Gradd\\Device0",&hkey)!=ERROR_SUCCESS) {
454 goto initreg_error;
455 }
456 RegSetValueExA(hkey,"Device Description", 0, REG_SZ, (LPBYTE)HARDWARE_VIDEO_GRADD_DESCRIPTION, sizeof(HARDWARE_VIDEO_GRADD_DESCRIPTION));
457 RegCloseKey(hkey);
458
459 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\VgaSave\\Device0",&hkey)!=ERROR_SUCCESS) {
460 goto initreg_error;
461 }
462 RegSetValueExA(hkey,"Device Description", 0, REG_SZ, (LPBYTE)HARDWARE_VIDEO_VGA_DESCRIPTION, sizeof(HARDWARE_VIDEO_VGA_DESCRIPTION));
463 RegCloseKey(hkey);
464
465 //Software\Microsoft\Multimedia\Sound Mapper
466 if(RegCreateKeyA(HKEY_CURRENT_USER,"Software\\Microsoft\\Multimedia\\Sound Mapper",&hkey)!=ERROR_SUCCESS) {
467 goto initreg_error;
468 }
469 RegSetValueExA(hkey,"Playback", 0, REG_SZ, (LPBYTE)ODIN_WINMM_PLAYBACK, sizeof(ODIN_WINMM_PLAYBACK));
470 RegSetValueExA(hkey,"Record", 0, REG_SZ, (LPBYTE)ODIN_WINMM_RECORD, sizeof(ODIN_WINMM_RECORD));
471 RegCloseKey(hkey);
472
473 //Software\Microsoft\DirectX
474 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectX",&hkey)!=ERROR_SUCCESS) {
475 goto initreg_error;
476 }
477 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)"", 0);
478 RegSetValueExA(hkey, "RC", 0,REG_SZ, (LPBYTE)DIRECTX_RC, sizeof(DIRECTX_RC));
479 RegSetValueExA(hkey, "Version", 0,REG_SZ, (LPBYTE)DIRECTX_VERSION, sizeof(DIRECTX_VERSION));
480 val = DIRECTX_INSTALLED_VERSION;
481 RegSetValueExA(hkey, "InstalledVersion", 0,REG_BINARY, (LPBYTE)&val, sizeof(DWORD));
482 RegCloseKey(hkey);
483
484 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectDraw",&hkey)!=ERROR_SUCCESS) {
485 goto initreg_error;
486 }
487 //todo
488 RegCloseKey(hkey);
489
490 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Direct3D",&hkey)!=ERROR_SUCCESS) {
491 goto initreg_error;
492 }
493 //todo
494 RegCloseKey(hkey);
495
496 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectPlay",&hkey)!=ERROR_SUCCESS) {
497 goto initreg_error;
498 }
499 //todo
500 RegCloseKey(hkey);
501
502#if 0
503 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectMusic",&hkey)!=ERROR_SUCCESS) {
504 goto initreg_error;
505 }
506 //todo
507 RegCloseKey(hkey);
508#endif
509
510// [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cdfs]
511// "Type"=dword:00000002
512// "Start"=dword:00000004
513// "Group"="File system"
514// "ErrorControl"=dword:00000001
515// "DependOnGroup"=hex(7):53,43,53,49,20,43,44,52,4f,4d,20,43,6c,61,73,73,00,00
516
517 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\Cdfs",&hkey)!=ERROR_SUCCESS) {
518 goto initreg_error;
519 }
520 val = 0x2;
521 RegSetValueExA(hkey, KEY_DEVICE_TYPE,0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
522 val = 0x4;
523 RegSetValueExA(hkey, KEY_DEVICE_START,0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
524 val = 0x1;
525 RegSetValueExA(hkey, KEY_DEVICE_ERRORCONTROL,0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
526 RegSetValueExA(hkey, KEY_DEVICE_GROUP,0,REG_SZ, (LPBYTE)DEVICE_GROUP_FILESYSTEM, sizeof(DEVICE_GROUP_FILESYSTEM));
527 //todo dependongroup
528 RegCloseKey(hkey);
529
530
531/*
532// [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cdfs\Enum]
533// "0"="Root\\LEGACY_CDFS\\0000"
534// "Count"=dword:00000001
535// "NextInstance"=dword:00000001
536*/
537// [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cdrom]
538// "Type"=dword:00000001
539// "Start"=dword:00000001
540// "Group"="SCSI CDROM Class"
541// "ErrorControl"=dword:00000000
542// "Tag"=dword:00000002
543// "DependOnGroup"=hex(7):53,43,53,49,20,6d,69,6e,69,70,6f,72,74,00,00
544// "Autorun"=dword:00000001
545
546 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\Cdrom",&hkey)!=ERROR_SUCCESS) {
547 goto initreg_error;
548 }
549 val = 0x1;
550 RegSetValueExA(hkey, KEY_DEVICE_TYPE,0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
551 val = 0x1;
552 RegSetValueExA(hkey, KEY_DEVICE_START,0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
553 val = 0x0;
554 RegSetValueExA(hkey, KEY_DEVICE_ERRORCONTROL,0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
555 val = 0x2;
556 RegSetValueExA(hkey, KEY_DEVICE_TAG,0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
557 val = 0x0;
558 RegSetValueExA(hkey, KEY_DEVICE_AUTORUN,0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
559 RegSetValueExA(hkey, KEY_DEVICE_GROUP,0,REG_SZ, (LPBYTE)DEVICE_GROUP_SCSICDROM, sizeof(DEVICE_GROUP_SCSICDROM));
560 //todo dependongroup
561 RegCloseKey(hkey);
562
563/*
564[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cdrom\Enum]
565"0"="Root\\LEGACY_CDROM\\0000"
566"Count"=dword:00000001
567"NextInstance"=dword:00000001
568*/
569
570 return TRUE;
571
572initreg_error:
573 dprintf((INITREG_ERROR));
574 return FALSE;
575}
576//******************************************************************************
577//Environment variables created by Windows NT:
578//
579//COMPUTERNAME=NTBAK
580//ComSpec=E:\WINNT\system32\cmd.exe
581//CPU=i386
582//HOMEDRIVE=E:
583//HOMEPATH=\
584//LOGONSERVER=\\NTBAK
585//NUMBER_OF_PROCESSORS=2
586//OS=Windows_NT
587//PATHEXT=.COM;.EXE;.BAT;.CMD
588//PROCESSOR_ARCHITECTURE=x86
589//PROCESSOR_IDENTIFIER=x86 Family 6 Model 6 Stepping 5, GenuineIntel
590//PROCESSOR_LEVEL=6
591//PROCESSOR_REVISION=0605
592//SystemDrive=E:
593//SystemRoot=E:\WINNT
594//USERDOMAIN=NTBAK
595//USERNAME=Sander
596//USERPROFILE=E:\WINNT\Profiles\Sander
597//windir=E:\WINNT
598//******************************************************************************
599void InitEnvironment(int nrcpus)
600{
601 char buffer[64];
602 char buffer1[32];
603 char *windir;
604 DWORD signature;
605
606 SetEnvironmentVariableA("CPU", "i386");
607 SetEnvironmentVariableA("PROCESSOR_ARCHITECTURE", "x86");
608 if(SupportsCPUID()) {
609 GetCPUVendorString(buffer1);
610 buffer1[12] = 0;
611 signature = GetCPUSignature();
612 sprintf(buffer, "x86 Family %x Model %x Stepping %x, %s", (signature >> 8)&0xf, signature & 0xf, (signature >> 4)&0xf, buffer1);
613 SetEnvironmentVariableA("PROCESSOR_IDENTIFIER", buffer);
614 sprintf(buffer, "%x", (signature >> 8)&0xf);
615 SetEnvironmentVariableA("PROCESSOR_LEVEL", buffer);
616 sprintf(buffer, "%02x%02x", (signature >> 4)&0xf, signature & 0xf);
617 SetEnvironmentVariableA("PROCESSOR_REVISION", buffer);
618 }
619 sprintf(buffer, "%d", nrcpus);
620 SetEnvironmentVariableA("NUMBER_OF_PROCESSORS", buffer);
621 SetEnvironmentVariableA("OS", "Windows_NT");
622 SetEnvironmentVariableA("PATHEXT", ".COM;.EXE;.BAT;.CMD");
623 windir = InternalGetWindowsDirectoryA();
624 SetEnvironmentVariableA("windir", windir);
625 SetEnvironmentVariableA("SystemRoot", windir);
626 buffer[0] = windir[0];
627 buffer[1] = windir[1];
628 buffer[2] = 0;
629 SetEnvironmentVariableA("SystemDrive", buffer);
630 SetEnvironmentVariableA("HOMEDRIVE", buffer);
631 SetEnvironmentVariableA("HOMEPATH", "\\");
632
633//TODO:
634//COMPUTERNAME=NTBAK
635//ComSpec=E:\WINNT\system32\cmd.exe
636//LOGONSERVER=\\NTBAK
637//USERDOMAIN=NTBAK
638//USERNAME=Sander
639//USERPROFILE=E:\WINNT\Profiles\Sander
640}
Note: See TracBrowser for help on using the repository browser.