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

cminit.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:   registry manipulation library
00003  * LICENSE:   GPL - See COPYING in the top level directory
00004  * COPYRIGHT: Copyright 2005 Filip Navara <navaraf@reactos.org>
00005  *            Copyright 2001 - 2005 Eric Kohl
00006  */
00007 
00008 #include "cmlib.h"
00009 #define NDEBUG
00010 #include <debug.h>
00011 
00012 ULONG CmlibTraceLevel = 0;
00013 
00014 BOOLEAN CMAPI
00015 CmCreateRootNode(
00016    PHHIVE Hive,
00017    PCWSTR Name)
00018 {
00019    PCM_KEY_NODE KeyCell;
00020    HCELL_INDEX RootCellIndex;
00021    ULONG NameSize;
00022 
00023    /* Allocate the cell */
00024    NameSize = (ULONG)strlenW(Name) * sizeof(WCHAR);
00025    RootCellIndex = HvAllocateCell(Hive,
00026                                   FIELD_OFFSET(CM_KEY_NODE, Name) + NameSize,
00027                                   Stable,
00028                                   HCELL_NIL);
00029    if (RootCellIndex == HCELL_NIL) return FALSE;
00030 
00031    /* Seutp the base block */
00032    Hive->BaseBlock->RootCell = RootCellIndex;
00033    Hive->BaseBlock->CheckSum = HvpHiveHeaderChecksum(Hive->BaseBlock);
00034 
00035    /* Get the key cell */
00036    KeyCell = (PCM_KEY_NODE)HvGetCell(Hive, RootCellIndex);
00037    if (!KeyCell) return FALSE;
00038 
00039    /* Setup the cell */
00040    KeyCell->Signature = (USHORT)CM_KEY_NODE_SIGNATURE;
00041    KeyCell->Flags = KEY_HIVE_ENTRY | KEY_NO_DELETE;
00042    KeyCell->LastWriteTime.QuadPart = 0;
00043    KeyCell->Parent = HCELL_NIL;
00044    KeyCell->SubKeyCounts[Stable] = 0;
00045    KeyCell->SubKeyCounts[Volatile] = 0;
00046    KeyCell->SubKeyLists[Stable] = HCELL_NIL;
00047    KeyCell->SubKeyLists[Volatile] = HCELL_NIL;
00048    KeyCell->ValueList.Count = 0;
00049    KeyCell->ValueList.List = HCELL_NIL;
00050    KeyCell->Security = HCELL_NIL;
00051    KeyCell->Class = HCELL_NIL;
00052    KeyCell->ClassLength = 0;
00053    KeyCell->MaxNameLen = 0;
00054    KeyCell->MaxClassLen = 0;
00055    KeyCell->MaxValueNameLen = 0;
00056    KeyCell->MaxValueDataLen = 0;
00057 
00058    /* Write the name */
00059    KeyCell->NameLength = (USHORT)NameSize;
00060    memcpy(KeyCell->Name, Name, NameSize);
00061 
00062    /* Return success */
00063    HvReleaseCell(Hive, RootCellIndex);
00064    return TRUE;
00065 }
00066 
00067 static VOID CMAPI
00068 CmpPrepareKey(
00069    PHHIVE RegistryHive,
00070    PCM_KEY_NODE KeyCell);
00071 
00072 static VOID CMAPI
00073 CmpPrepareIndexOfKeys(
00074    PHHIVE RegistryHive,
00075    PCM_KEY_INDEX IndexCell)
00076 {
00077    ULONG i;
00078 
00079    if (IndexCell->Signature == CM_KEY_INDEX_ROOT ||
00080        IndexCell->Signature == CM_KEY_INDEX_LEAF)
00081    {
00082       for (i = 0; i < IndexCell->Count; i++)
00083       {
00084          PCM_KEY_INDEX SubIndexCell = HvGetCell(RegistryHive, IndexCell->List[i]);
00085          if (SubIndexCell->Signature == CM_KEY_NODE_SIGNATURE)
00086             CmpPrepareKey(RegistryHive, (PCM_KEY_NODE)SubIndexCell);
00087          else
00088             CmpPrepareIndexOfKeys(RegistryHive, SubIndexCell);
00089       }
00090    }
00091    else if (IndexCell->Signature == CM_KEY_FAST_LEAF ||
00092             IndexCell->Signature == CM_KEY_HASH_LEAF)
00093    {
00094       PCM_KEY_FAST_INDEX HashCell = (PCM_KEY_FAST_INDEX)IndexCell;
00095       for (i = 0; i < HashCell->Count; i++)
00096       {
00097          PCM_KEY_NODE SubKeyCell = HvGetCell(RegistryHive, HashCell->List[i].Cell);
00098          CmpPrepareKey(RegistryHive, SubKeyCell);
00099       }
00100    }
00101    else
00102    {
00103       DPRINT1("IndexCell->Signature %x\n", IndexCell->Signature);
00104       ASSERT(FALSE);
00105    }
00106 }
00107 
00108 static VOID CMAPI
00109 CmpPrepareKey(
00110    PHHIVE RegistryHive,
00111    PCM_KEY_NODE KeyCell)
00112 {
00113    PCM_KEY_INDEX IndexCell;
00114 
00115    ASSERT(KeyCell->Signature == CM_KEY_NODE_SIGNATURE);
00116 
00117    KeyCell->SubKeyLists[Volatile] = HCELL_NIL;
00118    KeyCell->SubKeyCounts[Volatile] = 0;
00119 
00120    /* Enumerate and add subkeys */
00121    if (KeyCell->SubKeyCounts[Stable] > 0)
00122    {
00123       IndexCell = HvGetCell(RegistryHive, KeyCell->SubKeyLists[Stable]);
00124       CmpPrepareIndexOfKeys(RegistryHive, IndexCell);
00125    }
00126 }
00127 
00128 VOID CMAPI
00129 CmPrepareHive(
00130    PHHIVE RegistryHive)
00131 {
00132    PCM_KEY_NODE RootCell;
00133 
00134    RootCell = HvGetCell(RegistryHive, RegistryHive->BaseBlock->RootCell);
00135    CmpPrepareKey(RegistryHive, RootCell);
00136 }

Generated on Fri May 25 2012 04:34:27 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.