[CMLIB]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 14 Jan 2016 18:03:35 +0000 (18:03 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 14 Jan 2016 18:03:35 +0000 (18:03 +0000)
- Do not define _NTOSKRNL_ at compilation time, keep only the _NTSYSTEM_ define (and NASSERT).
- Remove deprecated unused private flags.
- Modify CmCreateRootNode to make it look more similar to the CmpCreateRootNode function of ntoskrnl/config/cmsysini.c, to ease future code adaptation in cmlib & mkhive and then deprecate CmCreateRootNode in favour of CmpCreateRootNode.

svn path=/trunk/; revision=70593

reactos/lib/cmlib/CMakeLists.txt
reactos/lib/cmlib/cmdata.h
reactos/lib/cmlib/cminit.c

index 83a1d4b..7de81f9 100644 (file)
@@ -1,6 +1,5 @@
 
 add_definitions(
-    -D_NTOSKRNL_
     -D_NTSYSTEM_
     -DNASSERT)
 
index dc68b20..d5313f1 100644 (file)
@@ -7,13 +7,6 @@
 
 #pragma once
 
-#define  REG_INIT_BLOCK_LIST_SIZE       32
-#define  REG_INIT_HASH_TABLE_SIZE       3
-#define  REG_EXTEND_HASH_TABLE_SIZE     4
-#define  REG_VALUE_LIST_CELL_MULTIPLE   4
-#define  REG_DATA_SIZE_MASK             0x7FFFFFFF
-#define  REG_DATA_IN_OFFSET             0x80000000
-
 //
 // Key Types
 //
index 29fe192..48235d8 100644 (file)
 
 ULONG CmlibTraceLevel = 0;
 
+// FIXME: This function must be replaced by CmpCreateRootNode from ntoskrnl/config/cmsysini.c
+// (and CmpCreateRootNode be moved there).
 BOOLEAN CMAPI
 CmCreateRootNode(
     PHHIVE Hive,
     PCWSTR Name)
 {
+    UNICODE_STRING KeyName;
     PCM_KEY_NODE KeyCell;
     HCELL_INDEX RootCellIndex;
-    ULONG NameSize;
 
-    /* Allocate the cell */
-    NameSize = (ULONG)strlenW(Name) * sizeof(WCHAR);
+    /* Initialize the node name and allocate it */
+    RtlInitUnicodeString(&KeyName, Name);
     RootCellIndex = HvAllocateCell(Hive,
-                                   FIELD_OFFSET(CM_KEY_NODE, Name) + NameSize,
+                                   FIELD_OFFSET(CM_KEY_NODE, Name) +
+                                   CmpNameSize(Hive, &KeyName),
                                    Stable,
                                    HCELL_NIL);
     if (RootCellIndex == HCELL_NIL) return FALSE;
@@ -37,9 +40,10 @@ CmCreateRootNode(
     if (!KeyCell) return FALSE;
 
     /* Setup the cell */
-    KeyCell->Signature = (USHORT)CM_KEY_NODE_SIGNATURE;
+    KeyCell->Signature = CM_KEY_NODE_SIGNATURE;
     KeyCell->Flags = KEY_HIVE_ENTRY | KEY_NO_DELETE;
-    KeyCell->LastWriteTime.QuadPart = 0;
+    // KeQuerySystemTime(&KeyCell->LastWriteTime);
+    KeyCell->LastWriteTime.QuadPart = 0ULL;
     KeyCell->Parent = HCELL_NIL;
     KeyCell->SubKeyCounts[Stable] = 0;
     KeyCell->SubKeyCounts[Volatile] = 0;
@@ -54,10 +58,8 @@ CmCreateRootNode(
     KeyCell->MaxClassLen = 0;
     KeyCell->MaxValueNameLen = 0;
     KeyCell->MaxValueDataLen = 0;
-
-    /* Write the name */
-    KeyCell->NameLength = (USHORT)NameSize;
-    RtlCopyMemory(KeyCell->Name, Name, NameSize);
+    KeyCell->NameLength = CmpCopyName(Hive, KeyCell->Name, &KeyName);
+    if (KeyCell->NameLength < KeyName.Length) KeyCell->Flags |= KEY_COMP_NAME;
 
     /* Return success */
     HvReleaseCell(Hive, RootCellIndex);