Implemented registry links (REG_LINK).

Create the 'CurrentControlSet' link after the registry has been initialized.

svn path=/trunk/; revision=3130
This commit is contained in:
Eric Kohl 2002-06-19 22:32:47 +00:00
parent 5c4728ed0a
commit 79d575aef4
8 changed files with 683 additions and 405 deletions

View file

@ -87,9 +87,6 @@ typedef struct _KEY_VALUE_PARTIAL_INFORMATION
UCHAR Data[1]; UCHAR Data[1];
} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION; } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
#define REG_OPTION_CREATE_LINK 0x00000002
#define REG_OPTION_BACKUP_RESTORE 0x00000004
/* used by [Nt/Zw]QueryMultipleValueKey */ /* used by [Nt/Zw]QueryMultipleValueKey */

View file

@ -1,4 +1,4 @@
/* $Id: registry.h,v 1.2 2001/05/30 19:58:48 ekohl Exp $ /* $Id: registry.h,v 1.3 2002/06/19 22:30:29 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -26,15 +26,18 @@
#define KEY_EXECUTE (0x20019L) #define KEY_EXECUTE (0x20019L)
#define KEY_ALL_ACCESS (0xf003fL) #define KEY_ALL_ACCESS (0xf003fL)
/* Key create options */
/* RegCreateKeyEx */ #define REG_OPTION_NON_VOLATILE (0x0L)
#define REG_OPTION_VOLATILE (0x1L) #define REG_OPTION_VOLATILE (0x1L)
#define REG_OPTION_NON_VOLATILE (0L) #define REG_OPTION_CREATE_LINK (0x2L)
#define REG_OPTION_BACKUP_RESTORE (0x8L)
#define REG_OPTION_OPEN_LINK (0x8L)
/* Key create/open disposition */
#define REG_CREATED_NEW_KEY (0x1L) #define REG_CREATED_NEW_KEY (0x1L)
#define REG_OPENED_EXISTING_KEY (0x2L) #define REG_OPENED_EXISTING_KEY (0x2L)
/* Value types */
/* RegEnumValue */
#define REG_NONE (0) #define REG_NONE (0)
#define REG_SZ (1) #define REG_SZ (1)
#define REG_EXPAND_SZ (2) #define REG_EXPAND_SZ (2)

View file

