ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

registry.c
Go to the documentation of this file.
00001 /*
00002  *  ReactOS kernel
00003  *  Copyright (C) 2006 ReactOS Team
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License along
00016  *  with this program; if not, write to the Free Software Foundation, Inc.,
00017  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 /* COPYRIGHT:       See COPYING in the top level directory
00020  * PROJECT:         ReactOS hive maker
00021  * FILE:            tools/mkhive/registry.c
00022  * PURPOSE:         Registry code
00023  * PROGRAMMER:      Hervé Poussineau
00024  */
00025 
00026 /*
00027  * TODO:
00028  *  - Implement RegDeleteKeyW()
00029  *  - Implement RegEnumValue()
00030  *  - Implement RegQueryValueExW()
00031  */
00032 
00033 #include <stdlib.h>
00034 #include <string.h>
00035 #include <stdio.h>
00036 
00037 #define NDEBUG
00038 #include "mkhive.h"
00039 
00040 #define REG_DATA_SIZE_MASK                 0x7FFFFFFF
00041 #define REG_DATA_IN_OFFSET                 0x80000000
00042 
00043 static CMHIVE RootHive;
00044 static MEMKEY RootKey;
00045 CMHIVE DefaultHive;  /* \Registry\User\.DEFAULT */
00046 CMHIVE SamHive;      /* \Registry\Machine\SAM */
00047 CMHIVE SecurityHive; /* \Registry\Machine\SECURITY */
00048 CMHIVE SoftwareHive; /* \Registry\Machine\SOFTWARE */
00049 CMHIVE SystemHive;   /* \Registry\Machine\SYSTEM */
00050 
00051 static MEMKEY
00052 CreateInMemoryStructure(
00053     IN PCMHIVE RegistryHive,
00054     IN HCELL_INDEX KeyCellOffset,
00055     IN PCUNICODE_STRING KeyName)
00056 {
00057     MEMKEY Key;
00058 
00059     Key = (MEMKEY) malloc (sizeof(KEY));
00060     if (!Key)
00061         return NULL;
00062 
00063     InitializeListHead (&Key->SubKeyList);
00064     InitializeListHead (&Key->ValueList);
00065     InitializeListHead (&Key->KeyList);
00066 
00067     Key->SubKeyCount = 0;
00068     Key->ValueCount = 0;
00069 
00070     Key->NameSize = KeyName->Length;
00071     /* FIXME: It's not enough to allocate this way, because later
00072               this memory gets overwritten with bigger names */
00073     Key->Name = malloc (Key->NameSize);
00074     if (!Key->Name)
00075         return NULL;
00076     memcpy(Key->Name, KeyName->Buffer, KeyName->Length);
00077 
00078     Key->DataType = 0;
00079     Key->DataSize = 0;
00080     Key->Data = NULL;
00081 
00082     Key->RegistryHive = RegistryHive;
00083     Key->KeyCellOffset = KeyCellOffset;
00084     Key->KeyCell = (PCM_KEY_NODE)HvGetCell (&RegistryHive->Hive, Key->KeyCellOffset);
00085     if (!Key->KeyCell)
00086     {
00087         free(Key->Name);
00088         free(Key);
00089         return NULL;
00090     }
00091     Key->LinkedKey = NULL;
00092     return Key;
00093 }
00094 
00095 static LONG
00096 RegpOpenOrCreateKey(
00097     IN HKEY hParentKey,
00098     IN PCWSTR KeyName,
00099     IN BOOL AllowCreation,
00100     OUT PHKEY Key)
00101 {
00102     PWSTR LocalKeyName;
00103     PWSTR End;
00104     UNICODE_STRING KeyString;
00105     NTSTATUS Status;
00106     MEMKEY ParentKey;
00107     MEMKEY CurrentKey;
00108     PLIST_ENTRY Ptr;
00109     PCM_KEY_NODE SubKeyCell;
00110     HCELL_INDEX BlockOffset;
00111 
00112     DPRINT("RegpCreateOpenKey('%S')\n", KeyName);
00113 
00114     if (*KeyName == L'\\')
00115     {
00116         KeyName++;
00117         ParentKey = RootKey;
00118     }
00119     else if (hParentKey == NULL)
00120     {
00121         ParentKey = RootKey;
00122     }
00123     else
00124     {
00125         ParentKey = HKEY_TO_MEMKEY(RootKey);
00126     }
00127 
00128     LocalKeyName = (PWSTR)KeyName;
00129     for (;;)
00130     {
00131         End = (PWSTR)strchrW(LocalKeyName, '\\');
00132         if (End)
00133         {
00134             KeyString.Buffer = LocalKeyName;
00135             KeyString.Length = KeyString.MaximumLength =
00136                 (USHORT)((ULONG_PTR)End - (ULONG_PTR)LocalKeyName);
00137         }
00138         else
00139             RtlInitUnicodeString(&KeyString, LocalKeyName);
00140 
00141         /* Redirect from 'CurrentControlSet' to 'ControlSet001' */
00142         if (!strncmpW(LocalKeyName, L"CurrentControlSet", 17) &&
00143             ParentKey->NameSize == 12 &&
00144             !memcmp(ParentKey->Name, L"SYSTEM", 12))
00145             RtlInitUnicodeString(&KeyString, L"ControlSet001");
00146 
00147         /* Check subkey in memory structure */
00148         Ptr = ParentKey->SubKeyList.Flink;
00149         while (Ptr != &ParentKey->SubKeyList)
00150         {
00151             CurrentKey = CONTAINING_RECORD(Ptr, KEY, KeyList);
00152             if (CurrentKey->NameSize == KeyString.Length
00153              && memcmp(CurrentKey->Name, KeyString.Buffer, KeyString.Length) == 0)
00154             {
00155                 goto nextsubkey;
00156             }
00157 
00158             Ptr = Ptr->Flink;
00159         }
00160 
00161         Status = CmiScanForSubKey(
00162             ParentKey->RegistryHive,
00163             ParentKey->KeyCell,
00164             &KeyString,
00165             OBJ_CASE_INSENSITIVE,
00166             &SubKeyCell,
00167             &BlockOffset);
00168         if (AllowCreation && Status == STATUS_OBJECT_NAME_NOT_FOUND)
00169         {
00170             Status = CmiAddSubKey(
00171                 ParentKey->RegistryHive,
00172                 ParentKey->KeyCell,
00173                 ParentKey->KeyCellOffset,
00174                 &KeyString,
00175                 0,
00176                 &SubKeyCell,
00177                 &BlockOffset);
00178         }
00179         if (!NT_SUCCESS(Status))
00180             return ERROR_UNSUCCESSFUL;
00181 
00182         /* Now, SubKeyCell/BlockOffset are valid */
00183         CurrentKey = CreateInMemoryStructure(
00184             ParentKey->RegistryHive,
00185             BlockOffset,
00186             &KeyString);
00187         if (!CurrentKey)
00188             return ERROR_OUTOFMEMORY;
00189 
00190         /* Add CurrentKey in ParentKey */
00191         InsertTailList(&ParentKey->SubKeyList, &CurrentKey->KeyList);
00192         ParentKey->SubKeyCount++;
00193 
00194 nextsubkey:
00195         ParentKey = CurrentKey;
00196         if (End)
00197             LocalKeyName = End + 1;
00198         else
00199             break;
00200     }
00201 
00202     *Key = MEMKEY_TO_HKEY(ParentKey);
00203 
00204     return ERROR_SUCCESS;
00205 }
00206 
00207 LONG WINAPI
00208 RegCreateKeyW(
00209     IN HKEY hKey,
00210     IN LPCWSTR lpSubKey,
00211     OUT PHKEY phkResult)
00212 {
00213     return RegpOpenOrCreateKey(hKey, lpSubKey, TRUE, phkResult);
00214 }
00215 
00216 static PWSTR
00217 MultiByteToWideChar(
00218     IN PCSTR MultiByteString)
00219 {
00220     ANSI_STRING Source;
00221     UNICODE_STRING Destination;
00222     NTSTATUS Status;
00223 
00224     RtlInitAnsiString(&Source, MultiByteString);
00225     Status = RtlAnsiStringToUnicodeString(&Destination, &Source, TRUE);
00226     if (!NT_SUCCESS(Status))
00227         return NULL;
00228     return Destination.Buffer;
00229 }
00230 
00231 LONG WINAPI
00232 RegCreateKeyA(
00233     IN HKEY hKey,
00234     IN LPCSTR lpSubKey,
00235     OUT PHKEY phkResult)
00236 {
00237     PWSTR lpSubKeyW;
00238     LONG rc;
00239 
00240     lpSubKeyW = MultiByteToWideChar(lpSubKey);
00241     if (!lpSubKeyW)
00242         return ERROR_OUTOFMEMORY;
00243 
00244     rc = RegCreateKeyW(hKey, lpSubKeyW, phkResult);
00245     free(lpSubKeyW);
00246     return rc;
00247 }
00248 
00249 LONG WINAPI
00250 RegDeleteKeyW(
00251     IN HKEY hKey,
00252     IN LPCWSTR lpSubKey)
00253 {
00254     DPRINT1("FIXME: implement RegDeleteKeyW!\n");
00255     return ERROR_SUCCESS;
00256 }
00257 
00258 LONG WINAPI
00259 RegDeleteKeyA(
00260     IN HKEY hKey,
00261     IN LPCSTR lpSubKey)
00262 {
00263     PWSTR lpSubKeyW = NULL;
00264     LONG rc;
00265 
00266     if (lpSubKey != NULL && strchr(lpSubKey, '\\') != NULL)
00267         return ERROR_INVALID_PARAMETER;
00268 
00269     if (lpSubKey)
00270     {
00271         lpSubKeyW = MultiByteToWideChar(lpSubKey);
00272         if (!lpSubKeyW)
00273             return ERROR_OUTOFMEMORY;
00274     }
00275 
00276     rc = RegDeleteKeyW(hKey, lpSubKeyW);
00277 
00278     if (lpSubKey)
00279         free(lpSubKeyW);
00280 
00281     return rc;
00282 }
00283 
00284 LONG WINAPI
00285 RegOpenKeyW(
00286     IN HKEY hKey,
00287     IN LPCWSTR lpSubKey,
00288     OUT PHKEY phkResult)
00289 {
00290     return RegpOpenOrCreateKey(hKey, lpSubKey, FALSE, phkResult);
00291 }
00292 
00293 LONG WINAPI
00294 RegOpenKeyA(
00295     IN HKEY hKey,
00296     IN LPCSTR lpSubKey,
00297     OUT PHKEY phkResult)
00298 {
00299     PWSTR lpSubKeyW;
00300     LONG rc;
00301 
00302     lpSubKeyW = MultiByteToWideChar(lpSubKey);
00303     if (!lpSubKeyW)
00304         return ERROR_OUTOFMEMORY;
00305 
00306     rc = RegOpenKeyW(hKey, lpSubKeyW, phkResult);
00307     free(lpSubKeyW);
00308     return rc;
00309 }
00310 
00311 static LONG
00312 RegpOpenOrCreateValue(
00313     IN HKEY hKey,
00314     IN LPCWSTR ValueName,
00315     IN BOOL AllowCreation,
00316     OUT PCM_KEY_VALUE *ValueCell,
00317     OUT PHCELL_INDEX ValueCellOffset)
00318 {
00319     MEMKEY ParentKey;
00320     UNICODE_STRING ValueString;
00321     NTSTATUS Status;
00322 
00323     ParentKey = HKEY_TO_MEMKEY(hKey);
00324     RtlInitUnicodeString(&ValueString, ValueName);
00325 
00326     Status = CmiScanForValueKey(
00327         ParentKey->RegistryHive,
00328         ParentKey->KeyCell,
00329         &ValueString,
00330         ValueCell,
00331         ValueCellOffset);
00332     if (AllowCreation && Status == STATUS_OBJECT_NAME_NOT_FOUND)
00333     {
00334         Status = CmiAddValueKey(
00335             ParentKey->RegistryHive,
00336             ParentKey->KeyCell,
00337             ParentKey->KeyCellOffset,
00338             &ValueString,
00339             ValueCell,
00340             ValueCellOffset);
00341     }
00342     if (!NT_SUCCESS(Status))
00343         return ERROR_UNSUCCESSFUL;
00344     return ERROR_SUCCESS;
00345 }
00346 
00347 LONG WINAPI
00348 RegSetValueExW(
00349     IN HKEY hKey,
00350     IN LPCWSTR lpValueName OPTIONAL,
00351     IN ULONG Reserved,
00352     IN ULONG dwType,
00353     IN const UCHAR* lpData,
00354     IN USHORT cbData)
00355 {
00356     MEMKEY Key, DestKey;
00357     PHKEY phKey;
00358     PCM_KEY_VALUE ValueCell;
00359     HCELL_INDEX ValueCellOffset;
00360     PVOID DataCell;
00361     LONG DataCellSize;
00362     NTSTATUS Status;
00363 
00364     if (dwType == REG_LINK)
00365     {
00366         /* Special handling of registry links */
00367         if (cbData != sizeof(PVOID))
00368             return STATUS_INVALID_PARAMETER;
00369         phKey = (PHKEY)lpData;
00370         Key = HKEY_TO_MEMKEY(hKey);
00371         DestKey = HKEY_TO_MEMKEY(*phKey);
00372 
00373         /* Create the link in memory */
00374         Key->DataType = REG_LINK;
00375         Key->LinkedKey = DestKey;
00376 
00377         /* Create the link in registry hive (if applicable) */
00378         if (Key->RegistryHive != DestKey->RegistryHive)
00379             return STATUS_SUCCESS;
00380         DPRINT1("Save link to registry\n");
00381         return STATUS_NOT_IMPLEMENTED;
00382     }
00383 
00384     if ((cbData & REG_DATA_SIZE_MASK) != cbData)
00385         return STATUS_UNSUCCESSFUL;
00386 
00387     Key = HKEY_TO_MEMKEY(hKey);
00388 
00389     Status = RegpOpenOrCreateValue(hKey, lpValueName, TRUE, &ValueCell, &ValueCellOffset);
00390     if (!NT_SUCCESS(Status))
00391         return ERROR_UNSUCCESSFUL;
00392 
00393     /* Get size of the allocated cellule (if any) */
00394     if (!(ValueCell->DataLength & REG_DATA_IN_OFFSET) &&
00395         (ValueCell->DataLength & REG_DATA_SIZE_MASK) != 0)
00396     {
00397         DataCell = HvGetCell(&Key->RegistryHive->Hive, ValueCell->Data);
00398         if (!DataCell)
00399             return ERROR_UNSUCCESSFUL;
00400         DataCellSize = -HvGetCellSize(&Key->RegistryHive->Hive, DataCell);
00401     }
00402     else
00403     {
00404         DataCell = NULL;
00405         DataCellSize = 0;
00406     }
00407 
00408     if (cbData <= sizeof(HCELL_INDEX))
00409     {
00410         /* If data size <= sizeof(HCELL_INDEX) then store data in the data offset */
00411         DPRINT("ValueCell->DataLength %u\n", ValueCell->DataLength);
00412         if (DataCell)
00413             HvFreeCell(&Key->RegistryHive->Hive, ValueCell->Data);
00414 
00415         RtlCopyMemory(&ValueCell->Data, lpData, cbData);
00416         ValueCell->DataLength = (ULONG)(cbData | REG_DATA_IN_OFFSET);
00417         ValueCell->Type = dwType;
00418         HvMarkCellDirty(&Key->RegistryHive->Hive, ValueCellOffset, FALSE);
00419     }
00420     else
00421     {
00422         if (cbData > (SIZE_T)DataCellSize)
00423         {
00424             /* New data size is larger than the current, destroy current
00425              * data block and allocate a new one. */
00426             HCELL_INDEX NewOffset;
00427 
00428             DPRINT("ValueCell->DataLength %u\n", ValueCell->DataLength);
00429 
00430             NewOffset = HvAllocateCell(&Key->RegistryHive->Hive, cbData, Stable, HCELL_NIL);
00431             if (NewOffset == HCELL_NIL)
00432             {
00433                 DPRINT("HvAllocateCell() failed with status 0x%08x\n", Status);
00434                 return ERROR_UNSUCCESSFUL;
00435             }
00436 
00437             if (DataCell)
00438                 HvFreeCell(&Key->RegistryHive->Hive, ValueCell->Data);
00439 
00440             ValueCell->Data = NewOffset;
00441             DataCell = (PVOID)HvGetCell(&Key->RegistryHive->Hive, NewOffset);
00442         }
00443 
00444         /* Copy new contents to cellule */
00445         RtlCopyMemory(DataCell, lpData, cbData);
00446         ValueCell->DataLength = (ULONG)(cbData & REG_DATA_SIZE_MASK);
00447         ValueCell->Type = dwType;
00448         HvMarkCellDirty(&Key->RegistryHive->Hive, ValueCell->Data, FALSE);
00449         HvMarkCellDirty(&Key->RegistryHive->Hive, ValueCellOffset, FALSE);
00450     }
00451 
00452     if (cbData > Key->KeyCell->MaxValueDataLen)
00453         Key->KeyCell->MaxValueDataLen = cbData;
00454 
00455     HvMarkCellDirty(&Key->RegistryHive->Hive, Key->KeyCellOffset, FALSE);
00456 
00457     DPRINT("Return status 0x%08x\n", Status);
00458     return Status;
00459 }
00460 
00461 LONG WINAPI
00462 RegSetValueExA(
00463     IN HKEY hKey,
00464     IN LPCSTR lpValueName OPTIONAL,
00465     IN ULONG Reserved,
00466     IN ULONG dwType,
00467     IN const UCHAR* lpData,
00468     IN ULONG cbData)
00469 {
00470     LPWSTR lpValueNameW = NULL;
00471     const UCHAR* lpDataW;
00472     USHORT cbDataW;
00473     LONG rc = ERROR_SUCCESS;
00474 
00475     DPRINT("RegSetValueA(%s)\n", lpValueName);
00476     if (lpValueName)
00477     {
00478         lpValueNameW = MultiByteToWideChar(lpValueName);
00479         if (!lpValueNameW)
00480             return ERROR_OUTOFMEMORY;
00481     }
00482 
00483     if ((dwType == REG_SZ || dwType == REG_EXPAND_SZ || dwType == REG_MULTI_SZ)
00484      && cbData != 0)
00485     {
00486         ANSI_STRING AnsiString;
00487         UNICODE_STRING Data;
00488 
00489         if (lpData[cbData - 1] != '\0')
00490             cbData++;
00491         RtlInitAnsiString(&AnsiString, NULL);
00492         AnsiString.Buffer = (PSTR)lpData;
00493         AnsiString.Length = (USHORT)cbData - 1;
00494         AnsiString.MaximumLength = (USHORT)cbData;
00495         RtlAnsiStringToUnicodeString (&Data, &AnsiString, TRUE);
00496         lpDataW = (const UCHAR*)Data.Buffer;
00497         cbDataW = Data.MaximumLength;
00498     }
00499     else
00500     {
00501         lpDataW = lpData;
00502         cbDataW = (USHORT)cbData;
00503     }
00504 
00505     if (rc == ERROR_SUCCESS)
00506         rc = RegSetValueExW(hKey, lpValueNameW, 0, dwType, lpDataW, cbDataW);
00507     if (lpValueNameW)
00508         free(lpValueNameW);
00509     if (lpData != lpDataW)
00510         free((PVOID)lpDataW);
00511     return rc;
00512 }
00513 
00514 LONG WINAPI
00515 RegQueryValueExW(
00516     IN HKEY hKey,
00517     IN LPCWSTR lpValueName,
00518     IN PULONG lpReserved,
00519     OUT PULONG lpType,
00520     OUT PUCHAR lpData,
00521     OUT PSIZE_T lpcbData)
00522 {
00523     //ParentKey = HKEY_TO_MEMKEY(RootKey);
00524     PCM_KEY_VALUE ValueCell;
00525     HCELL_INDEX ValueCellOffset;
00526     LONG rc;
00527 
00528     rc = RegpOpenOrCreateValue(
00529             hKey,
00530             lpValueName,
00531             FALSE,
00532             &ValueCell,
00533             &ValueCellOffset);
00534     if (rc != ERROR_SUCCESS)
00535         return rc;
00536 
00537     DPRINT1("RegQueryValueExW(%S) not implemented\n", lpValueName);
00538     /* ValueCell and ValueCellOffset are valid */
00539 
00540     return ERROR_UNSUCCESSFUL;
00541 }
00542 
00543 LONG WINAPI
00544 RegQueryValueExA(
00545     IN HKEY hKey,
00546     IN LPCSTR lpValueName,
00547     IN PULONG lpReserved,
00548     OUT PULONG lpType,
00549     OUT PUCHAR lpData,
00550     OUT PSIZE_T lpcbData)
00551 {
00552     LPWSTR lpValueNameW = NULL;
00553     LONG rc;
00554 
00555     if (lpValueName)
00556     {
00557         lpValueNameW = MultiByteToWideChar(lpValueName);
00558         if (!lpValueNameW)
00559             return ERROR_OUTOFMEMORY;
00560     }
00561 
00562     rc = RegQueryValueExW(hKey, lpValueNameW, lpReserved, lpType, lpData, lpcbData);
00563     if (lpValueNameW)
00564         free(lpValueNameW);
00565     return ERROR_UNSUCCESSFUL;
00566 }
00567 
00568 LONG WINAPI
00569 RegDeleteValueW(
00570     IN HKEY hKey,
00571     IN LPCWSTR lpValueName OPTIONAL)
00572 {
00573     DPRINT1("RegDeleteValueW() unimplemented\n");
00574     return ERROR_UNSUCCESSFUL;
00575 }
00576 
00577 LONG WINAPI
00578 RegDeleteValueA(
00579     IN HKEY hKey,
00580     IN LPCSTR lpValueName OPTIONAL)
00581 {
00582     LPWSTR lpValueNameW;
00583     LONG rc;
00584 
00585     if (lpValueName)
00586     {
00587         lpValueNameW = MultiByteToWideChar(lpValueName);
00588         if (!lpValueNameW)
00589             return ERROR_OUTOFMEMORY;
00590         rc = RegDeleteValueW(hKey, lpValueNameW);
00591         free(lpValueNameW);
00592     }
00593     else
00594         rc = RegDeleteValueW(hKey, NULL);
00595     return rc;
00596 }
00597 
00598 static BOOL
00599 ConnectRegistry(
00600     IN HKEY RootKey,
00601     IN PCMHIVE HiveToConnect,
00602     IN LPCWSTR Path)
00603 {
00604     NTSTATUS Status;
00605     MEMKEY NewKey;
00606     LONG rc;
00607 
00608     Status = CmiInitializeTempHive(HiveToConnect);
00609     if (!NT_SUCCESS(Status))
00610     {
00611         DPRINT1("CmiInitializeTempHive() failed with status 0x%08x\n", Status);
00612         return FALSE;
00613     }
00614 
00615     /* Create key */
00616     rc = RegCreateKeyW(
00617         RootKey,
00618         Path,
00619         (PHKEY)&NewKey);
00620     if (rc != ERROR_SUCCESS)
00621         return FALSE;
00622 
00623     NewKey->RegistryHive = HiveToConnect;
00624     NewKey->KeyCellOffset = HiveToConnect->Hive.BaseBlock->RootCell;
00625     NewKey->KeyCell = (PCM_KEY_NODE)HvGetCell (&HiveToConnect->Hive, NewKey->KeyCellOffset);
00626     return TRUE;
00627 }
00628 
00629 LIST_ENTRY CmiHiveListHead;
00630 
00631 VOID
00632 RegInitializeRegistry(VOID)
00633 {
00634     UNICODE_STRING RootKeyName = RTL_CONSTANT_STRING(L"\\");
00635     NTSTATUS Status;
00636     HKEY ControlSetKey;
00637 
00638     InitializeListHead(&CmiHiveListHead);
00639 
00640     Status = CmiInitializeTempHive(&RootHive);
00641     if (!NT_SUCCESS(Status))
00642     {
00643         DPRINT1("CmiInitializeTempHive() failed with status 0x%08x\n", Status);
00644         return;
00645     }
00646 
00647     RootKey = CreateInMemoryStructure(
00648         &RootHive,
00649         RootHive.Hive.BaseBlock->RootCell,
00650         &RootKeyName);
00651 
00652     /* Create DEFAULT key */
00653     ConnectRegistry(
00654         NULL,
00655         &DefaultHive,
00656         L"Registry\\User\\.DEFAULT");
00657 
00658     /* Create SAM key */
00659     ConnectRegistry(
00660         NULL,
00661         &SamHive,
00662         L"Registry\\Machine\\SAM");
00663 
00664     /* Create SECURITY key */
00665     ConnectRegistry(
00666         NULL,
00667         &SecurityHive,
00668         L"Registry\\Machine\\SECURITY");
00669 
00670     /* Create SOFTWARE key */
00671     ConnectRegistry(
00672         NULL,
00673         &SoftwareHive,
00674         L"Registry\\Machine\\SOFTWARE");
00675 
00676     /* Create SYSTEM key */
00677     ConnectRegistry(
00678         NULL,
00679         &SystemHive,
00680         L"Registry\\Machine\\SYSTEM");
00681 
00682     /* Create 'ControlSet001' key */
00683     RegCreateKeyW(
00684         NULL,
00685         L"Registry\\Machine\\SYSTEM\\ControlSet001",
00686         &ControlSetKey);
00687 }
00688 
00689 VOID
00690 RegShutdownRegistry(VOID)
00691 {
00692     /* FIXME: clean up the complete hive */
00693 
00694     free(RootKey->Name);
00695     free(RootKey);
00696 }
00697 
00698 /* EOF */

Generated on Mon May 28 2012 04:17:06 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.