Author: hbelusca
Date: Tue Jan 12 21:37:36 2016
New Revision: 70579
URL:
http://svn.reactos.org/svn/reactos?rev=70579&view=rev
Log:
[CMLIB]
- Fix some structure definitions to match Win2k3 symbols (define also
_SECURITY_DESCRIPTOR_RELATIVE for the host-tools so that the CM_KEY_SECURITY structure is
always correctly defined).
- Complete other structure definitions with respect to the NT version defined at compile
time;
http://msdn.mirt.net/ was used as the source of information.
- Add the definition of CM_BIG_DATA for supporting big valued keys (see also
http://www.msuiche.net/2009/06/07/windows-vista-and-later-registry-secrets/ for what they
are).
[NTOS]
- Move CM functions defined in the CMLIB out of the internal ntoskrnl headers.
Modified:
trunk/reactos/lib/cmlib/cmdata.h
trunk/reactos/lib/cmlib/cmlib.h
trunk/reactos/lib/cmlib/hivedata.h
trunk/reactos/ntoskrnl/include/internal/cm.h
Modified: trunk/reactos/lib/cmlib/cmdata.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/cmdata.h?rev=705…
==============================================================================
--- trunk/reactos/lib/cmlib/cmdata.h [iso-8859-1] (original)
+++ trunk/reactos/lib/cmlib/cmdata.h [iso-8859-1] Tue Jan 12 21:37:36 2016
@@ -18,16 +18,18 @@
// Key Types
//
#define CM_KEY_INDEX_ROOT 0x6972 // "ri"
-#define CM_KEY_INDEX_LEAF 0x696c // "li"
-#define CM_KEY_FAST_LEAF 0x666c // "lf"
-#define CM_KEY_HASH_LEAF 0x686c // "lh"
+#define CM_KEY_INDEX_LEAF 0x696C // "li"
+#define CM_KEY_FAST_LEAF 0x666C // "lf"
+#define CM_KEY_HASH_LEAF 0x686C // "lh"
//
// Key Signatures
//
#define CM_KEY_NODE_SIGNATURE 0x6B6E // "nk"
#define CM_LINK_NODE_SIGNATURE 0x6B6C // "lk"
+#define CM_KEY_SECURITY_SIGNATURE 0x6B73 // "sk"
#define CM_KEY_VALUE_SIGNATURE 0x6B76 // "vk"
+#define CM_BIG_DATA_SIGNATURE 0x6264 // "db"
//
// CM_KEY_NODE Flags
@@ -140,7 +142,7 @@
HCELL_INDEX Data;
ULONG Type;
USHORT Flags;
- USHORT Unused1;
+ USHORT Spare;
WCHAR Name[ANYSIZE_ARRAY];
} CM_KEY_VALUE, *PCM_KEY_VALUE;
@@ -155,9 +157,18 @@
HCELL_INDEX Blink;
ULONG ReferenceCount;
ULONG DescriptorLength;
- //SECURITY_DESCRIPTOR_RELATIVE Descriptor;
- UCHAR Data[ANYSIZE_ARRAY];
+ SECURITY_DESCRIPTOR_RELATIVE Descriptor;
} CM_KEY_SECURITY, *PCM_KEY_SECURITY;
+
+//
+// Big Value Key
+//
+typedef struct _CM_BIG_DATA
+{
+ USHORT Signature;
+ USHORT Count;
+ HCELL_INDEX List;
+} CM_BIG_DATA, *PCM_BIG_DATA;
#include <poppack.h>
@@ -205,6 +216,7 @@
CM_KEY_VALUE KeyValue;
CM_KEY_SECURITY KeySecurity;
CM_KEY_INDEX KeyIndex;
+ CM_BIG_DATA ValueData;
HCELL_INDEX KeyList[ANYSIZE_ARRAY];
WCHAR KeyString[ANYSIZE_ARRAY];
} u;
Modified: trunk/reactos/lib/cmlib/cmlib.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/cmlib.h?rev=7057…
==============================================================================
--- trunk/reactos/lib/cmlib/cmlib.h [iso-8859-1] (original)
+++ trunk/reactos/lib/cmlib/cmlib.h [iso-8859-1] Tue Jan 12 21:37:36 2016
@@ -17,6 +17,9 @@
#include <typedefs.h>
#include <stdio.h>
#include <string.h>
+
+ /* C_ASSERT Definition */
+ #define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
#ifdef _WIN32
#define strncasecmp _strnicmp
@@ -97,6 +100,19 @@
#define PKEVENT PVOID
#define PWORK_QUEUE_ITEM PVOID
#define EX_PUSH_LOCK PULONG_PTR
+
+ typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
+
+ typedef struct _SECURITY_DESCRIPTOR_RELATIVE
+ {
+ UCHAR Revision;
+ UCHAR Sbz1;
+ SECURITY_DESCRIPTOR_CONTROL Control;
+ ULONG Owner;
+ ULONG Group;
+ ULONG Sacl;
+ ULONG Dacl;
+ } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
#define CMLTRACE(x, ...)
#undef PAGED_CODE
@@ -118,7 +134,7 @@
#endif
#include <ntdef.h>
- #include <ntddk.h>
+ #include <ntifs.h>
#include <bugcodes.h>
#undef PAGED_CODE
#define PAGED_CODE()
@@ -482,46 +498,104 @@
_Out_ PWCHAR ValueNameBuffer,
_Inout_ ULONG BufferLength);
+
+
/* NT-style Public Cm functions */
+
+//
+// Cell Index Routines
+//
+HCELL_INDEX
+NTAPI
+CmpFindSubKeyByName(
+ IN PHHIVE Hive,
+ IN PCM_KEY_NODE Parent,
+ IN PCUNICODE_STRING SearchName
+);
+
+HCELL_INDEX
+NTAPI
+CmpFindSubKeyByNumber(
+ IN PHHIVE Hive,
+ IN PCM_KEY_NODE Node,
+ IN ULONG Number
+);
+
+ULONG
+NTAPI
+CmpComputeHashKey(
+ IN ULONG Hash,
+ IN PCUNICODE_STRING Name,
+ IN BOOLEAN AllowSeparators
+);
+
+BOOLEAN
+NTAPI
+CmpAddSubKey(
+ IN PHHIVE Hive,
+ IN HCELL_INDEX Parent,
+ IN HCELL_INDEX Child
+);
+
+BOOLEAN
+NTAPI
+CmpRemoveSubKey(
+ IN PHHIVE Hive,
+ IN HCELL_INDEX ParentKey,
+ IN HCELL_INDEX TargetKey
+);
+
+BOOLEAN
+NTAPI
+CmpMarkIndexDirty(
+ IN PHHIVE Hive,
+ HCELL_INDEX ParentKey,
+ HCELL_INDEX TargetKey
+);
+
+
+//
+// Name Functions
+//
LONG
NTAPI
CmpCompareCompressedName(
IN PCUNICODE_STRING SearchName,
IN PWCHAR CompressedName,
IN ULONG NameLength
- );
+);
+
+USHORT
+NTAPI
+CmpNameSize(
+ IN PHHIVE Hive,
+ IN PUNICODE_STRING Name
+);
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
- );
-
-HCELL_INDEX
-NTAPI
-CmpFindSubKeyByNumber(
- IN PHHIVE Hive,
- IN PCM_KEY_NODE Node,
- IN ULONG Number
- );
-
-PCELL_DATA
-NTAPI
-CmpValueToData(
- IN PHHIVE Hive,
- IN PCM_KEY_VALUE Value,
- OUT PULONG Length
- );
+);
+
+USHORT
+NTAPI
+CmpCopyName(
+ IN PHHIVE Hive,
+ IN PWCHAR Destination,
+ IN PUNICODE_STRING Source
+);
+
+VOID
+NTAPI
+CmpCopyCompressedName(
+ IN PWCHAR Destination,
+ IN ULONG DestinationLength,
+ IN PWCHAR Source,
+ IN ULONG SourceLength
+);
BOOLEAN
NTAPI
@@ -531,7 +605,102 @@
IN PUNICODE_STRING Name,
IN PULONG ChildIndex,
IN PHCELL_INDEX CellIndex
- );
+);
+
+
+//
+// Cell Value Routines
+//
+HCELL_INDEX
+NTAPI
+CmpFindValueByName(
+ IN PHHIVE Hive,
+ IN PCM_KEY_NODE KeyNode,
+ IN PUNICODE_STRING Name
+);
+
+PCELL_DATA
+NTAPI
+CmpValueToData(
+ IN PHHIVE Hive,
+ IN PCM_KEY_VALUE Value,
+ OUT PULONG Length
+);
+
+NTSTATUS
+NTAPI
+CmpSetValueDataNew(
+ IN PHHIVE Hive,
+ IN PVOID Data,
+ IN ULONG DataSize,
+ IN ULONG StorageType,
+ IN HCELL_INDEX ValueCell,
+ OUT PHCELL_INDEX DataCell
+);
+
+NTSTATUS
+NTAPI
+CmpAddValueToList(
+ IN PHHIVE Hive,
+ IN HCELL_INDEX ValueCell,
+ IN ULONG Index,
+ IN ULONG Type,
+ IN OUT PCHILD_LIST ChildList
+);
+
+BOOLEAN
+NTAPI
+CmpFreeValue(
+ IN PHHIVE Hive,
+ IN HCELL_INDEX Cell
+);
+
+BOOLEAN
+NTAPI
+CmpMarkValueDataDirty(
+ IN PHHIVE Hive,
+ IN PCM_KEY_VALUE Value
+);
+
+BOOLEAN
+NTAPI
+CmpFreeValueData(
+ IN PHHIVE Hive,
+ IN HCELL_INDEX DataCell,
+ IN ULONG DataLength
+);
+
+NTSTATUS
+NTAPI
+CmpRemoveValueFromList(
+ IN PHHIVE Hive,
+ IN ULONG Index,
+ IN OUT PCHILD_LIST ChildList
+);
+
+BOOLEAN
+NTAPI
+CmpGetValueData(
+ IN PHHIVE Hive,
+ IN PCM_KEY_VALUE Value,
+ IN PULONG Length,
+ OUT PVOID *Buffer,
+ OUT PBOOLEAN BufferAllocated,
+ OUT PHCELL_INDEX CellToRelease
+);
+
+NTSTATUS
+NTAPI
+CmpCopyKeyValueList(
+ IN PHHIVE SourceHive,
+ IN PCHILD_LIST SrcValueList,
+ IN PHHIVE DestinationHive,
+ IN OUT PCHILD_LIST DestValueList,
+ IN HSTORAGE_TYPE StorageType
+);
+
+
+/******************************************************************************/
/* To be implemented by the user of this library */
PVOID
@@ -549,13 +718,4 @@
IN ULONG Quota
);
-VOID
-NTAPI
-CmpCopyCompressedName(
- IN PWCHAR Destination,
- IN ULONG DestinationLength,
- IN PWCHAR Source,
- IN ULONG SourceLength
- );
-
#endif /* _CMLIB_H_ */
Modified: trunk/reactos/lib/cmlib/hivedata.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hivedata.h?rev=7…
==============================================================================
--- trunk/reactos/lib/cmlib/hivedata.h [iso-8859-1] (original)
+++ trunk/reactos/lib/cmlib/hivedata.h [iso-8859-1] Tue Jan 12 21:37:36 2016
@@ -137,7 +137,7 @@
If the hive is volatile, this is the actual pointer to the CM_KEY_NODE */
HCELL_INDEX RootCell;
- /* Size in bytes of the full hive, minus the header */
+ /* Size in bytes of the full hive, minus the header, multiple of the block size (4KB)
*/
ULONG Length;
/* (1?) */
@@ -157,6 +157,8 @@
ULONG BootRecover;
} HBASE_BLOCK, *PHBASE_BLOCK;
+C_ASSERT(sizeof(HBASE_BLOCK) == HBLOCK_SIZE);
+
typedef struct _HBIN
{
/* Bin identifier "hbin" (0x6E696268) */
@@ -165,7 +167,7 @@
/* Block offset of this bin */
HCELL_INDEX FileOffset;
- /* Size in bytes, multiple of the block size (4KB) */
+ /* Size in bytes of this bin, multiple of the block size (4KB) */
ULONG Size;
ULONG Reserved1[2];
@@ -282,10 +284,13 @@
PRELEASE_CELL_ROUTINE ReleaseCellRoutine;
PALLOCATE_ROUTINE Allocate;
PFREE_ROUTINE Free;
+ PFILE_SET_SIZE_ROUTINE FileSetSize;
+ PFILE_WRITE_ROUTINE FileWrite;
PFILE_READ_ROUTINE FileRead;
- PFILE_WRITE_ROUTINE FileWrite;
- PFILE_SET_SIZE_ROUTINE FileSetSize;
PFILE_FLUSH_ROUTINE FileFlush;
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+ PVOID HiveLoadFailure; // PHIVE_LOAD_FAILURE
+#endif
PHBASE_BLOCK BaseBlock;
RTL_BITMAP DirtyVector;
ULONG DirtyCount;
@@ -294,14 +299,23 @@
ULONG Cluster;
BOOLEAN Flat;
BOOLEAN ReadOnly;
+#if (NTDDI_VERSION < NTDDI_VISTA) // NTDDI_LONGHORN
BOOLEAN Log;
+#endif
BOOLEAN DirtyFlag;
+#if (NTDDI_VERSION >= NTDDI_VISTA) // NTDDI_LONGHORN
ULONG HvBinHeadersUse;
ULONG HvFreeCellsUse;
- ULONG HvUsedcellsUse;
+ ULONG HvUsedCellsUse;
ULONG CmUsedCellsUse;
+#endif
ULONG HiveFlags;
+#if (NTDDI_VERSION < NTDDI_VISTA) // NTDDI_LONGHORN
ULONG LogSize;
+#else
+ ULONG CurrentLog;
+ ULONG LogSize[2];
+#endif
ULONG RefreshCount;
ULONG StorageTypeCount;
ULONG Version;
Modified: trunk/reactos/ntoskrnl/include/internal/cm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/cm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/cm.h [iso-8859-1] Tue Jan 12 21:37:36 2016
@@ -1089,58 +1089,6 @@
);
//
-// Name Functions
-//
-LONG
-NTAPI
-CmpCompareCompressedName(
- IN PCUNICODE_STRING SearchName,
- IN PWCHAR CompressedName,
- IN ULONG NameLength
-);
-
-USHORT
-NTAPI
-CmpNameSize(
- IN PHHIVE Hive,
- IN PUNICODE_STRING Name
-);
-
-USHORT
-NTAPI
-CmpCompressedNameSize(
- IN PWCHAR Name,
- IN ULONG Length
-);
-
-VOID
-NTAPI
-CmpCopyCompressedName(
- IN PWCHAR Destination,
- IN ULONG DestinationLength,
- IN PWCHAR Source,
- IN ULONG SourceLength
-);
-
-USHORT
-NTAPI
-CmpCopyName(
- IN PHHIVE Hive,
- IN PWCHAR Destination,
- IN PUNICODE_STRING Source
-);
-
-BOOLEAN
-NTAPI
-CmpFindNameInList(
- IN PHHIVE Hive,
- IN PCHILD_LIST ChildList,
- IN PUNICODE_STRING Name,
- IN PULONG ChildIndex,
- IN PHCELL_INDEX CellIndex
-);
-
-//
// Parse Routines
//
BOOLEAN
@@ -1219,149 +1167,6 @@
);
//
-// Cell Index Routines
-//
-
-HCELL_INDEX
-NTAPI
-CmpFindSubKeyByName(
- IN PHHIVE Hive,
- IN PCM_KEY_NODE Parent,
- IN PCUNICODE_STRING SearchName
-);
-
-HCELL_INDEX
-NTAPI
-CmpFindSubKeyByNumber(
- IN PHHIVE Hive,
- IN PCM_KEY_NODE Node,
- IN ULONG Number
-);
-
-ULONG
-NTAPI
-CmpComputeHashKey(
- IN ULONG Hash,
- IN PCUNICODE_STRING Name,
- IN BOOLEAN AllowSeparators
-);
-
-BOOLEAN
-NTAPI
-CmpAddSubKey(
- IN PHHIVE Hive,
- IN HCELL_INDEX Parent,
- IN HCELL_INDEX Child
-);
-
-BOOLEAN
-NTAPI
-CmpRemoveSubKey(
- IN PHHIVE Hive,
- IN HCELL_INDEX ParentKey,
- IN HCELL_INDEX TargetKey
-);
-
-BOOLEAN
-NTAPI
-CmpMarkIndexDirty(
- IN PHHIVE Hive,
- HCELL_INDEX ParentKey,
- HCELL_INDEX TargetKey
-);
-
-//
-// Cell Value Routines
-//
-HCELL_INDEX
-NTAPI
-CmpFindValueByName(
- IN PHHIVE Hive,
- IN PCM_KEY_NODE KeyNode,
- IN PUNICODE_STRING Name
-);
-
-PCELL_DATA
-NTAPI
-CmpValueToData(
- IN PHHIVE Hive,
- IN PCM_KEY_VALUE Value,
- OUT PULONG Length
-);
-
-NTSTATUS
-NTAPI
-CmpSetValueDataNew(
- IN PHHIVE Hive,
- IN PVOID Data,
- IN ULONG DataSize,
- IN ULONG StorageType,
- IN HCELL_INDEX ValueCell,
- OUT PHCELL_INDEX DataCell
-);
-
-NTSTATUS
-NTAPI
-CmpAddValueToList(
- IN PHHIVE Hive,
- IN HCELL_INDEX ValueCell,
- IN ULONG Index,
- IN ULONG Type,
- IN OUT PCHILD_LIST ChildList
-);
-
-BOOLEAN
-NTAPI
-CmpFreeValue(
- IN PHHIVE Hive,
- IN HCELL_INDEX Cell
-);
-
-BOOLEAN
-NTAPI
-CmpMarkValueDataDirty(
- IN PHHIVE Hive,
- IN PCM_KEY_VALUE Value
-);
-
-BOOLEAN
-NTAPI
-CmpFreeValueData(
- IN PHHIVE Hive,
- IN HCELL_INDEX DataCell,
- IN ULONG DataLength
-);
-
-NTSTATUS
-NTAPI
-CmpRemoveValueFromList(
- IN PHHIVE Hive,
- IN ULONG Index,
- IN OUT PCHILD_LIST ChildList
-);
-
-BOOLEAN
-NTAPI
-CmpGetValueData(
- IN PHHIVE Hive,
- IN PCM_KEY_VALUE Value,
- IN PULONG Length,
- OUT PVOID *Buffer,
- OUT PBOOLEAN BufferAllocated,
- OUT PHCELL_INDEX CellToRelease
-);
-
-NTSTATUS
-NTAPI
-CmpCopyKeyValueList(
- IN PHHIVE SourceHive,
- IN PCHILD_LIST SrcValueList,
- IN PHHIVE DestinationHive,
- IN OUT PCHILD_LIST DestValueList,
- IN HSTORAGE_TYPE StorageType
-);
-
-//
// Boot Routines
//
HCELL_INDEX
@@ -1379,7 +1184,6 @@
IN PVOID SystemHiveData,
IN PCM_SYSTEM_CONTROL_VECTOR ControlVector
);
-
//
// Hardware Configuration Routines