Changeset 4510 for trunk/src


Ignore:
Timestamp:
Oct 21, 2000, 4:30:47 PM (25 years ago)
Author:
sandervl
Message:

registry api fixes + version keys added

Location:
trunk/src/kernel32
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/initsystem.cpp

    r4508 r4510  
    1 /* $Id: initsystem.cpp,v 1.20 2000-10-21 12:48:40 sandervl Exp $ */
     1/* $Id: initsystem.cpp,v 1.21 2000-10-21 14:30:46 sandervl Exp $ */
    22/*
    33 * Odin system initialization (registry, directories & environment)
    44 *
    5  * Called from the WarpIn install program to create the desktop directories and 
     5 * Called from the WarpIn install program to create the desktop directories and
    66 * to setup the registry
    77 *
    88 * InitSystemAndRegistry creates:
    99 *      - SYSTEMDIR\drivers
    10  *      - WINDOWSDIR\SYSTEM
     10 *  - WINDOWSDIR\SYSTEM
    1111 *      - WINDOWSDIR\AppData
    1212 *      - WINDOWSDIR\Cache
    1313 *      - WINDOWSDIR\Cookies
    14  *      - WINDOWSDIR\Desktop
    15  *      - WINDOWSDIR\Favorites
    16  *      - WINDOWSDIR\Fonts
     14 *  - WINDOWSDIR\Desktop
     15 *  - WINDOWSDIR\Favorites
     16 *  - WINDOWSDIR\Fonts
    1717 *      - WINDOWSDIR\History
    18  *      - WINDOWSDIR\NetHood
    19  *      - WINDOWSDIR\My Documents
    20  *      - WINDOWSDIR\PrintHood
    21  *      - WINDOWSDIR\Recent
    22  *      - WINDOWSDIR\SendTo
    23  *      - WINDOWSDIR\Start Menu
    24  *      - WINDOWSDIR\Start Menu\Programs
    25  *      - WINDOWSDIR\Start Menu\Programs\Startup
    26  *      - WINDOWSDIR\ShellNew
     18 *  - WINDOWSDIR\NetHood
     19 *  - WINDOWSDIR\My Documents
     20 *  - WINDOWSDIR\PrintHood
     21 *  - WINDOWSDIR\Recent
     22 *  - WINDOWSDIR\SendTo
     23 *  - WINDOWSDIR\Start Menu
     24 *  - WINDOWSDIR\Start Menu\Programs
     25 *  - WINDOWSDIR\Start Menu\Programs\Startup
     26 *  - WINDOWSDIR\ShellNew
    2727 *      - x:\Program Files
    2828 *      - x:\Program Files\Common Files
    29  *      - and a minimal system registry
     29 *  - and a minimal system registry
    3030 *
    3131 * Copyright 1999-2000 Sander van Leeuwen (sandervl@xs4all.nl)
     
    4848#include <versionos2.h>
    4949
    50 #define DBG_LOCALLOG    DBG_initsystem
     50#define DBG_LOCALLOG    DBG_initsystem
    5151#include "dbglocal.h"
    5252
    53 #define DDRAW_CLASSID           "{D7B70EE0-4340-11CF-B063-0020AFC2CD35}"
    54 #define DDRAW_DEFAULT           "DirectDraw Object"
    55 #define DDRAW_CLIPPER_CLASSID   "{593817A0-7DB3-11CF-A2DE-00AA00B93356}"
    56 #define DDRAW_CLIPPER_DEFAULT   "DirectDraw Clipper Object"
    57 #define DDRAW_DLL               "ddraw.dll"
    58 #define DSOUND_CLASSID          "{47D4D946-62E8-11cf-93BC-444553540000}"
    59 #define DSOUND_DEFAULT          "DirectSound Object"
    60 #define DSOUND_DLL              "dsound.dll"
     53#define DDRAW_CLASSID       "{D7B70EE0-4340-11CF-B063-0020AFC2CD35}"
     54#define DDRAW_DEFAULT       "DirectDraw Object"
     55#define DDRAW_CLIPPER_CLASSID   "{593817A0-7DB3-11CF-A2DE-00AA00B93356}"
     56#define DDRAW_CLIPPER_DEFAULT   "DirectDraw Clipper Object"
     57#define DDRAW_DLL       "ddraw.dll"
     58#define DSOUND_CLASSID      "{47D4D946-62E8-11cf-93BC-444553540000}"
     59#define DSOUND_DEFAULT      "DirectSound Object"
     60#define DSOUND_DLL      "dsound.dll"
    6161#define DPLAYX_CLASSID          "{D1EB6D20-8923-11d0-9D97-00A0C90A43CB}"
    6262#define DPLAYX_DEFAULT          "DirectPlay Object"
     
    6666#define DPLAYX_LOBBY_DLL        DPLAYX_DLL
    6767
    68 #define CLASS_DESKTOP           "Desktop"
     68#define CLASS_DESKTOP       "Desktop"
    6969#define CLASS_SHORTCUT          "Shortcut"
    70 #define CLASS_SHELL32DLL        "shell32.dll"
    71 #define COM_CLASS_ID            "CLSID"
     70#define CLASS_SHELL32DLL    "shell32.dll"
     71#define COM_CLASS_ID        "CLSID"
    7272#define COM_INPROCSERVER        "InprocServer32"
    73 #define COM_THREADMODEL         "ThreadingModel"
     73#define COM_THREADMODEL     "ThreadingModel"
    7474#define COM_THREAD_APARTMENT    "Apartment"
    75 #define THREAD_BOTH             "Both"
    76 #define INITREG_ERROR           "InitRegistry: Unable to register system information"
     75#define THREAD_BOTH     "Both"
     76#define INITREG_ERROR       "InitRegistry: Unable to register system information"
    7777#define DIR_PROGRAM             "ProgramFilesDir"
    78 #define DIR_PROGRAM_COMMON      "CommonFilesDir"
     78#define DIR_PROGRAM_COMMON  "CommonFilesDir"
    7979#define DIR_SHARED              "SharedDir"
    8080#define HARDWARE_VIDEO_GRADD    "\\REGISTRY\\Machine\\System\\CurrentControlSet\\Services\\Gradd\\Device0"
     
    8686#define DIRECTX_VERSION         "4.04.1381.276"
    8787#define DIRECTX_INSTALLED_VERSION 0x0004
    88 #define ODIN_WINMM_PLAYBACK     "OS/2 Dart Audio Playback"
    89 #define ODIN_WINMM_RECORD       "OS/2 Dart Audio Record"
    90 
    91 #define KEY_DEVICE_TYPE         "Type"
    92 #define KEY_DEVICE_START        "Start"
     88#define ODIN_WINMM_PLAYBACK     "OS/2 Dart Audio Playback"
     89#define ODIN_WINMM_RECORD   "OS/2 Dart Audio Record"
     90
     91#define KEY_DEVICE_TYPE     "Type"
     92#define KEY_DEVICE_START    "Start"
    9393#define KEY_DEVICE_GROUP        "Group"
    9494#define KEY_DEVICE_ERRORCONTROL "ErrorControl"
     
    118118 char  shellpath[260];
    119119
    120    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Windows",&hkey)!=ERROR_SUCCESS) {
    121         dprintf(("InitRegistry: Unable to register system information\n"));
    122         return FALSE;
    123    }
    124    buf = InternalGetWindowsDirectoryA();
    125    RegSetValueExA(hkey,"Directory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
    126    buf = InternalGetSystemDirectoryA();
    127    RegSetValueExA(hkey,"SystemDirectory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
    128    val = 0;
    129    RegSetValueExA(hkey,"ErrorMode",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
    130    val = 0;
    131    RegSetValueExA(hkey,"NoInteractiveServices",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
    132    val = ODINNT_BUILD_NR;
    133    RegSetValueExA(hkey,"CSDVersion",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
    134    RegSetValueExA(hkey,"ShutdownTime",0,REG_DWORD, (LPBYTE)ShutdownTime, sizeof(ShutdownTime));
    135    RegCloseKey(hkey);
    136 
    137    //Software\Microsoft\Windows\CurrentVersion\RunOnce
    138    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce",&hkey)!=ERROR_SUCCESS) {
    139         dprintf(("InitRegistry: Unable to register system information (2)"));
    140         return FALSE;
    141    }
    142    RegCloseKey(hkey);
    143 
    144    //System\CurrentControlSet\Control\Session Manager
    145    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\Control\\Session Manager",&hkey)!=ERROR_SUCCESS) {
    146         dprintf(("InitRegistry: Unable to register system information (2)"));
    147         return FALSE;
    148    }
    149    RegCloseKey(hkey);
    150 
    151    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\iexplore.exe",&hkey)!=ERROR_SUCCESS) {
    152         dprintf(("InitRegistry: Unable to register system information (2)"));
    153         return FALSE;
    154    }
    155    strcpy(shellpath, InternalGetWindowsDirectoryA());
    156    strcat(shellpath, "\\IEXPLORE.EXE");
    157    RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    158    RegCloseKey(hkey);
    159 
    160 
    161    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
    162         dprintf(("InitRegistry: Unable to register system information (2)"));
    163         return FALSE;
    164    }
    165    buf = InternalGetSystemDirectoryA();
    166    RegSetValueExA(hkey,"SystemRoot",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
    167    RegSetValueExA(hkey,"PathName",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
    168    sprintf(digbuf, "%d", ODINNT_BUILD_NR);
    169    RegSetValueExA(hkey,"CurrentBuildNumber",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
    170    RegSetValueExA(hkey,"CurrentType",0,REG_SZ, (LPBYTE)ODINNT_OSTYPE_UNI, sizeof(ODINNT_OSTYPE_UNI));
    171    RegSetValueExA(hkey,"CSDVersion",0,REG_SZ, (LPBYTE)ODINNT_CSDVERSION, sizeof(ODINNT_CSDVERSION));
    172    RegSetValueExA(hkey,"SoftwareType",0,REG_SZ, (LPBYTE)ODINNT_SOFTWARE_TYPE, sizeof(ODINNT_SOFTWARE_TYPE));
    173 
    174    sprintf(digbuf, "%d.%d", ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION);
    175    RegSetValueExA(hkey,"CurrentVersion",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
    176 
    177    val = (DWORD)time(NULL); //todo: Correct format???
    178    RegSetValueExA(hkey,"InstallDate",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
    179    
    180    RegCloseKey(hkey);
    181    //todo: productid, registered org/owner, sourcepath,   
    182 
    183    //Create Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders keys
    184    //"Favorites"="C:\WINDOWS\Favorites"
    185    //"StartUp"="C:\WINDOWS\Start Menu\Programs\Startup"
    186    //"Desktop"="C:\WINDOWS\Desktop"
    187    //"Programs"="C:\WINDOWS\Start Menu\Programs"
    188    //"Fonts"="C:\WINDOWS\Fonts"
    189    //"SendTo"="C:\WINDOWS\SendTo"
    190    //"Start Menu"="C:\WINDOWS\Start Menu"
    191    //"Templates"="C:\WINDOWS\ShellNew"
    192    //"Recent"="C:\WINDOWS\Recent"
    193    //"NetHood"="C:\WINDOWS\NetHood"
    194    //"Personal"="C:\My Documents"
     120    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Windows",&hkey)!=ERROR_SUCCESS) {
     121        dprintf(("InitRegistry: Unable to register system information\n"));
     122        return FALSE;
     123    }
     124    buf = InternalGetWindowsDirectoryA();
     125    RegSetValueExA(hkey,"Directory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
     126    buf = InternalGetSystemDirectoryA();
     127    RegSetValueExA(hkey,"SystemDirectory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
     128    val = 0;
     129    RegSetValueExA(hkey,"ErrorMode",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
     130    val = 0;
     131    RegSetValueExA(hkey,"NoInteractiveServices",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
     132    val = ODINNT_BUILD_NR;
     133    RegSetValueExA(hkey,"CSDVersion",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
     134    RegSetValueExA(hkey,"ShutdownTime",0,REG_DWORD, (LPBYTE)ShutdownTime, sizeof(ShutdownTime));
     135    RegCloseKey(hkey);
     136
     137    //Software\Microsoft\Windows\CurrentVersion\RunOnce
     138    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce",&hkey)!=ERROR_SUCCESS) {
     139        dprintf(("InitRegistry: Unable to register system information (2)"));
     140        return FALSE;
     141    }
     142    RegCloseKey(hkey);
     143
     144    //System\CurrentControlSet\Control\Session Manager
     145    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\Control\\Session Manager",&hkey)!=ERROR_SUCCESS) {
     146        dprintf(("InitRegistry: Unable to register system information (2)"));
     147        return FALSE;
     148    }
     149    RegCloseKey(hkey);
     150
     151    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\iexplore.exe",&hkey)!=ERROR_SUCCESS) {
     152        dprintf(("InitRegistry: Unable to register system information (2)"));
     153        return FALSE;
     154    }
     155    strcpy(shellpath, InternalGetWindowsDirectoryA());
     156    strcat(shellpath, "\\IEXPLORE.EXE");
     157    RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     158    RegCloseKey(hkey);
     159
     160
     161    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
     162        dprintf(("InitRegistry: Unable to register system information (2)"));
     163        return FALSE;
     164    }
     165    buf = InternalGetSystemDirectoryA();
     166    RegSetValueExA(hkey,"SystemRoot",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
     167    RegSetValueExA(hkey,"PathName",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
     168    sprintf(digbuf, "%d", ODINNT_BUILD_NR);
     169    RegSetValueExA(hkey,"CurrentBuildNumber",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
     170    RegSetValueExA(hkey,"CurrentType",0,REG_SZ, (LPBYTE)ODINNT_OSTYPE_UNI, sizeof(ODINNT_OSTYPE_UNI));
     171    RegSetValueExA(hkey,"CSDVersion",0,REG_SZ, (LPBYTE)ODINNT_CSDVERSION, sizeof(ODINNT_CSDVERSION));
     172    RegSetValueExA(hkey,"SoftwareType",0,REG_SZ, (LPBYTE)ODINNT_SOFTWARE_TYPE, sizeof(ODINNT_SOFTWARE_TYPE));
     173
     174    sprintf(digbuf, "%d.%d", ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION);
     175    RegSetValueExA(hkey,"CurrentVersion",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
     176
     177    val = (DWORD)time(NULL); //todo: Correct format???
     178    RegSetValueExA(hkey,"InstallDate",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
     179
     180    RegCloseKey(hkey);
     181    //todo: productid, registered org/owner, sourcepath,
     182
     183    //Create Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders keys
     184    //"Favorites"="C:\WINDOWS\Favorites"
     185    //"StartUp"="C:\WINDOWS\Start Menu\Programs\Startup"
     186    //"Desktop"="C:\WINDOWS\Desktop"
     187    //"Programs"="C:\WINDOWS\Start Menu\Programs"
     188    //"Fonts"="C:\WINDOWS\Fonts"
     189    //"SendTo"="C:\WINDOWS\SendTo"
     190    //"Start Menu"="C:\WINDOWS\Start Menu"
     191    //"Templates"="C:\WINDOWS\ShellNew"
     192    //"Recent"="C:\WINDOWS\Recent"
     193    //"NetHood"="C:\WINDOWS\NetHood"
     194    //"Personal"="C:\My Documents"
    195195
    196196   if(RegCreateKeyA(HKEY_CURRENT_USER,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",&hkey)!=ERROR_SUCCESS) {
    197         dprintf(("InitRegistry: Unable to register system information (3)"));
    198         return FALSE;
    199    }
    200 //   if(RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey) != ERROR_SUCCESS) 
     197    dprintf(("InitRegistry: Unable to register system information (3)"));
     198    return FALSE;
     199   }
     200//   if(RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey) != ERROR_SUCCESS)
    201201//   {
    202202        //system32\drivers dir
    203         strcpy(shellpath, InternalGetSystemDirectoryA());
    204         strcat(shellpath, "\\Drivers");
    205         CreateDirectoryA(shellpath, NULL);
    206 
    207         //SYSTEM dir
    208         strcpy(shellpath, InternalGetWindowsDirectoryA());
    209         strcat(shellpath, "\\SYSTEM");
    210         CreateDirectoryA(shellpath, NULL);
    211 
    212         //AppData
    213         strcpy(shellpath, InternalGetWindowsDirectoryA());
    214         strcat(shellpath, "\\Application Data");
    215         CreateDirectoryA(shellpath, NULL);
    216         RegSetValueExA(hkey,"AppData",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    217         //Cache
    218         strcpy(shellpath, InternalGetWindowsDirectoryA());
    219         strcat(shellpath, "\\Temporary Internet Files");
    220         CreateDirectoryA(shellpath, NULL);
    221         RegSetValueExA(hkey,"Cache",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    222         //Cookies
    223         strcpy(shellpath, InternalGetWindowsDirectoryA());
    224         strcat(shellpath, "\\Cookies");
    225         CreateDirectoryA(shellpath, NULL);
    226         RegSetValueExA(hkey,"Cookies",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    227         //Desktop
    228         strcpy(shellpath, InternalGetWindowsDirectoryA());
    229         strcat(shellpath, "\\Desktop");
    230         CreateDirectoryA(shellpath, NULL);
    231         RegSetValueExA(hkey,"Desktop",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    232         //Favorites
    233         strcpy(shellpath, InternalGetWindowsDirectoryA());
    234         strcat(shellpath, "\\Favorites");
    235         CreateDirectoryA(shellpath, NULL);
    236         RegSetValueExA(hkey,"Favorites",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    237         //Fonts
    238         strcpy(shellpath, InternalGetWindowsDirectoryA());
    239         strcat(shellpath, "\\Fonts");
    240         CreateDirectoryA(shellpath, NULL);
    241         RegSetValueExA(hkey,"Fonts",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    242         //History
    243         strcpy(shellpath, InternalGetWindowsDirectoryA());
    244         strcat(shellpath, "\\History");
    245         CreateDirectoryA(shellpath, NULL);
    246         RegSetValueExA(hkey,"History",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    247         //NetHood
    248         strcpy(shellpath, InternalGetWindowsDirectoryA());
    249         strcat(shellpath, "\\NetHood");
    250         CreateDirectoryA(shellpath, NULL);
    251         RegSetValueExA(hkey,"NetHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    252         //Personal
    253         strcpy(shellpath, InternalGetWindowsDirectoryA());
    254         strcat(shellpath, "\\My Documents");
    255         CreateDirectoryA(shellpath, NULL);
    256         RegSetValueExA(hkey,"Personal",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    257         //PrintHood
    258         strcpy(shellpath, InternalGetWindowsDirectoryA());
    259         strcat(shellpath, "\\PrintHood");
    260         CreateDirectoryA(shellpath, NULL);
    261         RegSetValueExA(hkey,"PrintHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    262         //Recent
    263         strcpy(shellpath, InternalGetWindowsDirectoryA());
    264         strcat(shellpath, "\\Recent");
    265         CreateDirectoryA(shellpath, NULL);
    266         RegSetValueExA(hkey,"Recent",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    267         //SendTo
    268         strcpy(shellpath, InternalGetWindowsDirectoryA());
    269         strcat(shellpath, "\\SendTo");
    270         CreateDirectoryA(shellpath, NULL);
    271         RegSetValueExA(hkey,"SendTo",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    272         //Start Menu
    273         strcpy(shellpath, InternalGetWindowsDirectoryA());
    274         strcat(shellpath, "\\Start Menu");
    275         CreateDirectoryA(shellpath, NULL);
    276         RegSetValueExA(hkey,"Start Menu",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    277         //Programs
    278         strcpy(shellpath, InternalGetWindowsDirectoryA());
    279         strcat(shellpath, "\\Start Menu\\Programs");
    280         CreateDirectoryA(shellpath, NULL);
    281         RegSetValueExA(hkey,"Programs",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    282         //Startup
    283         strcat(shellpath, "\\Startup");
    284         CreateDirectoryA(shellpath, NULL);
    285         RegSetValueExA(hkey,"Startup",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    286         //ShellNew
    287         strcpy(shellpath, InternalGetWindowsDirectoryA());
    288         strcat(shellpath, "\\ShellNew");
    289         CreateDirectoryA(shellpath, NULL);
    290         RegSetValueExA(hkey,"Templates",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     203    strcpy(shellpath, InternalGetSystemDirectoryA());
     204    strcat(shellpath, "\\Drivers");
     205    CreateDirectoryA(shellpath, NULL);
     206
     207    //SYSTEM dir
     208    strcpy(shellpath, InternalGetWindowsDirectoryA());
     209    strcat(shellpath, "\\SYSTEM");
     210    CreateDirectoryA(shellpath, NULL);
     211
     212    //AppData
     213    strcpy(shellpath, InternalGetWindowsDirectoryA());
     214    strcat(shellpath, "\\Application Data");
     215    CreateDirectoryA(shellpath, NULL);
     216    RegSetValueExA(hkey,"AppData",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     217    //Cache
     218    strcpy(shellpath, InternalGetWindowsDirectoryA());
     219    strcat(shellpath, "\\Temporary Internet Files");
     220    CreateDirectoryA(shellpath, NULL);
     221    RegSetValueExA(hkey,"Cache",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     222    //Cookies
     223    strcpy(shellpath, InternalGetWindowsDirectoryA());
     224    strcat(shellpath, "\\Cookies");
     225    CreateDirectoryA(shellpath, NULL);
     226    RegSetValueExA(hkey,"Cookies",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     227    //Desktop
     228    strcpy(shellpath, InternalGetWindowsDirectoryA());
     229    strcat(shellpath, "\\Desktop");
     230    CreateDirectoryA(shellpath, NULL);
     231    RegSetValueExA(hkey,"Desktop",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     232    //Favorites
     233    strcpy(shellpath, InternalGetWindowsDirectoryA());
     234    strcat(shellpath, "\\Favorites");
     235    CreateDirectoryA(shellpath, NULL);
     236    RegSetValueExA(hkey,"Favorites",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     237    //Fonts
     238    strcpy(shellpath, InternalGetWindowsDirectoryA());
     239    strcat(shellpath, "\\Fonts");
     240    CreateDirectoryA(shellpath, NULL);
     241    RegSetValueExA(hkey,"Fonts",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     242    //History
     243    strcpy(shellpath, InternalGetWindowsDirectoryA());
     244    strcat(shellpath, "\\History");
     245    CreateDirectoryA(shellpath, NULL);
     246    RegSetValueExA(hkey,"History",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     247    //NetHood
     248    strcpy(shellpath, InternalGetWindowsDirectoryA());
     249    strcat(shellpath, "\\NetHood");
     250    CreateDirectoryA(shellpath, NULL);
     251    RegSetValueExA(hkey,"NetHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     252    //Personal
     253    strcpy(shellpath, InternalGetWindowsDirectoryA());
     254    strcat(shellpath, "\\My Documents");
     255    CreateDirectoryA(shellpath, NULL);
     256    RegSetValueExA(hkey,"Personal",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     257    //PrintHood
     258    strcpy(shellpath, InternalGetWindowsDirectoryA());
     259    strcat(shellpath, "\\PrintHood");
     260    CreateDirectoryA(shellpath, NULL);
     261    RegSetValueExA(hkey,"PrintHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     262    //Recent
     263    strcpy(shellpath, InternalGetWindowsDirectoryA());
     264    strcat(shellpath, "\\Recent");
     265    CreateDirectoryA(shellpath, NULL);
     266    RegSetValueExA(hkey,"Recent",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     267    //SendTo
     268    strcpy(shellpath, InternalGetWindowsDirectoryA());
     269    strcat(shellpath, "\\SendTo");
     270    CreateDirectoryA(shellpath, NULL);
     271    RegSetValueExA(hkey,"SendTo",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     272    //Start Menu
     273    strcpy(shellpath, InternalGetWindowsDirectoryA());
     274    strcat(shellpath, "\\Start Menu");
     275    CreateDirectoryA(shellpath, NULL);
     276    RegSetValueExA(hkey,"Start Menu",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     277    //Programs
     278    strcpy(shellpath, InternalGetWindowsDirectoryA());
     279    strcat(shellpath, "\\Start Menu\\Programs");
     280    CreateDirectoryA(shellpath, NULL);
     281    RegSetValueExA(hkey,"Programs",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     282    //Startup
     283    strcat(shellpath, "\\Startup");
     284    CreateDirectoryA(shellpath, NULL);
     285    RegSetValueExA(hkey,"Startup",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     286    //ShellNew
     287    strcpy(shellpath, InternalGetWindowsDirectoryA());
     288    strcat(shellpath, "\\ShellNew");
     289    CreateDirectoryA(shellpath, NULL);
     290    RegSetValueExA(hkey,"Templates",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    291291//   }
    292292   RegCloseKey(hkey);
     
    299299   //ThreadingModel="Apartment"
    300300   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021400-0000-0000-C000-000000000046}",&hkey)!=ERROR_SUCCESS) {
    301         goto initreg_error;
     301    goto initreg_error;
    302302   }
    303303   RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)CLASS_DESKTOP, sizeof(CLASS_DESKTOP));
    304304   RegCloseKey(hkey);
    305305   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021400-0000-0000-C000-000000000046}\\InProcServer32",&hkey)!=ERROR_SUCCESS) {
    306         goto initreg_error;
     306    goto initreg_error;
    307307   }
    308308   RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)CLASS_SHELL32DLL, sizeof(CLASS_SHELL32DLL));
     
    317317   //@=""
    318318   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021401-0000-0000-C000-000000000046}",&hkey)!=ERROR_SUCCESS) {
    319         goto initreg_error;
     319    goto initreg_error;
    320320   }
    321321   RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)CLASS_SHORTCUT, sizeof(CLASS_SHORTCUT));
    322322   RegCloseKey(hkey);
    323323   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021401-0000-0000-C000-000000000046}\\InProcServer32",&hkey)!=ERROR_SUCCESS) {
    324         goto initreg_error;
     324    goto initreg_error;
    325325   }
    326326   RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)CLASS_SHELL32DLL, sizeof(CLASS_SHELL32DLL));
     
    328328   RegCloseKey(hkey);
    329329   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\CLSID\\{00021401-0000-0000-C000-000000000046}\\shellex\\MayChangeDefaultMenu",&hkey)!=ERROR_SUCCESS) {
    330         goto initreg_error;
     330    goto initreg_error;
    331331   }
    332332   RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)"", 0);
     
    339339   //HKEY_CLASSES_ROOT\CLSID\{D7B70EE0-4340-11CF-B063-0020AFC2CD35}\InprocServer32 = ddraw.dll
    340340   if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectDraw",&hkey)!=ERROR_SUCCESS) {
    341         goto initreg_error;
     341    goto initreg_error;
    342342   }
    343343   RegSetValueExA(hkey, "", 0, REG_SZ, (LPBYTE)DDRAW_DEFAULT, sizeof(DDRAW_DEFAULT));
    344344   if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
    345         RegCloseKey(hkey);
    346         goto initreg_error;
     345    RegCloseKey(hkey);
     346    goto initreg_error;
    347347   }
    348348   RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_CLASSID, sizeof(DDRAW_CLASSID));
     
    351351
    352352   if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DDRAW_CLASSID ,&hkey)!=ERROR_SUCCESS) {
    353         goto initreg_error;
     353    goto initreg_error;
    354354   }
    355355   RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_DEFAULT, sizeof(DDRAW_DEFAULT));
    356356   if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
    357         RegCloseKey(hkey);
    358         goto initreg_error;
     357    RegCloseKey(hkey);
     358    goto initreg_error;
    359359   }
    360360   RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_DLL, sizeof(DDRAW_DLL));
     
    368368   //HKEY_CLASSES_ROOT\CLSID\{593817A0-7DB3-11CF-A2DE-00AA00B93356}\InprocServer32 = ddraw.dll
    369369   if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectDrawClipper",&hkey)!=ERROR_SUCCESS) {
    370         goto initreg_error;
     370    goto initreg_error;
    371371   }
    372372   RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_DEFAULT, sizeof(DDRAW_CLIPPER_DEFAULT));
    373373   if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
    374         RegCloseKey(hkey);
    375         goto initreg_error;
     374    RegCloseKey(hkey);
     375    goto initreg_error;
    376376   }
    377377   RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_CLASSID, sizeof(DDRAW_CLIPPER_CLASSID));
     
    380380
    381381   if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DDRAW_CLIPPER_CLASSID,&hkey)!=ERROR_SUCCESS) {
    382         goto initreg_error;
     382    goto initreg_error;
    383383   }
    384384   RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DDRAW_CLIPPER_DEFAULT, sizeof(DDRAW_CLIPPER_DEFAULT));
    385385   if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
    386         RegCloseKey(hkey);
    387         goto initreg_error;
     386    RegCloseKey(hkey);
     387    goto initreg_error;
    388388   }
    389389   RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DDRAW_DLL, sizeof(DDRAW_DLL));
     
    397397   //HKEY_CLASSES_ROOT\CLSID\{47D4D946-62E8-11cf-93BC-444553540000}\InprocServer32 = dsound.dll
    398398   if(RegCreateKeyA(HKEY_CLASSES_ROOT,"DirectSound",&hkey)!=ERROR_SUCCESS) {
    399         goto initreg_error;
     399    goto initreg_error;
    400400   }
    401401   RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DSOUND_DEFAULT, sizeof(DSOUND_DEFAULT));
    402402   if(RegCreateKeyA(hkey,COM_CLASS_ID,&hkey1)!=ERROR_SUCCESS) {
    403         RegCloseKey(hkey);
    404         goto initreg_error;
     403    RegCloseKey(hkey);
     404    goto initreg_error;
    405405   }
    406406   RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DSOUND_CLASSID, sizeof(DSOUND_CLASSID));
     
    409409
    410410   if(RegCreateKeyA(HKEY_CLASSES_ROOT, COM_CLASS_ID"\\"DSOUND_CLASSID ,&hkey)!=ERROR_SUCCESS) {
    411         goto initreg_error;
     411    goto initreg_error;
    412412   }
    413413   RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DSOUND_DEFAULT, sizeof(DSOUND_DEFAULT));
    414414   if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
    415         RegCloseKey(hkey);
    416         goto initreg_error;
     415    RegCloseKey(hkey);
     416    goto initreg_error;
    417417   }
    418418   RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DSOUND_DLL, sizeof(DSOUND_DLL));
     
    423423   //DirectPlay
    424424   if(RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\CLASSES\\CLSID\\"DPLAYX_CLASSID ,&hkey)!=ERROR_SUCCESS) {
    425         goto initreg_error;
     425    goto initreg_error;
    426426   }
    427427   RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DPLAYX_DEFAULT, sizeof(DPLAYX_DEFAULT));
    428428   if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
    429         RegCloseKey(hkey);
    430         goto initreg_error;
     429    RegCloseKey(hkey);
     430    goto initreg_error;
    431431   }
    432432   RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DPLAYX_DLL, sizeof(DPLAYX_DLL));
     
    437437   //DirectPlay Lobby
    438438   if(RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\CLASSES\\CLSID\\"DPLAYX_LOBBY_CLASSID ,&hkey)!=ERROR_SUCCESS) {
    439         goto initreg_error;
     439    goto initreg_error;
    440440   }
    441441   RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)DPLAYX_LOBBY_DEFAULT, sizeof(DPLAYX_LOBBY_DEFAULT));
    442442   if(RegCreateKeyA(hkey,COM_INPROCSERVER, &hkey1)!=ERROR_SUCCESS) {
    443         RegCloseKey(hkey);
    444         goto initreg_error;
     443    RegCloseKey(hkey);
     444    goto initreg_error;
    445445   }
    446446   RegSetValueExA(hkey1,"",0,REG_SZ, (LPBYTE)DPLAYX_LOBBY_DLL, sizeof(DPLAYX_LOBBY_DLL));
     
    455455   //"SharedDir"="C:\WINDOWS"
    456456   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
    457         goto initreg_error;
     457    goto initreg_error;
    458458   }
    459459   //Create x:\Program Files directory
    460460   strcpy(shellpath, InternalGetWindowsDirectoryA());
    461    shellpath[2] = 0;    //get drive
     461   shellpath[2] = 0;    //get drive
    462462   strcat(shellpath, "\\Program Files");
    463463   CreateDirectoryA(shellpath, NULL);
     
    479479   //"VgaCompatible"="\\Device\\Video1"
    480480   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\VIDEO",&hkey)!=ERROR_SUCCESS) {
    481         goto initreg_error;
     481    goto initreg_error;
    482482   }
    483483   RegSetValueExA(hkey,"\\Device\\Video0",0,REG_SZ, (LPBYTE)HARDWARE_VIDEO_GRADD, sizeof(HARDWARE_VIDEO_GRADD));
     
    487487
    488488   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\Gradd\\Device0",&hkey)!=ERROR_SUCCESS) {
    489         goto initreg_error;
     489    goto initreg_error;
    490490   }
    491491   RegSetValueExA(hkey,"Device Description", 0, REG_SZ, (LPBYTE)HARDWARE_VIDEO_GRADD_DESCRIPTION, sizeof(HARDWARE_VIDEO_GRADD_DESCRIPTION));
     
    493493
    494494   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\VgaSave\\Device0",&hkey)!=ERROR_SUCCESS) {
    495         goto initreg_error;
     495    goto initreg_error;
    496496   }
    497497   RegSetValueExA(hkey,"Device Description", 0, REG_SZ, (LPBYTE)HARDWARE_VIDEO_VGA_DESCRIPTION, sizeof(HARDWARE_VIDEO_VGA_DESCRIPTION));
     
    500500   //Software\Microsoft\Multimedia\Sound Mapper
    501501   if(RegCreateKeyA(HKEY_CURRENT_USER,"Software\\Microsoft\\Multimedia\\Sound Mapper",&hkey)!=ERROR_SUCCESS) {
    502         goto initreg_error;
     502    goto initreg_error;
    503503   }
    504504   RegSetValueExA(hkey,"Playback", 0, REG_SZ, (LPBYTE)ODIN_WINMM_PLAYBACK, sizeof(ODIN_WINMM_PLAYBACK));
     
    506506   RegCloseKey(hkey);
    507507
    508    //Software\Microsoft\DirectX 
     508   //Software\Microsoft\DirectX
    509509   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectX",&hkey)!=ERROR_SUCCESS) {
    510         goto initreg_error;
     510    goto initreg_error;
    511511   }
    512512   RegSetValueExA(hkey,"",0,REG_SZ, (LPBYTE)"", 0);
     
    518518
    519519   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectDraw",&hkey)!=ERROR_SUCCESS) {
    520         goto initreg_error;
     520    goto initreg_error;
    521521   }
    522522   //todo
     
    524524
    525525   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Direct3D",&hkey)!=ERROR_SUCCESS) {
    526         goto initreg_error;
     526    goto initreg_error;
    527527   }
    528528   //todo
     
    530530
    531531   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectPlay",&hkey)!=ERROR_SUCCESS) {
    532         goto initreg_error;
     532    goto initreg_error;
    533533   }
    534534   //todo
     
    537537#if 0
    538538   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\DirectMusic",&hkey)!=ERROR_SUCCESS) {
    539         goto initreg_error;
     539    goto initreg_error;
    540540   }
    541541   //todo
     
    551551
    552552   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\Cdfs",&hkey)!=ERROR_SUCCESS) {
    553         goto initreg_error;
     553    goto initreg_error;
    554554   }
    555555   val = 0x2;
     
    580580
    581581   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\Cdrom",&hkey)!=ERROR_SUCCESS) {
    582         goto initreg_error;
     582    goto initreg_error;
    583583   }
    584584   val = 0x1;
     
    608608   //"Win95TruncatedExtensions"=dword:00000001
    609609   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\FileSystem",&hkey)!=ERROR_SUCCESS) {
    610         goto initreg_error;
     610    goto initreg_error;
    611611   }
    612612   val = 0x0;
     
    654654 DWORD signature;
    655655
    656    SetEnvironmentVariableA("CPU", "i386");
    657    SetEnvironmentVariableA("PROCESSOR_ARCHITECTURE", "x86");
    658    if(SupportsCPUID()) {
    659         GetCPUVendorString(buffer1);
    660         buffer1[12] = 0;       
    661         signature = GetCPUSignature();
    662         sprintf(buffer, "x86 Family %x Model %x Stepping %x, %s", (signature >> 8)&0xf, signature & 0xf, (signature >> 4)&0xf, buffer1);
    663         SetEnvironmentVariableA("PROCESSOR_IDENTIFIER", buffer);
    664         sprintf(buffer, "%x", (signature >> 8)&0xf);
    665         SetEnvironmentVariableA("PROCESSOR_LEVEL", buffer);
    666         sprintf(buffer, "%02x%02x", (signature >> 4)&0xf, signature & 0xf);
    667         SetEnvironmentVariableA("PROCESSOR_REVISION", buffer);
    668    }
    669    sprintf(buffer, "%d", nrcpus);
    670    SetEnvironmentVariableA("NUMBER_OF_PROCESSORS", buffer);
    671    SetEnvironmentVariableA("OS", "Windows_NT");
    672    SetEnvironmentVariableA("PATHEXT", ".COM;.EXE;.BAT;.CMD");
    673    windir = InternalGetWindowsDirectoryA();
    674    SetEnvironmentVariableA("windir", windir);
    675    SetEnvironmentVariableA("SystemRoot", windir);
    676    buffer[0] = windir[0];
    677    buffer[1] = windir[1];
    678    buffer[2] = 0;
    679    SetEnvironmentVariableA("SystemDrive", buffer);
    680    SetEnvironmentVariableA("HOMEDRIVE", buffer);
    681    SetEnvironmentVariableA("HOMEPATH", "\\");
    682 
    683 //TODO:
    684 //COMPUTERNAME=NTBAK
    685 //ComSpec=E:\WINNT\system32\cmd.exe
    686 //LOGONSERVER=\\NTBAK
    687 //USERDOMAIN=NTBAK
    688 //USERNAME=Sander
    689 //USERPROFILE=E:\WINNT\Profiles\Sander
     656    SetEnvironmentVariableA("CPU", "i386");
     657    SetEnvironmentVariableA("PROCESSOR_ARCHITECTURE", "x86");
     658    if(SupportsCPUID()) {
     659        GetCPUVendorString(buffer1);
     660        buffer1[12] = 0;
     661        signature = GetCPUSignature();
     662        sprintf(buffer, "x86 Family %x Model %x Stepping %x, %s", (signature >> 8)&0xf, signature & 0xf, (signature >> 4)&0xf, buffer1);
     663        SetEnvironmentVariableA("PROCESSOR_IDENTIFIER", buffer);
     664        sprintf(buffer, "%x", (signature >> 8)&0xf);
     665        SetEnvironmentVariableA("PROCESSOR_LEVEL", buffer);
     666        sprintf(buffer, "%02x%02x", (signature >> 4)&0xf, signature & 0xf);
     667        SetEnvironmentVariableA("PROCESSOR_REVISION", buffer);
     668    }
     669    sprintf(buffer, "%d", nrcpus);
     670    SetEnvironmentVariableA("NUMBER_OF_PROCESSORS", buffer);
     671    SetEnvironmentVariableA("OS", "Windows_NT");
     672    SetEnvironmentVariableA("PATHEXT", ".COM;.EXE;.BAT;.CMD");
     673    windir = InternalGetWindowsDirectoryA();
     674    SetEnvironmentVariableA("windir", windir);
     675    SetEnvironmentVariableA("SystemRoot", windir);
     676    buffer[0] = windir[0];
     677    buffer[1] = windir[1];
     678    buffer[2] = 0;
     679    SetEnvironmentVariableA("SystemDrive", buffer);
     680    SetEnvironmentVariableA("HOMEDRIVE", buffer);
     681    SetEnvironmentVariableA("HOMEPATH", "\\");
     682
     683    //TODO:
     684    //COMPUTERNAME=NTBAK
     685    //ComSpec=E:\WINNT\system32\cmd.exe
     686    //LOGONSERVER=\\NTBAK
     687    //USERDOMAIN=NTBAK
     688    //USERNAME=Sander
     689    //USERPROFILE=E:\WINNT\Profiles\Sander
    690690}
     691//******************************************************************************
     692//Create/change keys that may change (i.e. odin.ini keys that affect windows version)
     693//******************************************************************************
     694void InitDynamicRegistry()
     695{
     696 OSVERSIONINFOA versioninfo;
     697 HKEY           hkey;
     698 char           buf[16] = "";
     699
     700    versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
     701    GetVersionExA(&versioninfo);
     702
     703    //Set version key:
     704    // [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions]
     705    // "ProductType"="WinNT"
     706    if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",&hkey)!=ERROR_SUCCESS) {
     707        dprintf(("InitRegistry: Unable to register system information (2)"));
     708            return;
     709    }
     710    switch(versioninfo.dwPlatformId) {
     711    case VER_PLATFORM_WIN32_WINDOWS:
     712        strcpy(buf, "Win98");    //TODO: Correct???????????
     713        break;
     714    case VER_PLATFORM_WIN32_NT:
     715        strcpy(buf, "WinNT");   //TODO: Also correct for Windows 2000???
     716        break;
     717    default:
     718        DebugInt3();
     719        break;
     720    }
     721    RegSetValueExA(hkey,"ProductType",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
     722    RegCloseKey(hkey);
     723}
     724//******************************************************************************
     725//******************************************************************************
     726
  • trunk/src/kernel32/initterm.cpp

    r4474 r4510  
    1 /* $Id: initterm.cpp,v 1.48 2000-10-10 17:14:04 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.49 2000-10-21 14:30:47 sandervl Exp $ */
    22
    33/*
     
    183183            //Set up environment as found in NT
    184184            InitEnvironment(ulSysinfo);
     185
     186            //InitDynamicRegistry creates/changes keys that may change (i.e. odin.ini
     187            //keys that affect windows version)
     188            InitDynamicRegistry();
    185189            break;
    186190        }
  • trunk/src/kernel32/initterm.h

    r3740 r4510  
    1 /* $Id: initterm.h,v 1.5 2000-06-21 20:51:52 sandervl Exp $ */
     1/* $Id: initterm.h,v 1.6 2000-10-21 14:30:47 sandervl Exp $ */
    22/*
    33 * KERNEL32 DLL entry point header
     
    3939void InitEnvironment(int nrcpus); //initsystem.cpp
    4040
     41//InitDynamicRegistry creates/changes keys that may change (i.e. odin.ini
     42//keys that affect windows version)
     43void InitDynamicRegistry();       //initsystem.cpp
     44
    4145#endif
  • trunk/src/kernel32/registry.cpp

    r4496 r4510  
    1 /* $Id: registry.cpp,v 1.5 2000-10-18 17:09:33 sandervl Exp $ */
     1/* $Id: registry.cpp,v 1.6 2000-10-21 14:30:47 sandervl Exp $ */
    22
    33/*
     
    3030#include "unicode.h"
    3131#include <winreg.h>
    32 
    33 #define DBG_LOCALLOG    DBG_registry
     32#include <heapstring.h>
     33
     34#define DBG_LOCALLOG    DBG_registry
    3435#include "dbglocal.h"
    3536
     
    644645  LONG  rc;
    645646
    646   rc = CALL_ODINFUNC(RegOpenKeyExA)(ConvertKey(arg1),
     647  rc = CALL_ODINFUNC(RegOpenKeyExA)(arg1,
    647648                                    astring,
    648649                                    arg3,
     
    741742  if(rc == ERROR_SUCCESS)
    742743  {
    743         if(*arg3) {
    744                 astring = (char *)malloc(*arg3);
    745                 strcpy(astring, (char *)arg2);
    746                 AsciiToUnicode(astring, arg2);
    747                 free(astring);
    748         }
    749         else    *arg2 = 0;
     744    if(*arg3) {
     745            astring = (char *)malloc(*arg3);
     746        strcpy(astring, (char *)arg2);
     747            AsciiToUnicode(astring, arg2);
     748            free(astring);
     749    }
     750    else    *arg2 = 0;
    750751  }
    751752  return(rc);
     
    800801  LONG  rc;
    801802
    802   rc = CALL_ODINFUNC(RegQueryValueA)(ConvertKey(hkey),
     803  rc = CALL_ODINFUNC(RegQueryValueA)(hkey,
    803804                                     astring1,
    804805                                     (char *)lpszValue,
     
    806807  if(rc == ERROR_SUCCESS)
    807808  {
    808         if(pcbValue) {
    809                 astring2 = (char *)malloc(*pcbValue);
    810                 strcpy(astring2, (char *)lpszValue);
    811                 AsciiToUnicode(astring2, lpszValue);
    812                 free(astring2);
    813         }
     809    if(pcbValue) {
     810            astring2 = (char *)malloc(*pcbValue);
     811            strcpy(astring2, (char *)lpszValue);
     812            AsciiToUnicode(astring2, lpszValue);
     813            free(astring2);
     814    }
    814815  }
    815816  FreeAsciiString(astring1);
     
    830831 *****************************************************************************/
    831832
    832 ODINFUNCTION6(LONG,RegQueryValueExA,HKEY,   arg1,
    833                                     LPSTR,  arg2,
    834                                     LPDWORD,arg3,
    835                                     LPDWORD,arg4,
    836                                     LPBYTE, arg5,
    837                                     LPDWORD,arg6)
    838 {
    839   dprintf(("ADVAPI32:Registry key=%s", arg2));
    840 
    841   return O32_RegQueryValueEx(ConvertKey(arg1),
    842                              arg2,
    843                              arg3,
    844                              arg4,
    845                              arg5,
    846                              arg6);
     833ODINFUNCTION6(LONG,RegQueryValueExA,HKEY,   hkey,
     834                                    LPSTR,  lpszValueName,
     835                                    LPDWORD,lpdwType,
     836                                    LPDWORD,lpdwReserved,
     837                                    LPBYTE, lpbData,
     838                                    LPDWORD,lpcbData)
     839{
     840  dprintf(("ADVAPI32:Registry key=%s", lpszValueName));
     841
     842  return O32_RegQueryValueEx(ConvertKey(hkey),
     843                             lpszValueName,
     844                             lpdwType,
     845                             lpdwReserved,
     846                             lpbData,
     847                             lpcbData);
    847848}
    848849
     
    860861 *****************************************************************************/
    861862
    862 ODINFUNCTION6(LONG,RegQueryValueExW,HKEY,   arg1,
    863                                     LPWSTR, arg2,
    864                                     LPDWORD,arg3,
    865                                     LPDWORD,arg4,
    866                                     LPBYTE, arg5,
    867                                     LPDWORD,arg6)
    868 {
    869   char *astring = UnicodeToAsciiString(arg2);
     863ODINFUNCTION6(LONG,RegQueryValueExW,HKEY,   hkey,
     864                                    LPWSTR, lpszValueName,
     865                                    LPDWORD,lpdwType,
     866                                    LPDWORD,lpdwReserved,
     867                                    LPBYTE, lpbData,
     868                                    LPDWORD,lpcbData)
     869{
     870  char *astring = UnicodeToAsciiString(lpszValueName);
     871  char *akeydata = NULL;
    870872  LONG  rc;
    871873
    872   rc = CALL_ODINFUNC(RegQueryValueExA)(ConvertKey(arg1),
     874  if(lpbData && lpcbData)
     875  {
     876    akeydata = (char *)malloc(*lpcbData+1);
     877    akeydata[*lpcbData] = 0;
     878  }
     879
     880  rc = CALL_ODINFUNC(RegQueryValueExA)(hkey,
    873881                                       astring,
    874                                        arg3,
    875                                        arg4,
    876                                        arg5,
    877                                        arg6);
     882                                       lpdwType,
     883                                       lpdwReserved,
     884                                       (LPBYTE)akeydata,
     885                                       lpcbData);
     886  //could also query key type (without returning data), call it again and only allocate translation
     887  //buffer if string type
     888  if(rc == ERROR_SUCCESS && lpbData && lpcbData)
     889  {
     890    if(lpdwType == NULL) {//NULL apparently means REG_SZ
     891        lstrcpyAtoW((LPWSTR)lpcbData, akeydata);
     892    }
     893    else {
     894        switch(*lpdwType) {
     895        case REG_SZ:
     896        case REG_EXPAND_SZ:
     897            lstrcpyAtoW((LPWSTR)lpcbData, akeydata);
     898            break;
     899        case REG_MULTI_SZ:
     900        case REG_LINK: //???
     901            dprintf(("ERROR: key data must be translated from Unicode to Ascii!!"));
     902            break;
     903        default:
     904            memcpy(lpbData, akeydata, *lpcbData);
     905            break;
     906        }
     907    }
     908  }
    878909  FreeAsciiString(astring);
     910  if(akeydata) {
     911    free(akeydata);
     912  }
    879913  return(rc);
    880914}
     
    910944                         lpData,
    911945                         cbData);
    912   if(rc == ERROR_NOT_ENOUGH_MEMORY && cbData == 0 && dwType == REG_SZ) 
     946  if(rc == ERROR_NOT_ENOUGH_MEMORY && cbData == 0 && dwType == REG_SZ)
    913947  {
    914948    char regdata = 0;
    915         //SvL: Netscape sets an empty string key this way; Open32 doesn't like it
    916         rc = O32_RegSetValue(ConvertKey(hkey),
     949    //SvL: Netscape sets an empty string key this way; Open32 doesn't like it
     950    rc = O32_RegSetValue(ConvertKey(hkey),
    917951                         lpSubKey,
    918952                         dwType,
     
    946980  LONG  rc;
    947981
    948   //SvL: 8-11-'97: Bugfix: crash in pmwinx if size == 0 and string is large
    949   if(cbData == 0)
    950     cbData = strlen(astring2);
    951 
    952   rc = O32_RegSetValue(ConvertKey(hkey),
    953                        astring1,
    954                        dwType,
    955                        astring2,
    956                        cbData);
     982  rc = CALL_ODINFUNC(RegSetValueA)(hkey,
     983                                   astring1,
     984                                   dwType,
     985                                   astring2,
     986                                   cbData);
    957987
    958988  FreeAsciiString(astring1);
     
    9741004 *****************************************************************************/
    9751005
    976 ODINFUNCTION6(LONG,RegSetValueExA,HKEY,  arg1,
    977                                   LPSTR, arg2,
    978                                   DWORD, arg3,
    979                                   DWORD, arg4,
    980                                   BYTE*, arg5,
    981                                   DWORD, arg6)
    982 {
    983   return O32_RegSetValueEx(ConvertKey(arg1),
    984                            arg2,
    985                            arg3,
    986                            arg4,
    987                            arg5,
    988                            arg6);
     1006ODINFUNCTION6(LONG,RegSetValueExA,HKEY,  hkey,
     1007                                  LPSTR, lpszValueName,
     1008                                  DWORD, dwReserved,
     1009                                  DWORD, fdwType,
     1010                                  BYTE*, lpbData,
     1011                                  DWORD, cbData)
     1012{
     1013  if(fdwType == REG_SZ) {
     1014    dprintf(("ADVAPI32: RegSetValueExA)%08xh,%s,%08xh,%08xh,%s,%08xh)",
     1015               hkey,
     1016               lpszValueName,
     1017               dwReserved,
     1018               fdwType,
     1019               lpbData,
     1020               cbData));
     1021  }
     1022  else {
     1023    dprintf(("ADVAPI32: RegSetValueExA)%08xh,%s,%08xh,%08xh,%08xh,%08xh)",
     1024               hkey,
     1025               lpszValueName,
     1026               dwReserved,
     1027               fdwType,
     1028               lpbData,
     1029               cbData));
     1030  }
     1031
     1032  return O32_RegSetValueEx(ConvertKey(hkey),
     1033                           lpszValueName,
     1034                           dwReserved,
     1035                           fdwType,
     1036                           lpbData,
     1037                           cbData);
    9891038}
    9901039
     
    10021051 *****************************************************************************/
    10031052
    1004 ODINFUNCTION6(LONG,RegSetValueExW,HKEY,  arg1,
    1005                                    LPWSTR,arg2,
    1006                                    DWORD, arg3,
    1007                                    DWORD, arg4,
    1008                                    BYTE*, arg5,
    1009                                    DWORD, arg6)
    1010 {
    1011   char *astring = UnicodeToAsciiString(arg2);
     1053ODINFUNCTION6(LONG,RegSetValueExW,HKEY,  hkey,
     1054                                  LPWSTR,lpszValueName,
     1055                                  DWORD, dwReserved,
     1056                                  DWORD, fdwType,
     1057                                  BYTE*, lpbData,
     1058                                  DWORD, cbData)
     1059{
     1060  char *astring = UnicodeToAsciiString(lpszValueName);
     1061  char *akeydata = NULL;
    10121062  LONG  rc;
    10131063
    1014   dprintf(("ADVAPI32: RegSetValueExW(%08xh,%s,%08xh,%08xh,%08xh,%08xh)\n",
    1015            arg1,
    1016            astring,
    1017            arg3,
    1018            arg4,
    1019            arg5,
    1020            arg6));
    1021 
    1022   rc = O32_RegSetValueEx(ConvertKey(arg1),
    1023                          astring,
    1024                          arg3,
    1025                          arg4,
    1026                          arg5,
    1027                          arg6);
     1064  switch(fdwType) {
     1065  case REG_SZ:
     1066  case REG_EXPAND_SZ:
     1067        akeydata = UnicodeToAsciiString((LPWSTR)lpbData);
     1068        lpbData = (BYTE *)akeydata;
     1069        break;
     1070  case REG_MULTI_SZ:
     1071  case REG_LINK: //???
     1072        dprintf(("ERROR: key data must be translated from Unicode to Ascii!!"));
     1073        break;
     1074  }
     1075  rc = CALL_ODINFUNC(RegSetValueExA)(hkey,
     1076                                     astring,
     1077                                     dwReserved,
     1078                                     fdwType,
     1079                                     lpbData,
     1080                                     cbData);
     1081  if(akeydata)
     1082    FreeAsciiString(akeydata);
     1083
    10281084  FreeAsciiString(astring);
    10291085  return(rc);
Note: See TracChangeset for help on using the changeset viewer.