From 85b39039ddefe00ff49a1def34475bf31fa0d2a5 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Sun, 4 Oct 2015 20:18:49 +0000 Subject: [PATCH] [CMLIB/NTOSKRNL]: - 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 | 2 + .../{ntoskrnl/config => lib/cmlib}/cmindex.c | 6 +- reactos/lib/cmlib/cmlib.h | 115 +++++++++++++----- .../{ntoskrnl/config => lib/cmlib}/cmname.c | 6 +- reactos/ntoskrnl/ntos.cmake | 2 - 5 files changed, 94 insertions(+), 37 deletions(-) rename reactos/{ntoskrnl/config => lib/cmlib}/cmindex.c (99%) rename reactos/{ntoskrnl/config => lib/cmlib}/cmname.c (98%) diff --git a/reactos/lib/cmlib/CMakeLists.txt b/reactos/lib/cmlib/CMakeLists.txt index fa1b8ad1f00..70881d32876 100644 --- a/reactos/lib/cmlib/CMakeLists.txt +++ b/reactos/lib/cmlib/CMakeLists.txt @@ -6,6 +6,8 @@ add_definitions( list(APPEND SOURCE cminit.c + cmindex.c + cmname.c cmtools.c hivebin.c hivecell.c diff --git a/reactos/ntoskrnl/config/cmindex.c b/reactos/lib/cmlib/cmindex.c similarity index 99% rename from reactos/ntoskrnl/config/cmindex.c rename to reactos/lib/cmlib/cmindex.c index 2ef34cd0437..98da1c8802a 100644 --- a/reactos/ntoskrnl/config/cmindex.c +++ b/reactos/lib/cmlib/cmindex.c @@ -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" diff --git a/reactos/lib/cmlib/cmlib.h b/reactos/lib/cmlib/cmlib.h index c6b1c46bac2..3f3e60c1937 100644 --- a/reactos/lib/cmlib/cmlib.h +++ b/reactos/lib/cmlib/cmlib.h @@ -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); @@ -114,6 +116,8 @@ #include #include + #undef PAGED_CODE + #define PAGED_CODE() /* Prevent inclusion of Windows headers through */ #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 */ + +LONG +NTAPI +CmpCompareCompressedName( + IN PCUNICODE_STRING SearchName, + IN PWCHAR CompressedName, + IN ULONG NameLength + ); + +USHORT +NTAPI +CmpCompressedNameSize( + IN PWCHAR Name, + IN ULONG Length + ); + +HCELL_INDEX +NTAPI +CmpFindSubKeyByName( + IN PHHIVE Hive, + IN PCM_KEY_NODE Parent, + IN PCUNICODE_STRING SearchName + ); + +/* To be implemented by the user of this library */ +PVOID +NTAPI +CmpAllocate( + IN SIZE_T Size, + IN BOOLEAN Paged, + IN ULONG Tag + ); VOID -CMAPI -HvReleaseFreeCellRefArray( - PHV_TRACK_CELL_REF CellRef -); +NTAPI +CmpFree( + IN PVOID Ptr, + IN ULONG Quota + ); -/* - * Private functions. - */ - -PHBIN CMAPI -HvpAddBin( - PHHIVE RegistryHive, - ULONG Size, - HSTORAGE_TYPE Storage); - -NTSTATUS CMAPI -HvpCreateHiveFreeCellList( - PHHIVE Hive); - -ULONG CMAPI -HvpHiveHeaderChecksum( - PHBASE_BLOCK HiveHeader); +VOID +NTAPI +CmpCopyCompressedName( + IN PWCHAR Destination, + IN ULONG DestinationLength, + IN PWCHAR Source, + IN ULONG SourceLength + ); #endif /* _CMLIB_H_ */ diff --git a/reactos/ntoskrnl/config/cmname.c b/reactos/lib/cmlib/cmname.c similarity index 98% rename from reactos/ntoskrnl/config/cmname.c rename to reactos/lib/cmlib/cmname.c index 9fc91256e4d..50c5d193894 100644 --- a/reactos/ntoskrnl/config/cmname.c +++ b/reactos/lib/cmlib/cmname.c @@ -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" diff --git a/reactos/ntoskrnl/ntos.cmake b/reactos/ntoskrnl/ntos.cmake index e1946cfac7b..d6dc35e4364 100644 --- a/reactos/ntoskrnl/ntos.cmake +++ b/reactos/ntoskrnl/ntos.cmake @@ -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