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