1 | /* $Id: initsystem.cpp,v 1.8 2000-03-10 16:11:59 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Odin system initialization (registry & directories)
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * NOTE: Most of this has to be moved into the Odin install program!!!!!
|
---|
7 | *
|
---|
8 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 | #include <os2win.h>
|
---|
13 | #include <ctype.h>
|
---|
14 | #include <string.h>
|
---|
15 | #include "winreg.h"
|
---|
16 | #include "global.h"
|
---|
17 | #include "winnt.h"
|
---|
18 | #include "winerror.h"
|
---|
19 | #include "winreg.h"
|
---|
20 | #include "debugtools.h"
|
---|
21 | #include "cpuhlp.h"
|
---|
22 | #include "initsystem.h"
|
---|
23 | #include "directory.h"
|
---|
24 | #include <versionos2.h>
|
---|
25 |
|
---|
26 | #define DBG_LOCALLOG DBG_initsystem
|
---|
27 | #include "dbglocal.h"
|
---|
28 |
|
---|
29 | #define DDRAW_CLASSID "{D7B70EE0-4340-11CF-B063-0020AFC2CD35}"
|
---|
30 | #define DDRAW_DEFAULT "DirectDraw Object"
|
---|
31 | #define DDRAW_CLIPPER_CLASSID "{593817A0-7DB3-11CF-A2DE-00AA00B93356}"
|
---|
32 | #define DDRAW_CLIPPER_DEFAULT "DirectDraw Clipper Object"
|
---|
33 | #define DDRAW_DLL "ddraw.dll"
|
---|
34 | #define DSOUND_CLASSID "{47D4D946-62E8-11cf-93BC-444553540000}"
|
---|
35 | #define DSOUND_DEFAULT "DirectSound Object"
|
---|
36 | #define DSOUND_DLL "dsound.dll"
|
---|
37 | #define COM_CLASS_ID "CLSID"
|
---|
38 | #define COM_INPROCSERVER "InprocServer32"
|
---|
39 | #define COM_THREADMODEL "ThreadingModel"
|
---|
40 | #define THREAD_BOTH "Both"
|
---|
41 | #define INITREG_ERROR "InitRegistry: Unable to register system information"
|
---|
42 |
|
---|
43 | BOOL InitRegistry();
|
---|
44 |
|
---|
45 | //******************************************************************************
|
---|
46 | //******************************************************************************
|
---|
47 | BOOL InitSystemEnvironment(ULONG nrCPUs)
|
---|
48 | {
|
---|
49 | InitSystemInfo(nrCPUs);
|
---|
50 | return InitRegistry();
|
---|
51 | }
|
---|
52 | //******************************************************************************
|
---|
53 | //[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows]
|
---|
54 | //"Directory"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,00
|
---|
55 | //"SystemDirectory"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,73,79,73,74,65,\
|
---|
56 | // 6d,33,32,00
|
---|
57 | //"ErrorMode"=dword:00000000
|
---|
58 | //"NoInteractiveServices"=dword:00000000
|
---|
59 | //"CSDVersion"=dword:00000300
|
---|
60 | BYTE ShutdownTime[] = {0x44,0x5e,0xf2,0xbb,0x84,0x41,0xbf,0x01};
|
---|
61 | //******************************************************************************
|
---|
62 | BOOL InitRegistry()
|
---|
63 | {
|
---|
64 | HKEY hkey, hkey1;
|
---|
65 | char *buf;
|
---|
66 | DWORD val;
|
---|
67 | char digbuf[16];
|
---|
68 |
|
---|
69 | if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Windows",&hkey)!=ERROR_SUCCESS) {
|
---|
70 | dprintf(("InitRegistry: Unable to register system information\n"));
|
---|
71 | return FALSE;
|
---|
72 | }
|
---|
73 | buf = InternalGetWindowsDirectoryA();
|
---|
74 | RegSetValueExA(hkey,"Directory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
|
---|
75 | buf = InternalGetSystemDirectoryA();
|
---|
76 | RegSetValueExA(hkey,"SystemDirectory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
|
---|
77 | val = 0;
|
---|
78 | RegSetValueExA(hkey,"ErrorMode",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
|
---|
79 | val = 0;
|
---|
80 | RegSetValueExA(hkey,"NoInteractiveServices",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
|
---|
81 | val = ODINNT_BUILD_NR;
|
---|
82 | RegSetValueExA(hkey,"CSDVersion",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
|
---|
83 | RegSetValueExA(hkey,"ShutdownTime",0,REG_DWORD, (LPBYTE)ShutdownTime, sizeof(ShutdownTime));
|
---|
84 | RegCloseKey(hkey);
|
---|
85 |
|
---|
86 | if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
|
---|
87 | dprintf(("InitRegistry: Unable to register system information (2)"));
|
---|
88 | return FALSE;
|
---|
89 | }
|
---|
90 | buf = InternalGetSystemDirectoryA();
|
---|
91 | RegSetValueExA(hkey,"SystemRoot",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
|
---|
92 | RegSetValueExA(hkey,"PathName",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
|
---|
93 | sprintf(digbuf, "%d", ODINNT_BUILD_NR);
|
---|
94 | RegSetValueExA(hkey,"CurrentBuildNumber",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
|
---|
95 | RegSetValueExA(hkey,"CurrentType",0,REG_SZ, (LPBYTE)ODINNT_OSTYPE_UNI, sizeof(ODINNT_OSTYPE_UNI));
|
---|
96 | RegSetValueExA(hkey,"CSDVersion",0,REG_SZ, (LPBYTE)ODINNT_CSDVERSION, sizeof(ODINNT_CSDVERSION));
|
---|
97 | RegSetValueExA(hkey,"SoftwareType",0,REG_SZ, (LPBYTE)ODINNT_SOFTWARE_TYPE, sizeof(ODINNT_SOFTWARE_TYPE));
|
---|
98 |
|
---|
99 | sprintf(digbuf, "%d.%d", ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION);
|
---|
100 | RegSetValueExA(hkey,"CurrentVersion",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
|
---|
101 |
|
---|
102 | val = (DWORD)time(NULL); //todo: Correct format???
|
---|
103 | RegSetValueExA(hkey,"InstallDate",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
|
---|
104 |
|
---|
105 | RegCloseKey(hkey);
|
---|
106 | //todo: productid, registered org/owner, sourcepath,
|
---|
107 |
|
---|
108 | //Create Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders keys
|
---|
109 | //"Favorites"="C:\WINDOWS\Favorites"
|
---|
110 | //"StartUp"="C:\WINDOWS\Start Menu\Programs\Startup"
|
---|
111 | //"Desktop"="C:\WINDOWS\Desktop"
|
---|
112 | //"Programs"="C:\WINDOWS\Start Menu\Programs"
|
---|
113 | //"Fonts"="C:\WINDOWS\Fonts"
|
---|
114 | //"SendTo"="C:\WINDOWS\SendTo"
|
---|
115 | //"Start Menu"="C:\WINDOWS\Start Menu"
|
---|
116 | //"Templates"="C:\WINDOWS\ShellNew"
|
---|
117 | //"Recent"="C:\WINDOWS\Recent"
|
---|
118 | //"NetHood"="C:\WINDOWS\NetHood"
|
---|
119 | //"Personal"="C:\My Documents"
|
---|
120 |
|
---|
121 | char shellpath[260];
|
---|
122 |
|
---|
123 | if(RegCreateKeyA(HKEY_CURRENT_USER,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",&hkey)!=ERROR_SUCCESS) {
|
---|
124 | dprintf(("InitRegistry: Unable to register system information (3)"));
|
---|
125 | return FALSE;
|
---|
126 | }
|
---|
127 | // if(RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey) != ERROR_SUCCESS)
|
---|
128 | // {
|
---|
129 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
130 | strcat(shellpath, "\\Favorites");
|
---|
131 | CreateDirectoryA(shellpath, NULL);
|
---|
132 | RegSetValueExA(hkey,"Favorites",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
133 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
134 | strcat(shellpath, "\\Programs\\Startup");
|
---|
135 | CreateDirectoryA(shellpath, NULL);
|
---|
136 | RegSetValueExA(hkey,"Startup",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
137 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
138 | strcat(shellpath, "\\Desktop");
|
---|
139 | CreateDirectoryA(shellpath, NULL);
|
---|
140 | RegSetValueExA(hkey,"Desktop",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
141 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
142 | strcat(shellpath, "\\Start Menu\\Programs");
|
---|
143 | CreateDirectoryA(shellpath, NULL);
|
---|
144 | RegSetValueExA(hkey,"Programs",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
145 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
146 | strcat(shellpath, "\\Fonts");
|
---|
147 | CreateDirectoryA(shellpath, NULL);
|
---|
148 | RegSetValueExA(hkey,"Fonts",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
149 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
150 | strcat(shellpath, "\\SendTo");
|
---|
151 | CreateDirectoryA(shellpath, NULL);
|
---|
152 | RegSetValueExA(hkey,"SendTo",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
153 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
154 | strcat(shellpath, "\\Start Menu");
|
---|
155 | CreateDirectoryA(shellpath, NULL);
|
---|
156 | RegSetValueExA(hkey,"Start Menu",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
157 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
158 | strcat(shellpath, "\\ShellNew");
|
---|
159 | CreateDirectoryA(shellpath, NULL);
|
---|
160 | RegSetValueExA(hkey,"Templates",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
161 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
162 | strcat(shellpath, "\\Recent");
|
---|
163 | CreateDirectoryA(shellpath, NULL);
|
---|
164 | RegSetValueExA(hkey,"Recent",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
165 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
166 | strcat(shellpath, "\\NetHood");
|
---|
167 | CreateDirectoryA(shellpath, NULL);
|
---|
168 | RegSetValueExA(hkey,"NetHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
169 | strcpy(shellpath, InternalGetWindowsDirectoryA());
|
---|
170 | strcat(shellpath, "\\My Documents");
|
---|
171 | CreateDirectoryA(shellpath, NULL);
|
---|
172 | RegSetValueExA(hkey,"Personal",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
|
---|
173 | // }
|
---|
174 | RegCloseKey(hkey);
|
---|
175 |
|
---|
176 | //Now the Ddraw & dsound registry keys:
|
---|
177 | //HKEY_CLASSES_ROOT\DirectDraw = DirectDraw Object
|
---|
178 | //HKEY_CLASSES_ROOT\DirectDraw\CLSID = {D7B70EE0-4340-11CF-B063-0020AFC2CD35}
|
---|
179 | //HKEY_CLASSES_ROOT\CLSID\{D7B70EE0-4340-11CF-B063-0020AFC2CD35} = DirectDraw Object
|
---|
180 | //HKEY_CLASSES_ROOT\CLSID\{D7B70EE0-4340-11CF-B063-0020AFC2CD35}\InprocServer32 = ddraw.dll
|
---|
181 | if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectDraw",&hkey)!=ERROR_SUCCESS) {
|
---|
182 | goto initreg_error;
|
---|
183 | }
|
---|
184 | RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)DDRAW_DEFAULT, sizeof(DDRAW_DEFAULT));
|
---|
185 | if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
|
---|
186 | RegCloseKey(hkey);
|
---|
187 | goto initreg_error;
|
---|
188 | }
|
---|
189 | RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_CLASSID, sizeof(DDRAW_CLASSID));
|
---|
190 | RegCloseKey(hkey1);
|
---|
191 | RegCloseKey(hkey);
|
---|
192 |
|
---|
193 | if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DDRAW_CLASSID ,&hkey)!=ERROR_SUCCESS) {
|
---|
194 | goto initreg_error;
|
---|
195 | }
|
---|
196 | RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_DEFAULT, sizeof(DDRAW_DEFAULT));
|
---|
197 | if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
|
---|
198 | RegCloseKey(hkey);
|
---|
199 | goto initreg_error;
|
---|
200 | }
|
---|
201 | RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_DLL, sizeof(DDRAW_DLL));
|
---|
202 | RegSetValueExA(hkey1, COM_THREADMODEL, 0,REG_SZ, (LPBYTE)THREAD_BOTH, sizeof(THREAD_BOTH));
|
---|
203 | RegCloseKey(hkey1);
|
---|
204 | RegCloseKey(hkey);
|
---|
205 |
|
---|
206 | //HKEY_CLASSES_ROOT\DirectDrawClipper = DirectDraw Clipper Object
|
---|
207 | //HKEY_CLASSES_ROOT\DirectDrawClipper\CLSID = {593817A0-7DB3-11CF-A2DE-00AA00B93356}
|
---|
208 | //HKEY_CLASSES_ROOT\CLSID\{593817A0-7DB3-11CF-A2DE-00AA00B93356} = DirectDraw Clipper Object
|
---|
209 | //HKEY_CLASSES_ROOT\CLSID\{593817A0-7DB3-11CF-A2DE-00AA00B93356}\InprocServer32 = ddraw.dll
|
---|
210 | if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectDrawClipper",&hkey)!=ERROR_SUCCESS) {
|
---|
211 | goto initreg_error;
|
---|
212 | }
|
---|
213 | RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_DEFAULT, sizeof(DDRAW_CLIPPER_DEFAULT));
|
---|
214 | if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
|
---|
215 | RegCloseKey(hkey);
|
---|
216 | goto initreg_error;
|
---|
217 | }
|
---|
218 | RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_CLASSID, sizeof(DDRAW_CLIPPER_CLASSID));
|
---|
219 | RegCloseKey(hkey1);
|
---|
220 | RegCloseKey(hkey);
|
---|
221 |
|
---|
222 | if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DDRAW_CLIPPER_CLASSID,&hkey)!=ERROR_SUCCESS) {
|
---|
223 | goto initreg_error;
|
---|
224 | }
|
---|
225 | RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_DEFAULT, sizeof(DDRAW_CLIPPER_DEFAULT));
|
---|
226 | if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
|
---|
227 | RegCloseKey(hkey);
|
---|
228 | goto initreg_error;
|
---|
229 | }
|
---|
230 | RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_DLL, sizeof(DDRAW_DLL));
|
---|
231 | RegSetValueExA(hkey1, COM_THREADMODEL, 0,REG_SZ, (LPBYTE)THREAD_BOTH, sizeof(THREAD_BOTH));
|
---|
232 | RegCloseKey(hkey1);
|
---|
233 | RegCloseKey(hkey);
|
---|
234 |
|
---|
235 | //HKEY_CLASSES_ROOT\DirectSound = DirectSound Object
|
---|
236 | //HKEY_CLASSES_ROOT\DirectSound\CLSID = {47D4D946-62E8-11cf-93BC-444553540000}
|
---|
237 | //HKEY_CLASSES_ROOT\CLSID\{47D4D946-62E8-11cf-93BC-444553540000} = DirectSound Object
|
---|
238 | //HKEY_CLASSES_ROOT\CLSID\{47D4D946-62E8-11cf-93BC-444553540000}\InprocServer32 = dsound.dll
|
---|
239 | if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectSound",&hkey)!=ERROR_SUCCESS) {
|
---|
240 | goto initreg_error;
|
---|
241 | }
|
---|
242 | RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DSOUND_DEFAULT, sizeof(DSOUND_DEFAULT));
|
---|
243 | if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
|
---|
244 | RegCloseKey(hkey);
|
---|
245 | goto initreg_error;
|
---|
246 | }
|
---|
247 | RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DSOUND_CLASSID, sizeof(DSOUND_CLASSID));
|
---|
248 | RegCloseKey(hkey1);
|
---|
249 | RegCloseKey(hkey);
|
---|
250 |
|
---|
251 | if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DSOUND_CLASSID ,&hkey)!=ERROR_SUCCESS) {
|
---|
252 | goto initreg_error;
|
---|
253 | }
|
---|
254 | RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DSOUND_DEFAULT, sizeof(DSOUND_DEFAULT));
|
---|
255 | if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
|
---|
256 | RegCloseKey(hkey);
|
---|
257 | goto initreg_error;
|
---|
258 | }
|
---|
259 | RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DSOUND_DLL, sizeof(DSOUND_DLL));
|
---|
260 | RegSetValueExA(hkey1, COM_THREADMODEL, 0,REG_SZ, (LPBYTE)THREAD_BOTH, sizeof(THREAD_BOTH));
|
---|
261 | RegCloseKey(hkey1);
|
---|
262 | RegCloseKey(hkey);
|
---|
263 | return TRUE;
|
---|
264 |
|
---|
265 | initreg_error:
|
---|
266 | dprintf((INITREG_ERROR));
|
---|
267 | return FALSE;
|
---|
268 | }
|
---|
269 | //******************************************************************************
|
---|
270 | //******************************************************************************
|
---|