| 1 | /* $Id: initsystem.cpp,v 1.28 2001-06-27 13:35:46 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 | * Copyright 1999-2000 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 9 | *
|
|---|
| 10 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | #include <os2win.h>
|
|---|
| 14 | #include <ctype.h>
|
|---|
| 15 | #include <string.h>
|
|---|
| 16 | #include "winreg.h"
|
|---|
| 17 | #include "global.h"
|
|---|
| 18 | #include "winnt.h"
|
|---|
| 19 | #include "winerror.h"
|
|---|
| 20 | #include "winreg.h"
|
|---|
| 21 | #include "debugtools.h"
|
|---|
| 22 | #include "cpuhlp.h"
|
|---|
| 23 | #include <odininst.h>
|
|---|
| 24 | #include <win\options.h>
|
|---|
| 25 | #include "directory.h"
|
|---|
| 26 | #include <versionos2.h>
|
|---|
| 27 |
|
|---|
| 28 | #define DBG_LOCALLOG DBG_initsystem
|
|---|
| 29 | #include "dbglocal.h"
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | //******************************************************************************
|
|---|
| 33 | //******************************************************************************
|
|---|
| 34 | //Environment variables created by Windows NT:
|
|---|
| 35 | //
|
|---|
| 36 | //COMPUTERNAME=NTBAK
|
|---|
| 37 | //ComSpec=E:\WINNT\system32\cmd.exe
|
|---|
| 38 | //CPU=i386
|
|---|
| 39 | //HOMEDRIVE=E:
|
|---|
| 40 | //HOMEPATH=\
|
|---|
| 41 | //LOGONSERVER=\\NTBAK
|
|---|
| 42 | //NUMBER_OF_PROCESSORS=2
|
|---|
| 43 | //OS=Windows_NT
|
|---|
| 44 | //PATHEXT=.COM;.EXE;.BAT;.CMD
|
|---|
| 45 | //PROCESSOR_ARCHITECTURE=x86
|
|---|
| 46 | //PROCESSOR_IDENTIFIER=x86 Family 6 Model 6 Stepping 5, GenuineIntel
|
|---|
| 47 | //PROCESSOR_LEVEL=6
|
|---|
| 48 | //PROCESSOR_REVISION=0605
|
|---|
| 49 | //SystemDrive=E:
|
|---|
| 50 | //SystemRoot=E:\WINNT
|
|---|
| 51 | //USERDOMAIN=NTBAK
|
|---|
| 52 | //USERNAME=Sander
|
|---|
| 53 | //USERPROFILE=E:\WINNT\Profiles\Sander
|
|---|
| 54 | //windir=E:\WINNT
|
|---|
| 55 | //******************************************************************************
|
|---|
| 56 | void InitEnvironment(int nrcpus)
|
|---|
| 57 | {
|
|---|
| 58 | char buffer[64];
|
|---|
| 59 | char buffer1[32];
|
|---|
| 60 | char *windir;
|
|---|
| 61 | DWORD signature;
|
|---|
| 62 |
|
|---|
| 63 | SetEnvironmentVariableA("CPU", "i386");
|
|---|
| 64 | SetEnvironmentVariableA("PROCESSOR_ARCHITECTURE", "x86");
|
|---|
| 65 | if(SupportsCPUID()) {
|
|---|
| 66 | GetCPUVendorString(buffer1);
|
|---|
| 67 | buffer1[12] = 0;
|
|---|
| 68 | signature = GetCPUSignature();
|
|---|
| 69 | sprintf(buffer, "x86 Family %x Model %x Stepping %x, %s", (signature >> 8)&0xf, (signature >> 4) & 0xf, signature & 0xf, buffer1);
|
|---|
| 70 | SetEnvironmentVariableA("PROCESSOR_IDENTIFIER", buffer);
|
|---|
| 71 | sprintf(buffer, "%x", (signature >> 8)&0xf);
|
|---|
| 72 | SetEnvironmentVariableA("PROCESSOR_LEVEL", buffer);
|
|---|
| 73 | sprintf(buffer, "%02x%02x", (signature >> 4)&0xf, signature & 0xf);
|
|---|
| 74 | SetEnvironmentVariableA("PROCESSOR_REVISION", buffer);
|
|---|
| 75 | }
|
|---|
| 76 | sprintf(buffer, "%d", nrcpus);
|
|---|
| 77 | SetEnvironmentVariableA("NUMBER_OF_PROCESSORS", buffer);
|
|---|
| 78 | SetEnvironmentVariableA("OS", "Windows_NT");
|
|---|
| 79 | SetEnvironmentVariableA("PATHEXT", ".COM;.EXE;.BAT;.CMD");
|
|---|
| 80 | windir = InternalGetWindowsDirectoryA();
|
|---|
| 81 | SetEnvironmentVariableA("windir", windir);
|
|---|
| 82 | SetEnvironmentVariableA("SystemRoot", windir);
|
|---|
| 83 | buffer[0] = windir[0];
|
|---|
| 84 | buffer[1] = windir[1];
|
|---|
| 85 | buffer[2] = 0;
|
|---|
| 86 | SetEnvironmentVariableA("SystemDrive", buffer);
|
|---|
| 87 | SetEnvironmentVariableA("HOMEDRIVE", buffer);
|
|---|
| 88 | SetEnvironmentVariableA("HOMEPATH", "\\");
|
|---|
| 89 |
|
|---|
| 90 | //TODO:
|
|---|
| 91 | //COMPUTERNAME=NTBAK
|
|---|
| 92 | //ComSpec=E:\WINNT\system32\cmd.exe
|
|---|
| 93 | //LOGONSERVER=\\NTBAK
|
|---|
| 94 | //USERDOMAIN=NTBAK
|
|---|
| 95 | //USERNAME=Sander
|
|---|
| 96 | //USERPROFILE=E:\WINNT\Profiles\Sander
|
|---|
| 97 | }
|
|---|
| 98 | //******************************************************************************
|
|---|
| 99 | //Create/change keys that may change (i.e. odin.ini keys that affect windows version)
|
|---|
| 100 | //******************************************************************************
|
|---|
| 101 | void InitDynamicRegistry()
|
|---|
| 102 | {
|
|---|
| 103 | OSVERSIONINFOA versioninfo;
|
|---|
| 104 | HKEY hkey;
|
|---|
| 105 | char buf[16] = "";
|
|---|
| 106 |
|
|---|
| 107 | versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
|---|
| 108 | GetVersionExA(&versioninfo);
|
|---|
| 109 |
|
|---|
| 110 | //Set version key:
|
|---|
| 111 | // [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions]
|
|---|
| 112 | // "ProductType"="WinNT"
|
|---|
| 113 | if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",&hkey)!=ERROR_SUCCESS) {
|
|---|
| 114 | dprintf(("InitRegistry: Unable to register system information (2)"));
|
|---|
| 115 | return;
|
|---|
| 116 | }
|
|---|
| 117 | switch(versioninfo.dwPlatformId) {
|
|---|
| 118 | case VER_PLATFORM_WIN32_WINDOWS:
|
|---|
| 119 | strcpy(buf, "Win98"); //TODO: Correct???????????
|
|---|
| 120 | break;
|
|---|
| 121 | case VER_PLATFORM_WIN32_NT:
|
|---|
| 122 | strcpy(buf, "WinNT"); //TODO: Also correct for Windows 2000???
|
|---|
| 123 | break;
|
|---|
| 124 | default:
|
|---|
| 125 | DebugInt3();
|
|---|
| 126 | break;
|
|---|
| 127 | }
|
|---|
| 128 | RegSetValueExA(hkey,"ProductType",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
|
|---|
| 129 | RegCloseKey(hkey);
|
|---|
| 130 | }
|
|---|
| 131 | //******************************************************************************
|
|---|
| 132 | //******************************************************************************
|
|---|
| 133 |
|
|---|