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

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

add more keys for directx during install

File size: 20.3 KB
Line 
1/* $Id: initsystem.cpp,v 1.13 2000-08-25 09:02:54 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 COM_CLASS_ID "CLSID"
61#define COM_INPROCSERVER "InprocServer32"
62#define COM_THREADMODEL "ThreadingModel"
63#define THREAD_BOTH "Both"
64#define INITREG_ERROR "InitRegistry: Unable to register system information"
65#define DIR_PROGRAM "ProgramFilesDir"
66#define DIR_PROGRAM_COMMON "CommonFilesDir"
67#define DIR_SHARED "SharedDir"
68#define HARDWARE_VIDEO_GRADD "\\REGISTRY\\Machine\\System\\CurrentControlSet\\Services\\Gradd\\Device0"
69#define HARDWARE_VIDEO_GRADD_DESCRIPTION "OS/2 Display driver"
70#define HARDWARE_VIDEO_VGA "\\REGISTRY\\Machine\\System\\CurrentControlSet\\Services\\VgaSave\\Device0"
71#define HARDWARE_VIDEO_VGA_DESCRIPTION "OS/2 VGA Display driver"
72#define HARDWARE_VIDEO_COMPATIBLE "\\Device\\Video1"
73#define DIRECTX_RC "0"
74#define DIRECTX_VERSION "4.04.1381.276"
75#define DIRECTX_INSTALLED_VERSION 0x0004
76#define ODIN_WINMM_PLAYBACK "OS/2 Dart Audio Playback"
77#define ODIN_WINMM_RECORD "OS/2 Dart Audio Record"
78
79//******************************************************************************
80//******************************************************************************
81//******************************************************************************
82//[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows]
83//"Directory"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,00
84//"SystemDirectory"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,73,79,73,74,65,\
85// 6d,33,32,00
86//"ErrorMode"=dword:00000000
87//"NoInteractiveServices"=dword:00000000
88//"CSDVersion"=dword:00000300
89BYTE ShutdownTime[] = {0x44,0x5e,0xf2,0xbb,0x84,0x41,0xbf,0x01};
90//******************************************************************************
91BOOL InitSystemAndRegistry()
92{
93 HKEY hkey, hkey1;
94 char *buf;
95 DWORD val;
96 char digbuf[16];
97
98 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Windows",&hkey)!=ERROR_SUCCESS) {
99 dprintf(("InitRegistry: Unable to register system information\n"));
100 return FALSE;
101 }
102 buf = InternalGetWindowsDirectoryA();
103 RegSetValueExA(hkey,"Directory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
104 buf = InternalGetSystemDirectoryA();
105 RegSetValueExA(hkey,"SystemDirectory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
106 val = 0;
107 RegSetValueExA(hkey,"ErrorMode",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
108 val = 0;
109 RegSetValueExA(hkey,"NoInteractiveServices",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
110 val = ODINNT_BUILD_NR;
111 RegSetValueExA(hkey,"CSDVersion",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
112 RegSetValueExA(hkey,"ShutdownTime",0,REG_DWORD, (LPBYTE)ShutdownTime, sizeof(ShutdownTime));
113 RegCloseKey(hkey);
114
115 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
116 dprintf(("InitRegistry: Unable to register system information (2)"));
117 return FALSE;
118 }
119 buf = InternalGetSystemDirectoryA();
120 RegSetValueExA(hkey,"SystemRoot",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
121 RegSetValueExA(hkey,"PathName",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
122 sprintf(digbuf, "%d", ODINNT_BUILD_NR);
123 RegSetValueExA(hkey,"CurrentBuildNumber",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
124 RegSetValueExA(hkey,"CurrentType",0,REG_SZ, (LPBYTE)ODINNT_OSTYPE_UNI, sizeof(ODINNT_OSTYPE_UNI));
125 RegSetValueExA(hkey,"CSDVersion",0,REG_SZ, (LPBYTE)ODINNT_CSDVERSION, sizeof(ODINNT_CSDVERSION));
126 RegSetValueExA(hkey,"SoftwareType",0,REG_SZ, (LPBYTE)ODINNT_SOFTWARE_TYPE, sizeof(ODINNT_SOFTWARE_TYPE));
127
128 sprintf(digbuf, "%d.%d", ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION);
129 RegSetValueExA(hkey,"CurrentVersion",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
130
131 val = (DWORD)time(NULL); //todo: Correct format???
132 RegSetValueExA(hkey,"InstallDate",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
133
134 RegCloseKey(hkey);
135 //todo: productid, registered org/owner, sourcepath,
136
137 //Create Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders keys
138 //"Favorites"="C:\WINDOWS\Favorites"
139 //"StartUp"="C:\WINDOWS\Start Menu\Programs\Startup"
140 //"Desktop"="C:\WINDOWS\Desktop"
141 //"Programs"="C:\WINDOWS\Start Menu\Programs"
142 //"Fonts"="C:\WINDOWS\Fonts"
143 //"SendTo"="C:\WINDOWS\SendTo"
144 //"Start Menu"="C:\WINDOWS\Start Menu"
145 //"Templates"="C:\WINDOWS\ShellNew"
146 //"Recent"="C:\WINDOWS\Recent"
147 //"NetHood"="C:\WINDOWS\NetHood"
148 //"Personal"="C:\My Documents"
149
150 char shellpath[260];
151
152 if(RegCreateKeyA(HKEY_CURRENT_USER,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",&hkey)!=ERROR_SUCCESS) {
153 dprintf(("InitRegistry: Unable to register system information (3)"));
154 return FALSE;
155 }
156// if(RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey) != ERROR_SUCCESS)
157// {
158 //SYSTEM dir
159 strcpy(shellpath, InternalGetWindowsDirectoryA());
160 strcat(shellpath, "\\SYSTEM");
161 CreateDirectoryA(shellpath, NULL);
162
163 //AppData
164 strcpy(shellpath, InternalGetWindowsDirectoryA());
165 strcat(shellpath, "\\Application Data");
166 CreateDirectoryA(shellpath, NULL);
167 RegSetValueExA(hkey,"AppData",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
168 //Cache
169 strcpy(shellpath, InternalGetWindowsDirectoryA());
170 strcat(shellpath, "\\Temporary Internet Files");
171 CreateDirectoryA(shellpath, NULL);
172 RegSetValueExA(hkey,"Cache",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
173 //Cookies
174 strcpy(shellpath, InternalGetWindowsDirectoryA());
175 strcat(shellpath, "\\Cookies");
176 CreateDirectoryA(shellpath, NULL);
177 RegSetValueExA(hkey,"Cookies",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
178 //Desktop
179 strcpy(shellpath, InternalGetWindowsDirectoryA());
180 strcat(shellpath, "\\Desktop");
181 CreateDirectoryA(shellpath, NULL);
182 RegSetValueExA(hkey,"Desktop",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
183 //Favorites
184 strcpy(shellpath, InternalGetWindowsDirectoryA());
185 strcat(shellpath, "\\Favorites");
186 CreateDirectoryA(shellpath, NULL);
187 RegSetValueExA(hkey,"Favorites",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
188 //Fonts
189 strcpy(shellpath, InternalGetWindowsDirectoryA());
190 strcat(shellpath, "\\Fonts");
191 CreateDirectoryA(shellpath, NULL);
192 RegSetValueExA(hkey,"Fonts",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
193 //History
194 strcpy(shellpath, InternalGetWindowsDirectoryA());
195 strcat(shellpath, "\\History");
196 CreateDirectoryA(shellpath, NULL);
197 RegSetValueExA(hkey,"History",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
198 //NetHood
199 strcpy(shellpath, InternalGetWindowsDirectoryA());
200 strcat(shellpath, "\\NetHood");
201 CreateDirectoryA(shellpath, NULL);
202 RegSetValueExA(hkey,"NetHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
203 //Personal
204 strcpy(shellpath, InternalGetWindowsDirectoryA());
205 strcat(shellpath, "\\My Documents");
206 CreateDirectoryA(shellpath, NULL);
207 RegSetValueExA(hkey,"Personal",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
208 //PrintHood
209 strcpy(shellpath, InternalGetWindowsDirectoryA());
210 strcat(shellpath, "\\PrintHood");
211 CreateDirectoryA(shellpath, NULL);
212 RegSetValueExA(hkey,"PrintHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
213 //Recent
214 strcpy(shellpath, InternalGetWindowsDirectoryA());
215 strcat(shellpath, "\\Recent");
216 CreateDirectoryA(shellpath, NULL);
217 RegSetValueExA(hkey,"Recent",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
218 //SendTo
219 strcpy(shellpath, InternalGetWindowsDirectoryA());
220 strcat(shellpath, "\\SendTo");
221 CreateDirectoryA(shellpath, NULL);
222 RegSetValueExA(hkey,"SendTo",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
223 //Start Menu
224 strcpy(shellpath, InternalGetWindowsDirectoryA());
225 strcat(shellpath, "\\Start Menu");
226 CreateDirectoryA(shellpath, NULL);
227 RegSetValueExA(hkey,"Start Menu",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
228 //Programs
229 strcpy(shellpath, InternalGetWindowsDirectoryA());
230 strcat(shellpath, "\\Start Menu\\Programs");
231 CreateDirectoryA(shellpath, NULL);
232 RegSetValueExA(hkey,"Programs",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
233 //Startup
234 strcat(shellpath, "\\Startup");
235 CreateDirectoryA(shellpath, NULL);
236 RegSetValueExA(hkey,"Startup",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
237 //ShellNew
238 strcpy(shellpath, InternalGetWindowsDirectoryA());
239 strcat(shellpath, "\\ShellNew");
240 CreateDirectoryA(shellpath, NULL);
241 RegSetValueExA(hkey,"Templates",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
242// }
243 RegCloseKey(hkey);
244
245 //Now the Ddraw & dsound registry keys:
246 //HKEY_CLASSES_ROOT\DirectDraw = DirectDraw Object
247 //HKEY_CLASSES_ROOT\DirectDraw\CLSID = {D7B70EE0-4340-11CF-B063-0020AFC2CD35}
248 //HKEY_CLASSES_ROOT\CLSID\{D7B70EE0-4340-11CF-B063-0020AFC2CD35} = DirectDraw Object
249 //HKEY_CLASSES_ROOT\CLSID\{D7B70EE0-4340-11CF-B063-0020AFC2CD35}\InprocServer32 = ddraw.dll
250 if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectDraw",&hkey)!=ERROR_SUCCESS) {
251 goto initreg_error;
252 }
253 RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)DDRAW_DEFAULT, sizeof(DDRAW_DEFAULT));
254 if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
255 RegCloseKey(hkey);
256 goto initreg_error;
257 }
258 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_CLASSID, sizeof(DDRAW_CLASSID));
259 RegCloseKey(hkey1);
260 RegCloseKey(hkey);
261
262 if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DDRAW_CLASSID ,&hkey)!=ERROR_SUCCESS) {
263 goto initreg_error;
264 }
265 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_DEFAULT, sizeof(DDRAW_DEFAULT));
266 if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
267 RegCloseKey(hkey);
268 goto initreg_error;
269 }
270 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_DLL, sizeof(DDRAW_DLL));
271 RegSetValueExA(hkey1, COM_THREADMODEL, 0,REG_SZ, (LPBYTE)THREAD_BOTH, sizeof(THREAD_BOTH));
272 RegCloseKey(hkey1);
273 RegCloseKey(hkey);
274
275 //HKEY_CLASSES_ROOT\DirectDrawClipper = DirectDraw Clipper Object
276 //HKEY_CLASSES_ROOT\DirectDrawClipper\CLSID = {593817A0-7DB3-11CF-A2DE-00AA00B93356}
277 //HKEY_CLASSES_ROOT\CLSID\{593817A0-7DB3-11CF-A2DE-00AA00B93356} = DirectDraw Clipper Object
278 //HKEY_CLASSES_ROOT\CLSID\{593817A0-7DB3-11CF-A2DE-00AA00B93356}\InprocServer32 = ddraw.dll
279 if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectDrawClipper",&hkey)!=ERROR_SUCCESS) {
280 goto initreg_error;
281 }
282 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_DEFAULT, sizeof(DDRAW_CLIPPER_DEFAULT));
283 if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
284 RegCloseKey(hkey);
285 goto initreg_error;
286 }
287 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_CLASSID, sizeof(DDRAW_CLIPPER_CLASSID));
288 RegCloseKey(hkey1);
289 RegCloseKey(hkey);
290
291 if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DDRAW_CLIPPER_CLASSID,&hkey)!=ERROR_SUCCESS) {
292 goto initreg_error;
293 }
294 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_DEFAULT, sizeof(DDRAW_CLIPPER_DEFAULT));
295 if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
296 RegCloseKey(hkey);
297 goto initreg_error;
298 }
299 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_DLL, sizeof(DDRAW_DLL));
300 RegSetValueExA(hkey1, COM_THREADMODEL, 0,REG_SZ, (LPBYTE)THREAD_BOTH, sizeof(THREAD_BOTH));
301 RegCloseKey(hkey1);
302 RegCloseKey(hkey);
303
304 //HKEY_CLASSES_ROOT\DirectSound = DirectSound Object
305 //HKEY_CLASSES_ROOT\DirectSound\CLSID = {47D4D946-62E8-11cf-93BC-444553540000}
306 //HKEY_CLASSES_ROOT\CLSID\{47D4D946-62E8-11cf-93BC-444553540000} = DirectSound Object
307 //HKEY_CLASSES_ROOT\CLSID\{47D4D946-62E8-11cf-93BC-444553540000}\InprocServer32 = dsound.dll
308 if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectSound",&hkey)!=ERROR_SUCCESS) {
309 goto initreg_error;
310 }
311 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DSOUND_DEFAULT, sizeof(DSOUND_DEFAULT));
312 if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
313 RegCloseKey(hkey);
314 goto initreg_error;
315 }
316 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DSOUND_CLASSID, sizeof(DSOUND_CLASSID));
317 RegCloseKey(hkey1);
318 RegCloseKey(hkey);
319
320 if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DSOUND_CLASSID ,&hkey)!=ERROR_SUCCESS) {
321 goto initreg_error;
322 }
323 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DSOUND_DEFAULT, sizeof(DSOUND_DEFAULT));
324 if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
325 RegCloseKey(hkey);
326 goto initreg_error;
327 }
328 RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DSOUND_DLL, sizeof(DSOUND_DLL));
329 RegSetValueExA(hkey1, COM_THREADMODEL, 0,REG_SZ, (LPBYTE)THREAD_BOTH, sizeof(THREAD_BOTH));
330 RegCloseKey(hkey1);
331 RegCloseKey(hkey);
332
333 //[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
334 //"ProgramFilesDir"="C:\Program Files"
335 //"CommonFilesDir"="C:\Program Files\Common Files"
336 //# 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.
337 //"SharedDir"="C:\WINDOWS"
338 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
339 goto initreg_error;
340 }
341 //Create x:\Program Files directory
342 strcpy(shellpath, InternalGetWindowsDirectoryA());
343 shellpath[2] = 0; //get drive
344 strcat(shellpath, "\\Program Files");
345 CreateDirectoryA(shellpath, NULL);
346 RegSetValueExA(hkey, DIR_PROGRAM, 0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
347
348 //Create x:\Program Files\Common Files directory
349 strcat(shellpath, "\\Common Files");
350 CreateDirectoryA(shellpath, NULL);
351 RegSetValueExA(hkey, DIR_PROGRAM_COMMON, 0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
352
353 strcpy(shellpath, InternalGetWindowsDirectoryA());
354 RegSetValueExA(hkey, DIR_SHARED, 0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
355
356 RegCloseKey(hkey);
357
358 //[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\VIDEO]
359 //"\\Device\\Video0"="\\REGISTRY\\Machine\\System\\ControlSet001\\Services\\mga64\\Device0"
360 //"\\Device\\Video1"="\\REGISTRY\\Machine\\System\\ControlSet001\\Services\\VgaSave\\Device0"
361 //"VgaCompatible"="\\Device\\Video1"
362 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\VIDEO",&hkey)!=ERROR_SUCCESS) {
363 goto initreg_error;
364 }
365 RegSetValueExA(hkey,"\\Device\\Video0",0,REG_SZ, (LPBYTE)HARDWARE_VIDEO_GRADD, sizeof(HARDWARE_VIDEO_GRADD));
366 RegSetValueExA(hkey,"\\Device\\Video1",0,REG_SZ, (LPBYTE)HARDWARE_VIDEO_VGA, sizeof(HARDWARE_VIDEO_VGA));
367 RegSetValueExA(hkey, "VgaCompatible", 0,REG_SZ, (LPBYTE)HARDWARE_VIDEO_COMPATIBLE, sizeof(HARDWARE_VIDEO_COMPATIBLE));
368 RegCloseKey(hkey);
369
370 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\Gradd\\Device0",&hkey)!=ERROR_SUCCESS) {
371 goto initreg_error;
372 }
373 RegSetValueExA(hkey,"Device Description", 0, REG_SZ, (LPBYTE)HARDWARE_VIDEO_GRADD_DESCRIPTION, sizeof(HARDWARE_VIDEO_GRADD_DESCRIPTION));
374 RegCloseKey(hkey);
375
376 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\VgaSave\\Device0",&hkey)!=ERROR_SUCCESS) {
377 goto initreg_error;
378 }
379 RegSetValueExA(hkey,"Device Description", 0, REG_SZ, (LPBYTE)HARDWARE_VIDEO_VGA_DESCRIPTION, sizeof(HARDWARE_VIDEO_VGA_DESCRIPTION));
380 RegCloseKey(hkey);
381
382 //Software\Microsoft\Multimedia\Sound Mapper
383 if(RegCreateKeyA(HKEY_CURRENT_USER,"Software\\Microsoft\\Multimedia\\Sound Mapper",&hkey)!=ERROR_SUCCESS) {
384 goto initreg_error;
385 }
386 RegSetValueExA(hkey,"Playback", 0, REG_SZ, (LPBYTE)ODIN_WINMM_PLAYBACK, sizeof(ODIN_WINMM_PLAYBACK));
387 RegSetValueExA(hkey,"Record", 0, REG_SZ, (LPBYTE)ODIN_WINMM_RECORD, sizeof(ODIN_WINMM_RECORD));
388 RegCloseKey(hkey);
389
390 //Software\Microsoft\DirectX
391 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectX",&hkey)!=ERROR_SUCCESS) {
392 goto initreg_error;
393 }
394 RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)"", 0);
395 RegSetValueExA(hkey, "RC", 0,REG_SZ, (LPBYTE)DIRECTX_RC, sizeof(DIRECTX_RC));
396 RegSetValueExA(hkey, "Version", 0,REG_SZ, (LPBYTE)DIRECTX_VERSION, sizeof(DIRECTX_VERSION));
397 val = DIRECTX_INSTALLED_VERSION;
398 RegSetValueExA(hkey, "InstalledVersion", 0,REG_BINARY, (LPBYTE)&val, sizeof(DWORD));
399 RegCloseKey(hkey);
400
401 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectDraw",&hkey)!=ERROR_SUCCESS) {
402 goto initreg_error;
403 }
404 //todo
405 RegCloseKey(hkey);
406
407 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Direct3D",&hkey)!=ERROR_SUCCESS) {
408 goto initreg_error;
409 }
410 //todo
411 RegCloseKey(hkey);
412
413 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectPlay",&hkey)!=ERROR_SUCCESS) {
414 goto initreg_error;
415 }
416 //todo
417 RegCloseKey(hkey);
418
419#if 0
420 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectMusic",&hkey)!=ERROR_SUCCESS) {
421 goto initreg_error;
422 }
423 //todo
424 RegCloseKey(hkey);
425#endif
426 return TRUE;
427
428initreg_error:
429 dprintf((INITREG_ERROR));
430 return FALSE;
431}
432//******************************************************************************
433//Environment variables created by Windows NT:
434//
435//COMPUTERNAME=NTBAK
436//ComSpec=E:\WINNT\system32\cmd.exe
437//CPU=i386
438//HOMEDRIVE=E:
439//HOMEPATH=\
440//LOGONSERVER=\\NTBAK
441//NUMBER_OF_PROCESSORS=2
442//OS=Windows_NT
443//PATHEXT=.COM;.EXE;.BAT;.CMD
444//PROCESSOR_ARCHITECTURE=x86
445//PROCESSOR_IDENTIFIER=x86 Family 6 Model 6 Stepping 5, GenuineIntel
446//PROCESSOR_LEVEL=6
447//PROCESSOR_REVISION=0605
448//SystemDrive=E:
449//SystemRoot=E:\WINNT
450//USERDOMAIN=NTBAK
451//USERNAME=Sander
452//USERPROFILE=E:\WINNT\Profiles\Sander
453//windir=E:\WINNT
454//******************************************************************************
455void InitEnvironment(int nrcpus)
456{
457 char buffer[64];
458 char buffer1[32];
459 char *windir;
460 DWORD signature;
461
462 SetEnvironmentVariableA("CPU", "i386");
463 SetEnvironmentVariableA("PROCESSOR_ARCHITECTURE", "x86");
464 if(SupportsCPUID()) {
465 GetCPUVendorString(buffer1);
466 buffer1[12] = 0;
467 signature = GetCPUSignature();
468 sprintf(buffer, "x86 Family %x Model %x Stepping %x, %s", (signature >> 8)&0xf, signature & 0xf, (signature >> 4)&0xf, buffer1);
469 SetEnvironmentVariableA("PROCESSOR_IDENTIFIER", buffer);
470 sprintf(buffer, "%x", (signature >> 8)&0xf);
471 SetEnvironmentVariableA("PROCESSOR_LEVEL", buffer);
472 sprintf(buffer, "%02x%02x", (signature >> 4)&0xf, signature & 0xf);
473 SetEnvironmentVariableA("PROCESSOR_REVISION", buffer);
474 }
475 sprintf(buffer, "%d", nrcpus);
476 SetEnvironmentVariableA("NUMBER_OF_PROCESSORS", buffer);
477 SetEnvironmentVariableA("OS", "Windows_NT");
478 SetEnvironmentVariableA("PATHEXT", ".COM;.EXE;.BAT;.CMD");
479 windir = InternalGetWindowsDirectoryA();
480 SetEnvironmentVariableA("windir", windir);
481 SetEnvironmentVariableA("SystemRoot", windir);
482 buffer[0] = windir[0];
483 buffer[1] = windir[1];
484 buffer[2] = 0;
485 SetEnvironmentVariableA("SystemDrive", buffer);
486 SetEnvironmentVariableA("HOMEDRIVE", buffer);
487 SetEnvironmentVariableA("HOMEPATH", "\\");
488
489//TODO:
490//COMPUTERNAME=NTBAK
491//ComSpec=E:\WINNT\system32\cmd.exe
492//LOGONSERVER=\\NTBAK
493//USERDOMAIN=NTBAK
494//USERNAME=Sander
495//USERPROFILE=E:\WINNT\Profiles\Sander
496}
Note: See TracBrowser for help on using the repository browser.