[CMLIB]: Move Value functions to CMLIB as well, so that they can be shared with the new boot code.

svn path=/trunk/; revision=70489
This commit is contained in:
Alex Ionescu 2016-01-05 01:51:54 +00:00
parent 3789427f96
commit 9a4cbe2cbe
8 changed files with 115 additions and 89 deletions

View file

@ -75,3 +75,15 @@ DbgPrint (
{ {
return 0; 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);
}

View file

@ -9,6 +9,7 @@ list(APPEND SOURCE
cmindex.c cmindex.c
cmname.c cmname.c
cmtools.c cmtools.c
cmvalue.c
hivebin.c hivebin.c
hivecell.c hivecell.c
hiveinit.c hiveinit.c

View file

@ -48,6 +48,13 @@
// //
#define VALUE_COMP_NAME 0x0001 #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> #include <pshpack1.h>
// //

View file

@ -160,6 +160,7 @@
#include <wchar.h> #include <wchar.h>
#include "hivedata.h" #include "hivedata.h"
#include "cmdata.h" #include "cmdata.h"
#include "bugcodes.h"
#if defined(_TYPEDEFS_HOST_H) || defined(__FREELDR_H) #if defined(_TYPEDEFS_HOST_H) || defined(__FREELDR_H)
@ -253,6 +254,56 @@ typedef struct _HV_TRACK_CELL_REF
extern ULONG CmlibTraceLevel; 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. * Public Hive functions.
*/ */

View file

@ -1,16 +1,16 @@
/* /*
* PROJECT: ReactOS Kernel * PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory * LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmvalue.c * FILE: lib/cmlib/cmvalue.c
* PURPOSE: Configuration Manager - Cell Values * PURPOSE: Configuration Manager Library - Cell Values
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES ******************************************************************/
#include "ntoskrnl.h" #include "cmlib.h"
#define NDEBUG #define NDEBUG
#include "debug.h" #include <debug.h>
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -362,6 +362,46 @@ CmpRemoveValueFromList(IN PHHIVE Hive,
return STATUS_SUCCESS; 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 NTSTATUS
NTAPI NTAPI
CmpCopyKeyValueList(IN PHHIVE SourceHive, CmpCopyKeyValueList(IN PHHIVE SourceHive,

View file

@ -2345,46 +2345,6 @@ CmCountOpenSubKeys(IN PCM_KEY_CONTROL_BLOCK RootKcb,
return SubKeys; 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 static
NTSTATUS NTSTATUS
NTAPI NTAPI

View file

@ -6,50 +6,6 @@
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) * 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 // Returns the hashkey corresponding to a convkey
// //

View file

@ -68,7 +68,6 @@ list(APPEND SOURCE
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmsecach.c ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmsecach.c
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmsysini.c ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmsysini.c
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmvalche.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/cmwraprs.c
${REACTOS_SOURCE_DIR}/ntoskrnl/config/ntapi.c ${REACTOS_SOURCE_DIR}/ntoskrnl/config/ntapi.c
${REACTOS_SOURCE_DIR}/ntoskrnl/dbgk/dbgkobj.c ${REACTOS_SOURCE_DIR}/ntoskrnl/dbgk/dbgkobj.c