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

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

Create 'Font Mapping' Odin.ini entry during WarpIn install

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