diff --git a/reactos/boot/environ/app/bootmgr/rtlcompat.c b/reactos/boot/environ/app/bootmgr/rtlcompat.c index 0590c2cc1c8..25aee307644 100644 --- a/reactos/boot/environ/app/bootmgr/rtlcompat.c +++ b/reactos/boot/environ/app/bootmgr/rtlcompat.c @@ -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); +} diff --git a/reactos/lib/cmlib/CMakeLists.txt b/reactos/lib/cmlib/CMakeLists.txt index 70881d32876..83a1d4bc1c2 100644 --- a/reactos/lib/cmlib/CMakeLists.txt +++ b/reactos/lib/cmlib/CMakeLists.txt @@ -9,6 +9,7 @@ list(APPEND SOURCE cmindex.c cmname.c cmtools.c + cmvalue.c hivebin.c hivecell.c hiveinit.c diff --git a/reactos/lib/cmlib/cmdata.h b/reactos/lib/cmlib/cmdata.h index 393efd4861a..f1566b47d3a 100644 --- a/reactos/lib/cmlib/cmdata.h +++ b/reactos/lib/cmlib/cmdata.h @@ -48,6 +48,13 @@ // #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 // diff --git a/reactos/lib/cmlib/cmlib.h b/reactos/lib/cmlib/cmlib.h index 5906b423aea..21fe27ee129 100644 --- a/reactos/lib/cmlib/cmlib.h +++ b/reactos/lib/cmlib/cmlib.h @@ -160,6 +160,7 @@ #include #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. */ diff --git a/reactos/ntoskrnl/config/cmvalue.c b/reactos/lib/cmlib/cmvalue.c similarity index 88% rename from reactos/ntoskrnl/config/cmvalue.c rename to reactos/lib/cmlib/cmvalue.c index 30fd6229127..f0de392347b 100644 --- a/reactos/ntoskrnl/config/cmvalue.c +++ b/reactos/lib/cmlib/cmvalue.c @@ -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 /* 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, diff --git a/reactos/ntoskrnl/config/cmapi.c b/reactos/ntoskrnl/config/cmapi.c index aa162d1307c..64679dea513 100644 --- a/reactos/ntoskrnl/config/cmapi.c +++ b/reactos/ntoskrnl/config/cmapi.c @@ -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 diff --git a/reactos/ntoskrnl/include/internal/cm_x.h b/reactos/ntoskrnl/include/internal/cm_x.h index 3f6d4ae0018..a6b27428f30 100644 --- a/reactos/ntoskrnl/include/internal/cm_x.h +++ b/reactos/ntoskrnl/include/internal/cm_x.h @@ -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 // diff --git a/reactos/ntoskrnl/ntos.cmake b/reactos/ntoskrnl/ntos.cmake index ebde0b186fe..728c14ed00b 100644 --- a/reactos/ntoskrnl/ntos.cmake +++ b/reactos/ntoskrnl/ntos.cmake @@ -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