Author: ion Date: Fri Oct 6 08:34:46 2006 New Revision: 24419
URL: http://svn.reactos.org/svn/reactos?rev=24419&view=rev Log: - Implement CmpNameSize, CmpCopyName. - Fix some bugs in cminit.c
Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cm.h branches/alex-cm-branch/reactos/ntoskrnl/cm/cminit.c branches/alex-cm-branch/reactos/ntoskrnl/cm/cmname.c
Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cm.h URL: http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl/... ============================================================================== --- branches/alex-cm-branch/reactos/ntoskrnl/cm/cm.h (original) +++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cm.h Fri Oct 6 08:34:46 2006 @@ -731,6 +731,21 @@ IN ULONG NameLength );
+USHORT +NTAPI +CmpNameSize( + IN PHHIVE Hive, + IN PUNICODE_STRING Name +); + +USHORT +NTAPI +CmpCopyName( + IN PHHIVE Hive, + IN PWCHAR Destination, + IN PUNICODE_STRING Source +); + // // Flush Routines //
Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cminit.c URL: http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl/... ============================================================================== --- branches/alex-cm-branch/reactos/ntoskrnl/cm/cminit.c (original) +++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cminit.c Fri Oct 6 08:34:46 2006 @@ -25,6 +25,16 @@
ULONG CmpCallBackCount;
+GENERIC_MAPPING CmpKeyMapping = +{ + KEY_READ, + KEY_WRITE, + KEY_EXECUTE, + KEY_ALL_ACCESS +}; + +EX_CALLBACK CmpCallBackVector[CMP_MAX_CALLBACKS]; + /* FUNCTIONS *****************************************************************/
NTSTATUS @@ -51,7 +61,7 @@ Cell = HvGetCell(Hive, *Index);
/* Fill out the cell */ - Cell->u.KeyNode.Signature = CM_KEY_NODE_SIGNATURE; + Cell->u.KeyNode.Signature = (USHORT)CM_KEY_NODE_SIGNATURE; Cell->u.KeyNode.Flags = KEY_HIVE_ENTRY | KEY_NO_DELETE; KeQuerySystemTime(&SystemTime); Cell->u.KeyNode.LastWriteTime = SystemTime; @@ -93,7 +103,6 @@ HCELL_INDEX RootCell; PCM_KEY_BODY Key; PVOID KeyBody; - HANDLE KeyHandle; PCM_KEY_CONTROL_BLOCK RootKcb; UNICODE_STRING RootName = RTL_CONSTANT_STRING(L"\REGISTRY"); OBJECT_ATTRIBUTES ObjectAttributes; @@ -148,7 +157,7 @@ if (!NT_SUCCESS(Status)) return Status;
/* Now reference it as a keep alive and return the status */ - Status = ObReferenceObjectByHandle(KeyHandle, + Status = ObReferenceObjectByHandle(CmpRegistryRootHandle, KEY_READ, NULL, KernelMode, @@ -183,8 +192,6 @@ UNICODE_STRING KeyName, ValueName; HANDLE KeyHandle; NTSTATUS Status; - PCHAR CommandLine; - PCHAR SystemBootDevice; ULONG i = 0; ASSERT(LoaderBlock != NULL);
@@ -225,7 +232,6 @@
/* Free the buffers */ RtlFreeUnicodeString(&ValueName); - ExFreePool(SystemBootDevice);
/* Close the key and return */ NtClose(KeyHandle); @@ -274,7 +280,7 @@ RtlInitUnicodeString(&Name, L"Key"); ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); ObjectTypeInitializer.DefaultPagedPoolCharge = sizeof(CM_KEY_BODY); - ObjectTypeInitializer.GenericMapping = NULL; + ObjectTypeInitializer.GenericMapping = CmpKeyMapping; ObjectTypeInitializer.PoolType = PagedPool; ObjectTypeInitializer.SecurityRequired = TRUE; ObjectTypeInitializer.ValidAccessMask = KEY_ALL_ACCESS;
Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cmname.c URL: http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl/... ============================================================================== --- branches/alex-cm-branch/reactos/ntoskrnl/cm/cmname.c (original) +++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cmname.c Fri Oct 6 08:34:46 2006 @@ -13,6 +13,62 @@ #include <debug.h>
/* FUNCTIONS *****************************************************************/ + +USHORT +NTAPI +CmpCopyName(IN PHHIVE Hive, + IN PWCHAR Destination, + IN PUNICODE_STRING Source) +{ + ULONG i; + + /* Check for old hives */ + if (Hive->Version == 1) + { + /* Just copy the source directly */ + RtlCopyMemory(Destination, Source->Buffer, Source->Length); + return Source->Length; + } + + /* For new versions, check for compressed name */ + for (i = 0; i < (Source->Length / sizeof(WCHAR)); i++) + { + /* Check if the name is non compressed */ + if ((Source->Buffer[i]) > -1) + { + /* Do the copy */ + RtlCopyMemory(Destination, Source->Buffer, Source->Length); + return Source->Length; + } + + /* Copy this character */ + Destination[i] = Source->Buffer[i]; + } + + /* Compressed name, return length */ + return Source->Length / sizeof(WCHAR); +} + +USHORT +NTAPI +CmpNameSize(IN PHHIVE Hive, + IN PUNICODE_STRING Name) +{ + ULONG i; + + /* For old hives, just retun the length */ + if (Hive->Version == 1) return Name->Length; + + /* For new versions, check for compressed name */ + for (i = 0; i < (Name->Length / sizeof(WCHAR)); i++) + { + /* Check if the name is non compressed */ + if ((Name->Buffer[i]) > -1) return Name->Length; + } + + /* Compressed name, return length */ + return Name->Length / sizeof(WCHAR); +}
LONG NTAPI