[CMLIB/NTOSKRNL]:
authorAlex Ionescu <aionescu@gmail.com>
Sun, 4 Oct 2015 20:18:49 +0000 (20:18 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Sun, 4 Oct 2015 20:18:49 +0000 (20:18 +0000)
- Move cmindex.c and cmname.c to cmlib, because bootmgr/winload use the kernel's cm implementation, unlike our freeldr which uses an almost copy-pasted-but-not-shared-because-hey-why-not-have-to-fix-the-bugs-in-two-places-instead-of-just-one implementation.
- Minor fixes to headers to allow those two files to be used/built outside of ntoskrnl.

svn path=/trunk/; revision=69444

reactos/lib/cmlib/CMakeLists.txt
reactos/lib/cmlib/cmindex.c [moved from reactos/ntoskrnl/config/cmindex.c with 99% similarity]
reactos/lib/cmlib/cmlib.h
reactos/lib/cmlib/cmname.c [moved from reactos/ntoskrnl/config/cmname.c with 98% similarity]
reactos/ntoskrnl/ntos.cmake

index fa1b8ad..70881d3 100644 (file)
@@ -6,6 +6,8 @@ add_definitions(
 
 list(APPEND SOURCE
     cminit.c
+    cmindex.c
+    cmname.c
     cmtools.c
     hivebin.c
     hivecell.c
similarity index 99%
rename from reactos/ntoskrnl/config/cmindex.c
rename to reactos/lib/cmlib/cmindex.c
index 2ef34cd..98da1c8 100644 (file)
@@ -1,14 +1,14 @@
 /*
- * PROJECT:         ReactOS Kernel
+ * PROJECT:         ReactOS Registry Library
  * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            ntoskrnl/config/cmindex.c
+ * FILE:            lib/cmlib/cmindex.c
  * PURPOSE:         Configuration Manager - Cell Indexes
  * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
  */
 
 /* INCLUDES ******************************************************************/
 
-#include "ntoskrnl.h"
+#include "cmlib.h"
 #define NDEBUG
 #include "debug.h"
 
index c6b1c46..3f3e60c 100644 (file)
@@ -55,6 +55,8 @@
     #define OBJ_CASE_INSENSITIVE             0x00000040L
     #define USHORT_MAX                       USHRT_MAX
 
+    #define OBJ_NAME_PATH_SEPARATOR          ((WCHAR)L'\\')
+
     VOID NTAPI
     KeQuerySystemTime(
         OUT PLARGE_INTEGER CurrentTime);
 
     #include <ntdef.h>
     #include <ntddk.h>
+    #undef PAGED_CODE
+    #define PAGED_CODE()
 
     /* Prevent inclusion of Windows headers through <wine/unicode.h> */
     #define _WINDEF_
@@ -248,7 +252,7 @@ typedef struct _HV_TRACK_CELL_REF
 extern ULONG CmlibTraceLevel;
 
 /*
- * Public functions.
+ * Public Hive functions.
  */
 NTSTATUS CMAPI
 HvInitialize(
@@ -336,6 +340,41 @@ BOOLEAN CMAPI
 HvWriteHive(
    PHHIVE RegistryHive);
 
+BOOLEAN
+CMAPI
+HvTrackCellRef(
+    PHV_TRACK_CELL_REF CellRef,
+    PHHIVE Hive,
+    HCELL_INDEX Cell
+);
+
+VOID
+CMAPI
+HvReleaseFreeCellRefArray(
+    PHV_TRACK_CELL_REF CellRef
+);
+
+/*
+ * Private functions.
+ */
+
+PHBIN CMAPI
+HvpAddBin(
+   PHHIVE RegistryHive,
+   ULONG Size,
+   HSTORAGE_TYPE Storage);
+
+NTSTATUS CMAPI
+HvpCreateHiveFreeCellList(
+   PHHIVE Hive);
+
+ULONG CMAPI
+HvpHiveHeaderChecksum(
+   PHBASE_BLOCK HiveHeader);
+
+
+/* Old-style Public "Cmlib" functions */
+
 BOOLEAN CMAPI
 CmCreateRootNode(
    PHHIVE Hive,
@@ -389,36 +428,54 @@ CmCopyKeyValueName(
     _Out_ PWCHAR ValueNameBuffer,
     _Inout_ ULONG BufferLength);
 
-BOOLEAN
-CMAPI
-HvTrackCellRef(
-    PHV_TRACK_CELL_REF CellRef,
-    PHHIVE Hive,
-    HCELL_INDEX Cell
-);
+/* NT-style Public Cm functions */
 
-VOID
-CMAPI
-HvReleaseFreeCellRefArray(
-    PHV_TRACK_CELL_REF CellRef
-);
+LONG
+NTAPI
+CmpCompareCompressedName(
+    IN PCUNICODE_STRING SearchName,
+    IN PWCHAR CompressedName,
+    IN ULONG NameLength
+    );
 
-/*
- * Private functions.
- */
+USHORT
+NTAPI
+CmpCompressedNameSize(
+    IN PWCHAR Name,
+    IN ULONG Length
+    );
 
-PHBIN CMAPI
-HvpAddBin(
-   PHHIVE RegistryHive,
-   ULONG Size,
-   HSTORAGE_TYPE Storage);
+HCELL_INDEX
+NTAPI
+CmpFindSubKeyByName(
+    IN PHHIVE Hive,
+    IN PCM_KEY_NODE Parent,
+    IN PCUNICODE_STRING SearchName
+    );
 
-NTSTATUS CMAPI
-HvpCreateHiveFreeCellList(
-   PHHIVE Hive);
+/* To be implemented by the user of this library */
+PVOID
+NTAPI
+CmpAllocate(
+    IN SIZE_T Size,
+    IN BOOLEAN Paged,
+    IN ULONG Tag
+    );
 
-ULONG CMAPI
-HvpHiveHeaderChecksum(
-   PHBASE_BLOCK HiveHeader);
+VOID
+NTAPI
+CmpFree(
+    IN PVOID Ptr,
+    IN ULONG Quota
+    );
+
+VOID
+NTAPI
+CmpCopyCompressedName(
+    IN PWCHAR Destination,
+    IN ULONG DestinationLength,
+    IN PWCHAR Source,
+    IN ULONG SourceLength
+    );
 
 #endif /* _CMLIB_H_ */
similarity index 98%
rename from reactos/ntoskrnl/config/cmname.c
rename to reactos/lib/cmlib/cmname.c
index 9fc9125..50c5d19 100644 (file)
@@ -1,14 +1,14 @@
 /*
- * PROJECT:         ReactOS Kernel
+ * PROJECT:         ReactOS Registry Library
  * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            ntoskrnl/config/cmname.c
+ * FILE:            lib/cmlib/cmname.c
  * PURPOSE:         Configuration Manager - Name Management
  * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
  */
 
 /* INCLUDES ******************************************************************/
 
-#include "ntoskrnl.h"
+#include "cmlib.h"
 #define NDEBUG
 #include "debug.h"
 
index e1946cf..d6dc35e 100644 (file)
@@ -56,13 +56,11 @@ list(APPEND SOURCE
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmdelay.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmhook.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmhvlist.c
-    ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmindex.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cminit.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmkcbncb.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmkeydel.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmlazy.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmmapvw.c
-    ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmname.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmnotify.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmparse.c
     ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmquota.c