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