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

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

registry api fixes + version keys added

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