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

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

create additional keys during install (display driver related) + extra logging for GetProcAddress

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