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

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

misc updates + fixes

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