[CMLIB]: Move Value functions to CMLIB as well, so that they can be shared with the...
authorAlex Ionescu <aionescu@gmail.com>
Tue, 5 Jan 2016 01:51:54 +0000 (01:51 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Tue, 5 Jan 2016 01:51:54 +0000 (01:51 +0000)
svn path=/trunk/; revision=70489

reactos/boot/environ/app/bootmgr/rtlcompat.c
reactos/lib/cmlib/CMakeLists.txt
reactos/lib/cmlib/cmdata.h
reactos/lib/cmlib/cmlib.h
reactos/lib/cmlib/cmvalue.c [moved from reactos/ntoskrnl/config/cmvalue.c with 88% similarity]
reactos/ntoskrnl/config/cmapi.c
reactos/ntoskrnl/include/internal/cm_x.h
reactos/ntoskrnl/ntos.cmake

index 0590c2c..25aee30 100644 (file)
@@ -75,3 +75,15 @@ DbgPrint (
 {
     return 0;
 }
+
+VOID
+NTAPI
+KeBugCheckEx(
+    _In_ ULONG BugCheckCode,
+    _In_ ULONG_PTR BugCheckParameter1,
+    _In_ ULONG_PTR BugCheckParameter2,
+    _In_ ULONG_PTR BugCheckParameter3,
+    _In_ ULONG_PTR BugCheckParameter4)
+{
+    __assume(0);
+}
index 70881d3..83a1d4b 100644 (file)
@@ -9,6 +9,7 @@ list(APPEND SOURCE
     cmindex.c
     cmname.c
     cmtools.c
+    cmvalue.c
     hivebin.c
     hivecell.c
     hiveinit.c
index 393efd4..f1566b4 100644 (file)
 //
 #define VALUE_COMP_NAME                                 0x0001
 
+//
+// CM_KEY_VALUE Types
+//
+#define CM_KEY_VALUE_SMALL                              0x4
+#define CM_KEY_VALUE_BIG                                0x3FD8
+#define CM_KEY_VALUE_SPECIAL_SIZE                       0x80000000
+
 #include <pshpack1.h>
 
 //
index 5906b42..21fe27e 100644 (file)
 #include <wchar.h>
 #include "hivedata.h"
 #include "cmdata.h"
+#include "bugcodes.h"
 
 #if defined(_TYPEDEFS_HOST_H) || defined(__FREELDR_H)
 
@@ -253,6 +254,56 @@ typedef struct _HV_TRACK_CELL_REF
 
 extern ULONG CmlibTraceLevel;
 
+//
+// Hack since bigkeys are not yet supported
+//
+#define ASSERT_VALUE_BIG(h, s)                          \
+    ASSERTMSG("Big keys not supported!", !CmpIsKeyValueBig(h, s));
+
+//
+// Returns whether or not this is a small valued key
+//
+static inline
+BOOLEAN
+CmpIsKeyValueSmall(OUT PULONG RealLength,
+                   IN ULONG Length)
+{
+    /* Check if the length has the special size value */
+    if (Length >= CM_KEY_VALUE_SPECIAL_SIZE)
+    {
+        /* It does, so this is a small key: return the real length */
+        *RealLength = Length - CM_KEY_VALUE_SPECIAL_SIZE;
+        return TRUE;
+    }
+
+    /* This is not a small key, return the length we read */
+    *RealLength = Length;
+    return FALSE;
+}
+
+//
+// Returns whether or not this is a big valued key
+//
+static inline
+BOOLEAN
+CmpIsKeyValueBig(IN PHHIVE Hive,
+                 IN ULONG Length)
+{
+    /* Check if the hive is XP Beta 1 or newer */
+    if (Hive->Version >= HSYS_WHISTLER_BETA1)
+    {
+        /* Check if the key length is valid for a big value key */
+        if ((Length < CM_KEY_VALUE_SPECIAL_SIZE) && (Length > CM_KEY_VALUE_BIG))
+        {
+            /* Yes, this value is big */
+            return TRUE;
+        }
+    }
+
+    /* Not a big value key */
+    return FALSE;
+}
+
 /*
  * Public Hive functions.
  */
similarity index 88%
rename from reactos/ntoskrnl/config/cmvalue.c
rename to reactos/lib/cmlib/cmvalue.c
index 30fd622..f0de392 100644 (file)
@@ -1,16 +1,16 @@
 /*
  * PROJECT:         ReactOS Kernel
  * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            ntoskrnl/config/cmvalue.c
- * PURPOSE:         Configuration Manager - Cell Values
+ * FILE:            lib/cmlib/cmvalue.c
+ * PURPOSE:         Configuration Manager Library - Cell Values
  * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
  */
 
 /* INCLUDES ******************************************************************/
 
-#include "ntoskrnl.h"
+#include "cmlib.h"
 #define NDEBUG
-#include "debug.h"
+#include <debug.h>
 
 /* FUNCTIONS *****************************************************************/
 
@@ -362,6 +362,46 @@ CmpRemoveValueFromList(IN PHHIVE Hive,
     return STATUS_SUCCESS;
 }
 
+HCELL_INDEX
+NTAPI
+CmpCopyCell(IN PHHIVE SourceHive,
+            IN HCELL_INDEX SourceCell,
+            IN PHHIVE DestinationHive,
+            IN HSTORAGE_TYPE StorageType)
+{
+    PCELL_DATA SourceData;
+    PCELL_DATA DestinationData = NULL;
+    HCELL_INDEX DestinationCell = HCELL_NIL;
+    LONG DataSize;
+    PAGED_CODE();
+
+    /* Get the data and the size of the source cell */
+    SourceData = HvGetCell(SourceHive, SourceCell);
+    DataSize = HvGetCellSize(SourceHive, SourceData);
+
+    /* Allocate a new cell in the destination hive */
+    DestinationCell = HvAllocateCell(DestinationHive,
+                                     DataSize,
+                                     StorageType,
+                                     HCELL_NIL);
+    if (DestinationCell == HCELL_NIL) goto Cleanup;
+
+    /* Get the data of the destination cell */
+    DestinationData = HvGetCell(DestinationHive, DestinationCell);
+
+    /* Copy the data from the source cell to the destination cell */
+    RtlMoveMemory(DestinationData, SourceData, DataSize);
+
+Cleanup:
+
+    /* Release the cells */
+    if (SourceData) HvReleaseCell(SourceHive, SourceCell);
+    if (DestinationData) HvReleaseCell(DestinationHive, DestinationCell);
+
+    /* Return the destination cell index */
+    return DestinationCell;
+}
+
 NTSTATUS
 NTAPI
 CmpCopyKeyValueList(IN PHHIVE SourceHive,
index aa162d1..64679de 100644 (file)
@@ -2345,46 +2345,6 @@ CmCountOpenSubKeys(IN PCM_KEY_CONTROL_BLOCK RootKcb,
     return SubKeys;
 }
 
-HCELL_INDEX
-NTAPI
-CmpCopyCell(IN PHHIVE SourceHive,
-            IN HCELL_INDEX SourceCell,
-            IN PHHIVE DestinationHive,
-            IN HSTORAGE_TYPE StorageType)
-{
-    PCELL_DATA SourceData;
-    PCELL_DATA DestinationData = NULL;
-    HCELL_INDEX DestinationCell = HCELL_NIL;
-    LONG DataSize;
-    PAGED_CODE();
-
-    /* Get the data and the size of the source cell */
-    SourceData = HvGetCell(SourceHive, SourceCell);
-    DataSize = HvGetCellSize(SourceHive, SourceData);
-
-    /* Allocate a new cell in the destination hive */
-    DestinationCell = HvAllocateCell(DestinationHive,
-                                     DataSize,
-                                     StorageType,
-                                     HCELL_NIL);
-    if (DestinationCell == HCELL_NIL) goto Cleanup;
-
-    /* Get the data of the destination cell */
-    DestinationData = HvGetCell(DestinationHive, DestinationCell);
-
-    /* Copy the data from the source cell to the destination cell */
-    RtlMoveMemory(DestinationData, SourceData, DataSize);
-
-Cleanup:
-
-    /* Release the cells */
-    if (SourceData) HvReleaseCell(SourceHive, SourceCell);
-    if (DestinationData) HvReleaseCell(DestinationHive, DestinationCell);
-
-    /* Return the destination cell index */
-    return DestinationCell;
-}
-
 static
 NTSTATUS
 NTAPI
index 3f6d4ae..a6b2742 100644 (file)
@@ -6,50 +6,6 @@
 * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
 */
 
-//
-// Returns whether or not this is a small valued key
-//
-FORCEINLINE
-BOOLEAN
-CmpIsKeyValueSmall(OUT PULONG RealLength,
-                   IN ULONG Length)
-{
-    /* Check if the length has the special size value */
-    if (Length >= CM_KEY_VALUE_SPECIAL_SIZE)
-    {
-        /* It does, so this is a small key: return the real length */
-        *RealLength = Length - CM_KEY_VALUE_SPECIAL_SIZE;
-        return TRUE;
-    }
-
-    /* This is not a small key, return the length we read */
-    *RealLength = Length;
-    return FALSE;
-}
-
-//
-// Returns whether or not this is a big valued key
-//
-FORCEINLINE
-BOOLEAN
-CmpIsKeyValueBig(IN PHHIVE Hive,
-                 IN ULONG Length)
-{
-    /* Check if the hive is XP Beta 1 or newer */
-    if (Hive->Version >= HSYS_WHISTLER_BETA1)
-    {
-        /* Check if the key length is valid for a big value key */
-        if ((Length < CM_KEY_VALUE_SPECIAL_SIZE) && (Length > CM_KEY_VALUE_BIG))
-        {
-            /* Yes, this value is big */
-            return TRUE;
-        }
-    }
-
-    /* Not a big value key */
-    return FALSE;
-}
-
 //
 // Returns the hashkey corresponding to a convkey
 //
index ebde0b1..728c14e 100644 (file)
@@ -68,7 +68,6 @@ list(APPEND SOURCE
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmsecach.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmsysini.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmvalche.c
-    ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmvalue.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmwraprs.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/ntapi.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/dbgk/dbgkobj.c