@ -26,6 +26,21 @@
#define SAM_REG_FILE L"\\SystemRoot\\System32\\Config\\SAM" #define SAM_REG_FILE L"\\SystemRoot\\System32\\Config\\SAM"
#define SEC_REG_FILE L"\\SystemRoot\\System32\\Config\\SECURITY" #define SEC_REG_FILE L"\\SystemRoot\\System32\\Config\\SECURITY"
#define REG_BLOCK_SIZE 4096
#define REG_HBIN_DATA_OFFSET 32
#define REG_BIN_ID 0x6e696268
#define REG_INIT_BLOCK_LIST_SIZE 32
#define REG_INIT_HASH_TABLE_SIZE 3
#define REG_EXTEND_HASH_TABLE_SIZE 4
#define REG_VALUE_LIST_CELL_MULTIPLE 4
#define REG_KEY_CELL_ID 0x6b6e
#define REG_HASH_TABLE_BLOCK_ID 0x666c
#define REG_VALUE_CELL_ID 0x6b76
#define REG_LINK_KEY_CELL_TYPE 0x10
#define REG_KEY_CELL_TYPE 0x20
#define REG_ROOT_KEY_CELL_TYPE 0x2c
#define REG_HIVE_ID 0x66676572
#define REGISTRY_FILE_MAGIC "REGEDIT4" #define REGISTRY_FILE_MAGIC "REGEDIT4"
#define REG_MACHINE_STD_HANDLE_NAME "HKEY_LOCAL_MACHINE" #define REG_MACHINE_STD_HANDLE_NAME "HKEY_LOCAL_MACHINE"
@ -247,6 +262,7 @@ typedef struct _REGISTRY_HIVE
atempts to access the key must not succeed */ atempts to access the key must not succeed */
#define KO_MARKED_FOR_DELETE 0x00000001 #define KO_MARKED_FOR_DELETE 0x00000001
/* Type defining the Object Manager Key Object */ /* Type defining the Object Manager Key Object */
typedef struct _KEY_OBJECT typedef struct _KEY_OBJECT
{ {
@ -294,6 +310,9 @@ typedef struct _KEY_OBJECT
extern BOOLEAN CmiDoVerify; extern BOOLEAN CmiDoVerify;
extern PREGISTRY_HIVE CmiVolatileHive;
extern POBJECT_TYPE CmiKeyType;
extern KSPIN_LOCK CmiKeyListLock;
VOID VOID

View file

@ -96,7 +96,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
DesiredAccess, DesiredAccess,
NULL, NULL,
CmiKeyType, CmiKeyType,
(PVOID*) &KeyObject); (PVOID*)&KeyObject);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return(Status); return(Status);
@ -825,10 +825,9 @@ NtOpenKey(OUT PHANDLE KeyHandle,
&Object, &Object,
&RemainingPath, &RemainingPath,
CmiKeyType); CmiKeyType);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return Status; return(Status);
} }
VERIFY_KEY_OBJECT((PKEY_OBJECT) Object); VERIFY_KEY_OBJECT((PKEY_OBJECT) Object);
@ -838,18 +837,17 @@ NtOpenKey(OUT PHANDLE KeyHandle,
if ((RemainingPath.Buffer != NULL) && (RemainingPath.Buffer[0] != 0)) if ((RemainingPath.Buffer != NULL) && (RemainingPath.Buffer[0] != 0))
{ {
ObDereferenceObject(Object); ObDereferenceObject(Object);
return STATUS_UNSUCCESSFUL; return(STATUS_UNSUCCESSFUL);
} }
/* Fail if the key has been deleted */ /* Fail if the key has been deleted */
if (((PKEY_OBJECT)Object)->Flags & KO_MARKED_FOR_DELETE) if (((PKEY_OBJECT)Object)->Flags & KO_MARKED_FOR_DELETE)
{ {
ObDereferenceObject(Object); ObDereferenceObject(Object);
return STATUS_UNSUCCESSFUL; return(STATUS_UNSUCCESSFUL);
} }
Status = ObCreateHandle( Status = ObCreateHandle(PsGetCurrentProcess(),
PsGetCurrentProcess(),
Object, Object,
DesiredAccess, DesiredAccess,
FALSE, FALSE,
@ -858,10 +856,10 @@ NtOpenKey(OUT PHANDLE KeyHandle,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return Status; return(Status);
} }
return STATUS_SUCCESS; return(STATUS_SUCCESS);
} }
@ -1185,8 +1183,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
NTSTATUS STDCALL NTSTATUS STDCALL
NtSetValueKey( NtSetValueKey(IN HANDLE KeyHandle,
IN HANDLE KeyHandle,
IN PUNICODE_STRING ValueName, IN PUNICODE_STRING ValueName,
IN ULONG TitleIndex, IN ULONG TitleIndex,
IN ULONG Type, IN ULONG Type,
@ -1203,6 +1200,7 @@ NtSetValueKey(
PDATA_CELL DataCell; PDATA_CELL DataCell;
PDATA_CELL NewDataCell; PDATA_CELL NewDataCell;
PHBIN pBin; PHBIN pBin;
ULONG DesiredAccess;
// KIRQL OldIrql; // KIRQL OldIrql;
DPRINT("KeyHandle %x ValueName %S Type %d\n", DPRINT("KeyHandle %x ValueName %S Type %d\n",
@ -1211,12 +1209,16 @@ NtSetValueKey(
wcstombs(ValueName2,ValueName->Buffer, ValueName->Length >> 1); wcstombs(ValueName2,ValueName->Buffer, ValueName->Length >> 1);
ValueName2[ValueName->Length>>1] = 0; ValueName2[ValueName->Length>>1] = 0;
DesiredAccess = KEY_SET_VALUE;
if (Type == REG_LINK)
DesiredAccess |= KEY_CREATE_LINK;
/* Verify that the handle is valid and is a registry key */ /* Verify that the handle is valid and is a registry key */
Status = ObReferenceObjectByHandle(KeyHandle, Status = ObReferenceObjectByHandle(KeyHandle,
KEY_SET_VALUE, DesiredAccess,
CmiKeyType, CmiKeyType,
UserMode, UserMode,
(PVOID *) &KeyObject, (PVOID *)&KeyObject,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return(Status); return(Status);
@ -1311,6 +1313,11 @@ NtSetValueKey(
ValueCell->DataOffset = NewOffset; ValueCell->DataOffset = NewOffset;
} }
if (strcmp(ValueName2, "SymbolicLinkValue") == 0)
{
KeyCell->Type = REG_LINK_KEY_CELL_TYPE;
}
/* Update time of heap */ /* Update time of heap */
if (IsPermanentHive(RegistryHive) && CmiGetBlock(RegistryHive, VBOffset, &pBin)) if (IsPermanentHive(RegistryHive) && CmiGetBlock(RegistryHive, VBOffset, &pBin))
{ {

View file

@ -21,21 +21,6 @@
#include "cm.h" #include "cm.h"
#define REG_BLOCK_SIZE 4096
#define REG_HBIN_DATA_OFFSET 32
#define REG_BIN_ID 0x6e696268
#define REG_INIT_BLOCK_LIST_SIZE 32
#define REG_INIT_HASH_TABLE_SIZE 3
#define REG_EXTEND_HASH_TABLE_SIZE 4
#define REG_VALUE_LIST_CELL_MULTIPLE 4
#define REG_KEY_CELL_ID 0x6b6e
#define REG_HASH_TABLE_BLOCK_ID 0x666c
#define REG_VALUE_CELL_ID 0x6b76
#define REG_KEY_CELL_TYPE 0x20
#define REG_ROOT_KEY_CELL_TYPE 0x2c
#define REG_HIVE_ID 0x66676572
extern PREGISTRY_HIVE CmiVolatileHive;
BOOLEAN CmiDoVerify = FALSE; BOOLEAN CmiDoVerify = FALSE;
@ -1344,7 +1329,6 @@ CmiDeleteValueFromKey(IN PREGISTRY_HIVE RegistryHive,
{ {
PVALUE_LIST_CELL ValueListCell; PVALUE_LIST_CELL ValueListCell;
PVALUE_CELL CurValueCell; PVALUE_CELL CurValueCell;
PHBIN pBin;
ULONG i; ULONG i;
ValueListCell = CmiGetBlock(RegistryHive, KeyCell->ValuesOffset, NULL); ValueListCell = CmiGetBlock(RegistryHive, KeyCell->ValuesOffset, NULL);
@ -1358,7 +1342,7 @@ CmiDeleteValueFromKey(IN PREGISTRY_HIVE RegistryHive,
for (i = 0; i < KeyCell->NumberOfValues; i++) for (i = 0; i < KeyCell->NumberOfValues; i++)
{ {
CurValueCell = CmiGetBlock(RegistryHive, ValueListCell->Values[i], &pBin); CurValueCell = CmiGetBlock(RegistryHive, ValueListCell->Values[i], NULL);
if ((CurValueCell != NULL) && if ((CurValueCell != NULL) &&
(CurValueCell->NameSize == strlen(ValueName)) && (CurValueCell->NameSize == strlen(ValueName)) &&
(memcmp(CurValueCell->Name, ValueName, strlen(ValueName)) == 0)) (memcmp(CurValueCell->Name, ValueName, strlen(ValueName)) == 0))
@ -1376,8 +1360,6 @@ CmiDeleteValueFromKey(IN PREGISTRY_HIVE RegistryHive,
KeyCell->NumberOfValues -= 1; KeyCell->NumberOfValues -= 1;
CmiDestroyValueCell(RegistryHive, CurValueCell, ValueListCell->Values[i]); CmiDestroyValueCell(RegistryHive, CurValueCell, ValueListCell->Values[i]);
/* update time of heap */
ZwQuerySystemTime((PTIME) &pBin->DateModified);
break; break;
} }
CmiReleaseBlock(RegistryHive, CurValueCell); CmiReleaseBlock(RegistryHive, CurValueCell);
@ -1864,6 +1846,9 @@ CmiGetBlock(PREGISTRY_HIVE RegistryHive,
BLOCK_OFFSET BlockOffset, BLOCK_OFFSET BlockOffset,
PHBIN * ppBin) PHBIN * ppBin)
{ {
if (ppBin)
*ppBin = NULL;
if ((BlockOffset == 0) || (BlockOffset == -1)) if ((BlockOffset == 0) || (BlockOffset == -1))
return NULL; return NULL;

View file

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.72 2002/06/16 11:45:06 ekohl Exp $ /* $Id: registry.c,v 1.73 2002/06/19 22:31:33 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -42,6 +42,10 @@ VOID
CmiCheckKey(BOOLEAN Verbose, CmiCheckKey(BOOLEAN Verbose,
HANDLE Key); HANDLE Key);
static NTSTATUS
CmiCreateCurrentControlSetLink(VOID);
/* FUNCTIONS ****************************************************************/
VOID VOID
CmiCheckSubKeys(BOOLEAN Verbose, CmiCheckSubKeys(BOOLEAN Verbose,
@ -471,7 +475,9 @@ CmInit2(PCHAR CommandLine)
/* FIXME: Store current command line */ /* FIXME: Store current command line */
/* FIXME: Create the 'CurrentControlSet' link. */ /* Create the 'CurrentControlSet' link. */
CmiCreateCurrentControlSetLink();
/* Set PICE 'Start' value to 1, if PICE debugging is enabled */ /* Set PICE 'Start' value to 1, if PICE debugging is enabled */
PiceStart = 4; PiceStart = 4;
@ -505,6 +511,100 @@ CmInit2(PCHAR CommandLine)
} }
static NTSTATUS
CmiCreateCurrentControlSetLink(VOID)
{
RTL_QUERY_REGISTRY_TABLE QueryTable[5];
WCHAR TargetNameBuffer[80];
ULONG TargetNameLength;
UNICODE_STRING LinkName;
UNICODE_STRING LinkValue;
ULONG CurrentSet;
ULONG DefaultSet;
ULONG Failed;
ULONG LastKnownGood;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE KeyHandle;
DPRINT("CmiCreateCurrentControlSetLink() called\n");
RtlZeroMemory(&QueryTable, sizeof(QueryTable));
QueryTable[0].Name = L"Current";
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[0].EntryContext = &CurrentSet;
QueryTable[1].Name = L"Default";
QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[1].EntryContext = &DefaultSet;
QueryTable[2].Name = L"Failed";
QueryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[2].EntryContext = &Failed;
QueryTable[3].Name = L"LastKnownGood";
QueryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[3].EntryContext = &LastKnownGood;
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
L"\\Registry\\Machine\\SYSTEM\\Select",
QueryTable,
NULL,
NULL);
if (!NT_SUCCESS(Status))
{
return(Status);
}
DPRINT("Current %ld Default %ld\n", CurrentSet, DefaultSet);
swprintf(TargetNameBuffer,
L"\\Registry\\Machine\\SYSTEM\\ControlSet%03lu",
CurrentSet);
TargetNameLength = wcslen(TargetNameBuffer) * sizeof(WCHAR);
DPRINT("Link target '%S'\n", TargetNameBuffer);
RtlInitUnicodeString(&LinkName,
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet");
InitializeObjectAttributes(&ObjectAttributes,
&LinkName,
OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_OPENLINK,
NULL,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_ALL_ACCESS | KEY_CREATE_LINK,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
return(Status);
}
RtlInitUnicodeString(&LinkValue,
L"SymbolicLinkValue");
Status=NtSetValueKey(KeyHandle,
&LinkValue,
0,
REG_LINK,
(PVOID)TargetNameBuffer,
TargetNameLength);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
}
NtClose(KeyHandle);
return(Status);
}
NTSTATUS NTSTATUS
CmiConnectHive(PWSTR FileName, CmiConnectHive(PWSTR FileName,
PWSTR FullName, PWSTR FullName,

View file

@ -13,14 +13,20 @@
#include <string.h> #include <string.h>
#include <internal/pool.h> #include <internal/pool.h>
#include <internal/registry.h> #include <internal/registry.h>
#include <ntos/minmax.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
#include "cm.h" #include "cm.h"
extern POBJECT_TYPE CmiKeyType;
extern KSPIN_LOCK CmiKeyListLock; static NTSTATUS
CmiGetLinkTarget(PREGISTRY_HIVE RegistryHive,
PKEY_CELL KeyCell,
PUNICODE_STRING TargetPath);
/* FUNCTONS *****************************************************************/
NTSTATUS STDCALL NTSTATUS STDCALL
CmiObjectParse(PVOID ParsedObject, CmiObjectParse(PVOID ParsedObject,
@ -37,6 +43,8 @@ CmiObjectParse(PVOID ParsedObject,
CHAR cPath[MAX_PATH]; CHAR cPath[MAX_PATH];
NTSTATUS Status; NTSTATUS Status;
PWSTR end; PWSTR end;
UNICODE_STRING LinkPath;
UNICODE_STRING TargetPath;
ParsedKey = ParsedObject; ParsedKey = ParsedObject;
@ -50,6 +58,8 @@ CmiObjectParse(PVOID ParsedObject,
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
DPRINT("Path '%S'\n", *Path);
if ((*Path[0]) == '\\') if ((*Path[0]) == '\\')
{ {
end = wcschr((*Path) + 1, '\\'); end = wcschr((*Path) + 1, '\\');
@ -77,14 +87,56 @@ CmiObjectParse(PVOID ParsedObject,
cPath, cPath,
0, 0,
Attributes); Attributes);
if (!NT_SUCCESS(Status) || (SubKeyCell == NULL)) if (!NT_SUCCESS(Status) || (SubKeyCell == NULL))
{ {
if (end != NULL) if (end != NULL)
{ {
*end = '\\'; *end = '\\';
} }
return STATUS_UNSUCCESSFUL; return(STATUS_UNSUCCESSFUL);
}
if ((SubKeyCell->Type == REG_LINK_KEY_CELL_TYPE) &&
!((Attributes & OBJ_OPENLINK) && (end == NULL)))
{
RtlInitUnicodeString(&LinkPath, NULL);
Status = CmiGetLinkTarget(ParsedKey->RegistryHive,
SubKeyCell,
&LinkPath);
if (NT_SUCCESS(Status))
{
DPRINT("LinkPath '%wZ'\n", &LinkPath);
/* build new FullPath for reparsing */
TargetPath.MaximumLength = LinkPath.MaximumLength;
if (end != NULL)
{
*end = '\\';
TargetPath.MaximumLength += (wcslen(end) * sizeof(WCHAR));
}
TargetPath.Length = TargetPath.MaximumLength - sizeof(WCHAR);
TargetPath.Buffer = ExAllocatePool(NonPagedPool,
TargetPath.MaximumLength);
wcscpy(TargetPath.Buffer, LinkPath.Buffer);
if (end != NULL)
{
wcscat(TargetPath.Buffer, end);
}
RtlFreeUnicodeString(FullPath);
RtlFreeUnicodeString(&LinkPath);
FullPath->Length = TargetPath.Length;
FullPath->MaximumLength = TargetPath.MaximumLength;
FullPath->Buffer = TargetPath.Buffer;
DPRINT("FullPath '%wZ'\n", FullPath);
/* reinitialize Path for reparsing */
*Path = FullPath->Buffer;
*NextObject = NULL;
return(STATUS_REPARSE);
}
} }
/* Create new key object and put into linked list */ /* Create new key object and put into linked list */
@ -93,11 +145,10 @@ CmiObjectParse(PVOID ParsedObject,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
NULL, NULL,
CmiKeyType, CmiKeyType,
(PVOID*) &FoundObject); (PVOID*)&FoundObject);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return Status; return(Status);
} }
FoundObject->Flags = 0; FoundObject->Flags = 0;
@ -111,6 +162,49 @@ CmiObjectParse(PVOID ParsedObject,
} }
else else
{ {
if ((FoundObject->KeyCell->Type == REG_LINK_KEY_CELL_TYPE) &&
!((Attributes & OBJ_OPENLINK) && (end == NULL)))
{
RtlInitUnicodeString(&LinkPath, NULL);
Status = CmiGetLinkTarget(FoundObject->RegistryHive,
FoundObject->KeyCell,
&LinkPath);
if (NT_SUCCESS(Status))
{
DPRINT("LinkPath '%wZ'\n", &LinkPath);
/* build new FullPath for reparsing */
TargetPath.MaximumLength = LinkPath.MaximumLength;
if (end != NULL)
{
*end = '\\';
TargetPath.MaximumLength += (wcslen(end) * sizeof(WCHAR));
}
TargetPath.Length = TargetPath.MaximumLength - sizeof(WCHAR);
TargetPath.Buffer = ExAllocatePool(NonPagedPool,
TargetPath.MaximumLength);
wcscpy(TargetPath.Buffer, LinkPath.Buffer);
if (end != NULL)
{
wcscat(TargetPath.Buffer, end);
}
RtlFreeUnicodeString(FullPath);
RtlFreeUnicodeString(&LinkPath);
FullPath->Length = TargetPath.Length;
FullPath->MaximumLength = TargetPath.MaximumLength;
FullPath->Buffer = TargetPath.Buffer;
DPRINT("FullPath '%wZ'\n", FullPath);
/* reinitialize Path for reparsing */
*Path = FullPath->Buffer;
*NextObject = NULL;
return(STATUS_REPARSE);
}
}
ObReferenceObjectByPointer(FoundObject, ObReferenceObjectByPointer(FoundObject,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
NULL, NULL,
@ -129,11 +223,11 @@ CmiObjectParse(PVOID ParsedObject,
*Path = NULL; *Path = NULL;
} }
VERIFY_KEY_OBJECT(FoundObject); VERIFY_KEY_OBJECT(FoundObject);
*NextObject = FoundObject; *NextObject = FoundObject;
return STATUS_SUCCESS; return(STATUS_SUCCESS);
} }
@ -144,17 +238,18 @@ CmiObjectCreate(PVOID ObjectBody,
struct _OBJECT_ATTRIBUTES* ObjectAttributes) struct _OBJECT_ATTRIBUTES* ObjectAttributes)
{ {
PKEY_OBJECT pKey = ObjectBody; PKEY_OBJECT pKey = ObjectBody;
pKey->ParentKey = Parent; pKey->ParentKey = Parent;
if (RemainingPath) if (RemainingPath)
{ {
if(RemainingPath[0]== L'\\') if(RemainingPath[0]== L'\\')
{ {
pKey->Name = (PCHAR) (&RemainingPath[1]); pKey->Name = (PCHAR)(&RemainingPath[1]);
pKey->NameSize = wcslen(RemainingPath) - 1; pKey->NameSize = wcslen(RemainingPath) - 1;
} }
else else
{ {
pKey->Name = (PCHAR) RemainingPath; pKey->Name = (PCHAR)RemainingPath;
pKey->NameSize = wcslen(RemainingPath); pKey->NameSize = wcslen(RemainingPath);
} }
} }
@ -194,6 +289,7 @@ CmiObjectDelete(PVOID DeletedObject)
} }
} }
VOID VOID
CmiAddKeyToList(PKEY_OBJECT ParentKey, CmiAddKeyToList(PKEY_OBJECT ParentKey,
PKEY_OBJECT NewKey) PKEY_OBJECT NewKey)
@ -227,7 +323,7 @@ CmiAddKeyToList(PKEY_OBJECT ParentKey,
/* to allow a dichotomic search */ /* to allow a dichotomic search */
ParentKey->SubKeys[ParentKey->NumberOfSubKeys++] = NewKey; ParentKey->SubKeys[ParentKey->NumberOfSubKeys++] = NewKey;
DPRINT("Reference parent key: 0x%x\n", ParentKey); DPRINT("Reference parent key: 0x%x\n", ParentKey);
ObReferenceObjectByPointer(ParentKey, ObReferenceObjectByPointer(ParentKey,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
@ -259,13 +355,14 @@ CmiRemoveKeyFromList(PKEY_OBJECT KeyToRemove)
ParentKey->NumberOfSubKeys--; ParentKey->NumberOfSubKeys--;
KeReleaseSpinLock(&CmiKeyListLock, OldIrql); KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
DPRINT("Dereference parent key: 0x%x\n", ParentKey); DPRINT("Dereference parent key: 0x%x\n", ParentKey);
ObDereferenceObject(ParentKey); ObDereferenceObject(ParentKey);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
} }
KeReleaseSpinLock(&CmiKeyListLock, OldIrql); KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -312,3 +409,63 @@ CmiScanKeyList(PKEY_OBJECT Parent,
return NULL; return NULL;
} }
static NTSTATUS
CmiGetLinkTarget(PREGISTRY_HIVE RegistryHive,
PKEY_CELL KeyCell,
PUNICODE_STRING TargetPath)
{
PVALUE_CELL ValueCell;
PDATA_CELL DataCell;
NTSTATUS Status;
/* Get Value block of interest */
Status = CmiScanKeyForValue(RegistryHive,
KeyCell,
"SymbolicLinkValue",
&ValueCell,
NULL);
if (!NT_SUCCESS(Status))
{
return(Status);
}
if (ValueCell->DataType != REG_LINK)
{
DPRINT1("Type != REG_LINK\n!");
return(STATUS_UNSUCCESSFUL);
}
if (TargetPath->Buffer == NULL && TargetPath->MaximumLength == 0)
{
TargetPath->Length = 0;
TargetPath->MaximumLength = ValueCell->DataSize + sizeof(WCHAR);
TargetPath->Buffer = ExAllocatePool(NonPagedPool,
TargetPath->MaximumLength);
}
TargetPath->Length = min(TargetPath->MaximumLength - sizeof(WCHAR),
ValueCell->DataSize);
if (ValueCell->DataSize > 0)
{
DataCell = CmiGetBlock(RegistryHive, ValueCell->DataOffset, NULL);
RtlCopyMemory(TargetPath->Buffer,
DataCell->Data,
TargetPath->Length);
TargetPath->Buffer[TargetPath->Length / sizeof(WCHAR)] = 0;
CmiReleaseBlock(RegistryHive, DataCell);
}
else
{
RtlCopyMemory(TargetPath->Buffer,
&ValueCell->DataOffset,
TargetPath->Length);
TargetPath->Buffer[TargetPath->Length / sizeof(WCHAR)] = 0;
}
return(STATUS_SUCCESS);
}
/* EOF */

View file

@ -2,13 +2,13 @@ REGEDIT4
[\Registry\Machine\SYSTEM] [\Registry\Machine\SYSTEM]
[\Registry\Machine\SYSTEM\CurrentControlSet] [\Registry\Machine\SYSTEM\ControlSet001]
[\Registry\Machine\SYSTEM\CurrentControlSet\Control] [\Registry\Machine\SYSTEM\ControlSet001\Control]
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\NLS] [\Registry\Machine\SYSTEM\ControlSet001\Control\NLS]
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\NLS\CodePage] [\Registry\Machine\SYSTEM\ControlSet001\Control\NLS\CodePage]
"10000"="c_10000.nls" "10000"="c_10000.nls"
"1252"="c_1252.nls" "1252"="c_1252.nls"
"437"="c_437.nls" "437"="c_437.nls"
@ -17,7 +17,7 @@ REGEDIT4
"OEMCP"="437" "OEMCP"="437"
"MACCP"="10000" "MACCP"="10000"
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\NLS\Language] [\Registry\Machine\SYSTEM\ControlSet001\Control\NLS\Language]
"0401"="l_intl.nls" "0401"="l_intl.nls"
"0402"="l_intl.nls" "0402"="l_intl.nls"
"0403"="l_intl.nls" "0403"="l_intl.nls"
@ -37,18 +37,18 @@ REGEDIT4
"Default"="0409" "Default"="0409"
"InstallLanguage"="0409" "InstallLanguage"="0409"
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder] [\Registry\Machine\SYSTEM\ControlSet001\Control\ServiceGroupOrder]
"List"=multi:"SCSI Port", "SCSI Miniport", "Primary Disk", "SCSI Class Helper", \ "List"=multi:"SCSI Port", "SCSI Miniport", "Primary Disk", "SCSI Class Helper", \
"SCSI Class", "Boot File System", "Base", "Pointer Port", \ "SCSI Class", "Boot File System", "Base", "Pointer Port", \
"Keyboard Port", "Pointer Class", "Keyboard Class", "Debug", \ "Keyboard Port", "Pointer Class", "Keyboard Class", "Debug", \
"Video Init", "Video", "File System", "Event log", "NDIS", \ "Video Init", "Video", "File System", "Event log", "NDIS", \
"PNP_TDI", "TDI", "Extended Base" "PNP_TDI", "TDI", "Extended Base"
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager] [\Registry\Machine\SYSTEM\ControlSet001\Control\Session Manager]
"BootExecute"=multi:"autocheck autochk *" "BootExecute"=multi:"autocheck autochk *"
"ObjectDirectories"=multi:"\Windows", "\RPC Control" "ObjectDirectories"=multi:"\Windows", "\RPC Control"
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices] [\Registry\Machine\SYSTEM\ControlSet001\Control\Session Manager\DOS Devices]
"AUX"="\DosDevices\COM1" "AUX"="\DosDevices\COM1"
"MAILSLOT"="\Device\MailSlot" "MAILSLOT"="\Device\MailSlot"
"NUL"="\Device\Null" "NUL"="\Device\Null"
@ -56,187 +56,197 @@ REGEDIT4
"PRN"="\DosDevices\LPT1" "PRN"="\DosDevices\LPT1"
"UNC"="\Device\Mup" "UNC"="\Device\Mup"
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager\Environment] [\Registry\Machine\SYSTEM\ControlSet001\Control\Session Manager\Environment]
"ComSpec"=expand:"%SystemRoot%\system32\shell.exe" "ComSpec"=expand:"%SystemRoot%\system32\shell.exe"
"OS"=expand:"ReactOS" "OS"=expand:"ReactOS"
"Path"=expand:"%SystemRoot%\system32;%SystemRoot%" "Path"=expand:"%SystemRoot%\system32;%SystemRoot%"
"windir"=expand:"%SystemRoot%" "windir"=expand:"%SystemRoot%"
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management] [\Registry\Machine\SYSTEM\ControlSet001\Control\Session Manager\Memory Management]
"PagingFiles"=multi:"C:\reactos\pagefile.sys" "PagingFiles"=multi:"C:\reactos\pagefile.sys"
[\Registry\Machine\SYSTEM\CurrentControlSet\Services] [\Registry\Machine\SYSTEM\ControlSet001\Services]
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Afd] [\Registry\Machine\SYSTEM\ControlSet001\Services\Afd]
"ErrorControl"=dword:00000001 "ErrorControl"=dword:00000001
"Group"="TDI" "Group"="TDI"
"ImagePath"="system32\drivers\afd.sys" "ImagePath"=expand:"system32\drivers\afd.sys"
"Start"=dword:00000002 "Start"=dword:00000002
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Atapi] [\Registry\Machine\SYSTEM\ControlSet001\Services\Atapi]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="SCSI Miniport" "Group"="SCSI Miniport"
"ImagePath"="system32\drivers\atapi.sys" "ImagePath"=expand:"system32\drivers\atapi.sys"
"Start"=dword:00000000 "Start"=dword:00000000
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Beep] [\Registry\Machine\SYSTEM\ControlSet001\Services\Beep]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Base" "Group"="Base"
"ImagePath"="system32\drivers\beep.sys" "ImagePath"=expand:"system32\drivers\beep.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Blue] [\Registry\Machine\SYSTEM\ControlSet001\Services\Blue]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Video Init" "Group"="Video Init"
"ImagePath"="system32\drivers\blue.sys" "ImagePath"=expand:"system32\drivers\blue.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Cdfs] [\Registry\Machine\SYSTEM\ControlSet001\Services\Cdfs]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="File System" "Group"="File System"
"ImagePath"="system32\drivers\cdfs.sys" "ImagePath"=expand:"system32\drivers\cdfs.sys"
"Start"=dword:00000003 "Start"=dword:00000003
"Type"=dword:00000002 "Type"=dword:00000002
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Cdrom] [\Registry\Machine\SYSTEM\ControlSet001\Services\Cdrom]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="SCSI Class" "Group"="SCSI Class"
"ImagePath"="system32\drivers\cdrom.sys" "ImagePath"=expand:"system32\drivers\cdrom.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Class2] [\Registry\Machine\SYSTEM\ControlSet001\Services\Class2]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="SCSI Class Helper" "Group"="SCSI Class Helper"
"ImagePath"="system32\drivers\class2.sys" "ImagePath"=expand:"system32\drivers\class2.sys"
"Start"=dword:00000000 "Start"=dword:00000000
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Disk] [\Registry\Machine\SYSTEM\ControlSet001\Services\Disk]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="SCSI Class" "Group"="SCSI Class"
"ImagePath"="system32\drivers\disk.sys" "ImagePath"=expand:"system32\drivers\disk.sys"
"Start"=dword:00000000 "Start"=dword:00000000
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\EventLog] [\Registry\Machine\SYSTEM\ControlSet001\Services\EventLog]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Event log" "Group"="Event log"
"ImagePath"="%SystemRoot%\system32\eventlog.exe" "ImagePath"=expand:"%SystemRoot%\system32\eventlog.exe"
"Start"=dword:00000004 "Start"=dword:00000004
"Type"=dword:00000020 "Type"=dword:00000010
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Floppy] [\Registry\Machine\SYSTEM\ControlSet001\Services\Floppy]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Primary Disk" "Group"="Primary Disk"
"ImagePath"="system32\drivers\floppy.sys" "ImagePath"=expand:"system32\drivers\floppy.sys"
"Start"=dword:00000004 "Start"=dword:00000004
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Fs_Rec] [\Registry\Machine\SYSTEM\ControlSet001\Services\Fs_Rec]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Boot file system" "Group"="Boot file system"
"ImagePath"="system32\drivers\fs_rec.sys" "ImagePath"=expand:"system32\drivers\fs_rec.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000008 "Type"=dword:00000008
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Ide] [\Registry\Machine\SYSTEM\ControlSet001\Services\Ide]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Primary Disk" "Group"="Primary Disk"
"ImagePath"="system32\drivers\ide.sys" "ImagePath"=expand:"system32\drivers\ide.sys"
"Start"=dword:00000004 "Start"=dword:00000004
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Keyboard] [\Registry\Machine\SYSTEM\ControlSet001\Services\Keyboard]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Keyboard Port" "Group"="Keyboard Port"
"ImagePath"="system32\drivers\keyboard.sys" "ImagePath"=expand:"system32\drivers\keyboard.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Msfs] [\Registry\Machine\SYSTEM\ControlSet001\Services\Msfs]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="File System" "Group"="File System"
"ImagePath"="system32\drivers\msfs.sys" "ImagePath"=expand:"system32\drivers\msfs.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000002 "Type"=dword:00000002
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Ne2000] [\Registry\Machine\SYSTEM\ControlSet001\Services\Ne2000]
"ErrorControl"=dword:00000001 "ErrorControl"=dword:00000001
"Group"="NDIS" "Group"="NDIS"
"ImagePath"="system32\drivers\ne2000.sys" "ImagePath"=expand:"system32\drivers\ne2000.sys"
"Start"=dword:00000004 "Start"=dword:00000004
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Ndis] [\Registry\Machine\SYSTEM\ControlSet001\Services\Ndis]
"ErrorControl"=dword:00000001 "ErrorControl"=dword:00000001
"Group"="NDIS" "Group"="NDIS"
"ImagePath"="system32\drivers\ndis.sys" "ImagePath"=expand:"system32\drivers\ndis.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Npfs] [\Registry\Machine\SYSTEM\ControlSet001\Services\Npfs]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="File System" "Group"="File System"
"ImagePath"="system32\drivers\npfs.sys" "ImagePath"=expand:"system32\drivers\npfs.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000002 "Type"=dword:00000002
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Ntfs] [\Registry\Machine\SYSTEM\ControlSet001\Services\Ntfs]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="File System" "Group"="File System"
"ImagePath"="system32\drivers\ntfs.sys" "ImagePath"=expand:"system32\drivers\ntfs.sys"
"Start"=dword:00000003 "Start"=dword:00000003
"Type"=dword:00000002 "Type"=dword:00000002
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Null] [\Registry\Machine\SYSTEM\ControlSet001\Services\Null]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Base" "Group"="Base"
"ImagePath"="system32\drivers\null.sys" "ImagePath"=expand:"system32\drivers\null.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Pice] [\Registry\Machine\SYSTEM\ControlSet001\Services\Pice]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Debug" "Group"="Debug"
"ImagePath"="system32\drivers\pice.sys" "ImagePath"=expand:"system32\drivers\pice.sys"
"Start"=dword:00000004 "Start"=dword:00000004
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Scsiport] [\Registry\Machine\SYSTEM\ControlSet001\Services\RpcSs]
"ErrorControl"=dword:00000001
"ImagePath"=expand:"%SystemRoot%\system32\rpcss.exe"
"Start"=dword:00000004
"Type"=dword:00000010
[\Registry\Machine\SYSTEM\ControlSet001\Services\Scsiport]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="SCSI Port" "Group"="SCSI Port"
"ImagePath"="system32\drivers\scsiport.sys" "ImagePath"=expand:"system32\drivers\scsiport.sys"
"Start"=dword:00000000 "Start"=dword:00000000
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Tcpip] [\Registry\Machine\SYSTEM\ControlSet001\Services\Tcpip]
"ErrorControl"=dword:00000001 "ErrorControl"=dword:00000001
"Group"="PNP_TDI" "Group"="PNP_TDI"
"ImagePath"="system32\drivers\tcpip.sys" "ImagePath"=expand:"system32\drivers\tcpip.sys"
"Start"=dword:00000002 "Start"=dword:00000002
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Vfatfs] [\Registry\Machine\SYSTEM\ControlSet001\Services\Vfatfs]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Boot File System" "Group"="Boot File System"
"ImagePath"="system32\drivers\vfatfs.sys" "ImagePath"=expand:"system32\drivers\vfatfs.sys"
"Start"=dword:00000000 "Start"=dword:00000000
"Type"=dword:00000002 "Type"=dword:00000002
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Vga] [\Registry\Machine\SYSTEM\ControlSet001\Services\Vga]
"ErrorControl"=dword:00000000 "ErrorControl"=dword:00000000
"Group"="Video" "Group"="Video"
"ImagePath"="system32\drivers\vgamp.sys" "ImagePath"=expand:"system32\drivers\vgamp.sys"
"Start"=dword:00000001 "Start"=dword:00000001
"Type"=dword:00000001 "Type"=dword:00000001
[\Registry\Machine\SYSTEM\ControlSet002]
[\Registry\Machine\SYSTEM\Select] [\Registry\Machine\SYSTEM\Select]
"Current"=dword:00000001 "Current"=dword:00000001
"Default"=dword:00000001 "Default"=dword:00000001
"Failed"=dword:00000000 "Failed"=dword:00000000
"LastKnownGood"=dword:00000000 "LastKnownGood"=dword:00000000
[\Registry\Machine\SYSTEM\Setup]