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

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

create system32\drivers\etc during install

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