Author: fireball
Date: Sun Dec 16 19:02:56 2007
New Revision: 31281
URL:
http://svn.reactos.org/svn/reactos?rev=31281&view=rev
Log:
- Sync binhive.c changes with trunk.
- Remove duplicated CM structs definitions.
- Fixed up code so it compiles.
Modified:
branches/winldr/arch/i386/hardware.c
branches/winldr/reactos/binhive.c
branches/winldr/reactos/reactos.c
branches/winldr/reactos/setupldr.c
Modified: branches/winldr/arch/i386/hardware.c
URL:
http://svn.reactos.org/svn/reactos/branches/winldr/arch/i386/hardware.c?rev…
==============================================================================
--- branches/winldr/arch/i386/hardware.c (original)
+++ branches/winldr/arch/i386/hardware.c Sun Dec 16 19:02:56 2007
@@ -79,44 +79,6 @@
/* Timeout in ms for sending to keyboard controller. */
#define CONTROLLER_TIMEOUT 250
-
-
-typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA
-{
- ULONG BytesPerSector;
- ULONG NumberOfCylinders;
- ULONG SectorsPerTrack;
- ULONG NumberOfHeads;
-} CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
-
-
-typedef struct _CM_PNP_BIOS_DEVICE_NODE
-{
- USHORT Size;
- CHAR Node;
- ULONG ProductId;
- CHAR DeviceType[3];
- USHORT DeviceAttributes;
-} __attribute__((packed)) CM_PNP_BIOS_DEVICE_NODE, *PCM_PNP_BIOS_DEVICE_NODE;
-
-
-typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK
-{
- UCHAR Signature[4];
- UCHAR Revision;
- UCHAR Length;
- USHORT ControlField;
- UCHAR Checksum;
- ULONG EventFlagAddress;
- USHORT RealModeEntryOffset;
- USHORT RealModeEntrySegment;
- USHORT ProtectedModeEntryOffset;
- ULONG ProtectedModeCodeBaseAddress;
- ULONG OemDeviceId;
- USHORT RealModeDataBaseAddress;
- ULONG ProtectedModeDataBaseAddress;
-} __attribute__((packed)) CM_PNP_BIOS_INSTALLATION_CHECK,
*PCM_PNP_BIOS_INSTALLATION_CHECK;
-
static CHAR Hex[] = "0123456789abcdef";
static unsigned int delay_count = 1;
Modified: branches/winldr/reactos/binhive.c
URL:
http://svn.reactos.org/svn/reactos/branches/winldr/reactos/binhive.c?rev=31…
==============================================================================
--- branches/winldr/reactos/binhive.c (original)
+++ branches/winldr/reactos/binhive.c Sun Dec 16 19:02:56 2007
@@ -23,11 +23,14 @@
#include <cmlib.h>
#include <debug.h>
+#define REG_DATA_SIZE_MASK 0x7FFFFFFF
+#define REG_DATA_IN_OFFSET 0x80000000
+
/* FUNCTIONS ****************************************************************/
static PVOID
NTAPI
-CmpAllocate (SIZE_T Size, BOOLEAN Paged)
+CmpAllocate (SIZE_T Size, BOOLEAN Paged, ULONG Tag)
{
return MmHeapAlloc(Size);
}
@@ -35,489 +38,10 @@
static VOID
NTAPI
-CmpFree (PVOID Ptr)
+CmpFree (PVOID Ptr, IN ULONG Quota)
{
return MmHeapFree(Ptr);
}
-
-
-static BOOLEAN
-CmiAllocateHashTableCell (PHHIVE Hive,
- PHCELL_INDEX HBOffset,
- ULONG SubKeyCount)
-{
- PHASH_TABLE_CELL HashCell;
- ULONG NewHashSize;
-
- NewHashSize = sizeof(HASH_TABLE_CELL) +
- (SubKeyCount * sizeof(HASH_RECORD));
- *HBOffset = HvAllocateCell (Hive, NewHashSize, HvStable);
- if (*HBOffset == HCELL_NULL)
- {
- return FALSE;
- }
-
- HashCell = HvGetCell (Hive, *HBOffset);
- HashCell->Id = REG_HASH_TABLE_CELL_ID;
- HashCell->HashTableSize = SubKeyCount;
-
- return TRUE;
-}
-
-
-static BOOLEAN
-CmiAddKeyToParentHashTable (PHHIVE Hive,
- HCELL_INDEX Parent,
- PCM_KEY_NODE NewKeyCell,
- HCELL_INDEX NKBOffset)
-{
- PHASH_TABLE_CELL HashBlock;
- PCM_KEY_NODE ParentKeyCell;
- ULONG i;
-
- ParentKeyCell = HvGetCell (Hive, Parent);
- HashBlock = HvGetCell (Hive, ParentKeyCell->SubKeyLists[HvStable]);
-
- for (i = 0; i < HashBlock->HashTableSize; i++)
- {
- if (HashBlock->Table[i].KeyOffset == 0)
- {
- HashBlock->Table[i].KeyOffset = NKBOffset;
- memcpy (&HashBlock->Table[i].HashValue,
- NewKeyCell->Name,
- min(NewKeyCell->NameSize, sizeof(ULONG)));
- ParentKeyCell->SubKeyCounts[HvStable]++;
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-
-static BOOLEAN
-CmiAllocateValueListCell (PHHIVE Hive,
- PHCELL_INDEX ValueListOffset,
- ULONG ValueCount)
-{
- ULONG ValueListSize;
-
- ValueListSize = sizeof(VALUE_LIST_CELL) +
- (ValueCount * sizeof(HCELL_INDEX));
- *ValueListOffset = HvAllocateCell (Hive, ValueListSize, HvStable);
- if (*ValueListOffset == HCELL_NULL)
- {
- DbgPrint((DPRINT_REGISTRY, "HvAllocateCell() failed\n"));
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-static BOOLEAN
-CmiAllocateValueCell(PHHIVE Hive,
- PCM_KEY_VALUE *ValueCell,
- HCELL_INDEX *ValueCellOffset,
- PWCHAR ValueName)
-{
- PCM_KEY_VALUE NewValueCell;
- ULONG NameSize;
- BOOLEAN Packable = TRUE;
- ULONG i;
-
- NameSize = (ValueName == NULL) ? 0 : wcslen (ValueName);
- for (i = 0; i < NameSize; i++)
- {
- if (ValueName[i] & 0xFF00)
- {
- NameSize *= sizeof(WCHAR);
- Packable = FALSE;
- break;
- }
- }
- *ValueCellOffset = HvAllocateCell (Hive, sizeof(CM_KEY_VALUE) + NameSize, HvStable);
- if (*ValueCellOffset == HCELL_NULL)
- {
- DbgPrint((DPRINT_REGISTRY, "CmiAllocateCell() failed\n"));
- return FALSE;
- }
-
- NewValueCell = (PCM_KEY_VALUE) HvGetCell (Hive, *ValueCellOffset);
- NewValueCell->Id = REG_VALUE_CELL_ID;
- NewValueCell->NameSize = NameSize;
- NewValueCell->Flags = 0;
- if (NameSize > 0)
- {
- if (Packable)
- {
- for (i = 0; i < NameSize; i++)
- {
- ((PCHAR)NewValueCell->Name)[i] = (CHAR)ValueName[i];
- }
- NewValueCell->Flags |= REG_VALUE_NAME_PACKED;
- }
- else
- {
- memcpy (NewValueCell->Name,
- ValueName,
- NameSize);
- }
- }
- NewValueCell->DataType = 0;
- NewValueCell->DataSize = 0;
- NewValueCell->DataOffset = -1;
-
- *ValueCell = NewValueCell;
-
- return TRUE;
-}
-
-
-static BOOLEAN
-CmiAddValueToKeyValueList(PHHIVE Hive,
- HCELL_INDEX KeyCellOffset,
- HCELL_INDEX ValueCellOffset)
-{
- PVALUE_LIST_CELL ValueListCell;
- PCM_KEY_NODE KeyCell;
-
- KeyCell = HvGetCell (Hive, KeyCellOffset);
- if (KeyCell == NULL)
- {
- DbgPrint((DPRINT_REGISTRY, "HvGetCell() failed\n"));
- return FALSE;
- }
-
- ValueListCell = HvGetCell (Hive, KeyCell->ValueList.List);
- if (ValueListCell == NULL)
- {
- DbgPrint((DPRINT_REGISTRY, "HvGetCell() failed\n"));
- return FALSE;
- }
-
- ValueListCell->ValueOffset[KeyCell->ValueList.Count] = ValueCellOffset;
- KeyCell->ValueList.Count++;
-
- return TRUE;
-}
-
-static BOOLEAN
-CmiExportValue (PHHIVE Hive,
- HCELL_INDEX KeyCellOffset,
- FRLDRHKEY Key,
- PVALUE Value)
-{
- HCELL_INDEX ValueCellOffset;
- HCELL_INDEX DataCellOffset;
- PCM_KEY_VALUE ValueCell;
- PVOID DataCell;
- ULONG DataSize;
- ULONG DataType;
- PCHAR Data;
-
- DbgPrint((DPRINT_REGISTRY, "CmiExportValue('%S') called\n",
- (Value == NULL) ? "<default>" : (PCHAR)Value->Name));
- DbgPrint((DPRINT_REGISTRY, "DataSize %lu\n",
- (Value == NULL) ? Key->DataSize : Value->DataSize));
-
- /* Allocate value cell */
- if (!CmiAllocateValueCell(Hive, &ValueCell, &ValueCellOffset, (Value == NULL) ?
NULL : Value->Name))
- {
- return FALSE;
- }
-
- if (!CmiAddValueToKeyValueList(Hive, KeyCellOffset, ValueCellOffset))
- {
- return FALSE;
- }
-
- if (Value == NULL)
- {
- DataType = Key->DataType;
- DataSize = Key->DataSize;
- Data = Key->Data;
- }
- else
- {
- DataType = Value->DataType;
- DataSize = Value->DataSize;
- Data = Value->Data;
- }
-
- if (DataSize <= sizeof(HCELL_INDEX))
- {
- ValueCell->DataSize = DataSize | REG_DATA_IN_OFFSET;
- ValueCell->DataType = DataType;
- memcpy (&ValueCell->DataOffset,
- &Data,
- DataSize);
- }
- else
- {
- /* Allocate data cell */
- DataCellOffset = HvAllocateCell (Hive, DataSize, HvStable);
- if (DataCellOffset == HCELL_NULL)
- {
- return FALSE;
- }
-
- ValueCell->DataOffset = DataCellOffset;
- ValueCell->DataSize = DataSize;
- ValueCell->DataType = DataType;
-
- DataCell = HvGetCell (Hive, DataCellOffset);
- memcpy (DataCell,
- Data,
- DataSize);
- }
-
- return TRUE;
-}
-
-
-static BOOLEAN
-CmiExportSubKey (PHHIVE Hive,
- HCELL_INDEX Parent,
- FRLDRHKEY ParentKey,
- FRLDRHKEY Key)
-{
- HCELL_INDEX NKBOffset;
- PCM_KEY_NODE NewKeyCell;
- ULONG KeyCellSize;
- ULONG SubKeyCount;
- ULONG ValueCount;
- PLIST_ENTRY Entry;
- FRLDRHKEY SubKey;
- PVALUE Value;
- BOOLEAN Packable = TRUE;
- ULONG i;
- ULONG NameSize;
-
- DbgPrint((DPRINT_REGISTRY, "CmiExportSubKey('%S') called\n",
Key->Name));
-
- /* Don't export links */
- if (Key->DataType == REG_LINK)
- return TRUE;
-
- NameSize = (Key->NameSize - sizeof(WCHAR)) / sizeof(WCHAR);
- for (i = 0; i < NameSize; i++)
- {
- if (Key->Name[i] & 0xFF00)
- {
- Packable = FALSE;
- NameSize *= sizeof(WCHAR);
- break;
- }
- }
-
- /* Allocate key cell */
- KeyCellSize = sizeof(CM_KEY_NODE) + NameSize;
- NKBOffset = HvAllocateCell (Hive, KeyCellSize, HvStable);
- if (NKBOffset == HCELL_NULL)
- {
- DbgPrint((DPRINT_REGISTRY, "HvAllocateCell() failed\n"));
- return FALSE;
- }
-
- /* Initialize key cell */
- NewKeyCell = (PCM_KEY_NODE) HvGetCell (Hive, NKBOffset);
- NewKeyCell->Id = REG_KEY_CELL_ID;
- NewKeyCell->Flags = 0;
- NewKeyCell->LastWriteTime.QuadPart = 0ULL;
- NewKeyCell->Parent = Parent;
- NewKeyCell->SubKeyCounts[HvStable] = 0;
- NewKeyCell->SubKeyLists[HvStable] = -1;
- NewKeyCell->ValueList.Count = 0;
- NewKeyCell->ValueList.List = -1;
- NewKeyCell->SecurityKeyOffset = -1;
- NewKeyCell->ClassNameOffset = -1;
- NewKeyCell->NameSize = NameSize;
- NewKeyCell->ClassSize = 0;
- if (Packable)
- {
- for (i = 0; i < NameSize; i++)
- {
- ((PCHAR)NewKeyCell->Name)[i] = (CHAR)Key->Name[i];
- }
- NewKeyCell->Flags |= REG_KEY_NAME_PACKED;
-
- }
- else
- {
- memcpy (NewKeyCell->Name,
- Key->Name,
- NameSize);
- }
-
- /* Add key cell to the parent key's hash table */
- if (!CmiAddKeyToParentHashTable (Hive,
- Parent,
- NewKeyCell,
- NKBOffset))
- {
- DbgPrint((DPRINT_REGISTRY, "CmiAddKeyToParentHashTable() failed\n"));
- return FALSE;
- }
-
- ValueCount = RegGetValueCount (Key);
- DbgPrint((DPRINT_REGISTRY, "ValueCount: %u\n", ValueCount));
- if (ValueCount > 0)
- {
- /* Allocate value list cell */
- if (!CmiAllocateValueListCell (Hive,
- &NewKeyCell->ValueList.List,
- ValueCount))
- {
- DbgPrint((DPRINT_REGISTRY, "CmiAllocateValueListCell() failed\n"));
- return FALSE;
- }
-
- if (Key->DataSize != 0)
- {
- if (!CmiExportValue (Hive, NKBOffset, Key, NULL))
- return FALSE;
- }
-
- /* Enumerate values */
- Entry = Key->ValueList.Flink;
- while (Entry != &Key->ValueList)
- {
- Value = CONTAINING_RECORD(Entry,
- VALUE,
- ValueList);
-
- if (!CmiExportValue (Hive, NKBOffset, Key, Value))
- return FALSE;
-
- Entry = Entry->Flink;
- }
- }
-
- SubKeyCount = RegGetSubKeyCount (Key);
- DbgPrint((DPRINT_REGISTRY, "SubKeyCount: %u\n", SubKeyCount));
- if (SubKeyCount > 0)
- {
- /* Allocate hash table cell */
- if (!CmiAllocateHashTableCell (Hive,
- &NewKeyCell->SubKeyLists[HvStable],
- SubKeyCount))
- {
- DbgPrint((DPRINT_REGISTRY, "CmiAllocateHashTableCell() failed\n"));
- return FALSE;
- }
-
- /* Enumerate subkeys */
- Entry = Key->SubKeyList.Flink;
- while (Entry != &Key->SubKeyList)
- {
- SubKey = CONTAINING_RECORD(Entry,
- KEY,
- KeyList);
-
- if (!CmiExportSubKey (Hive, NKBOffset, Key, SubKey))
- return FALSE;
-
- Entry = Entry->Flink;
- }
- }
-
- return TRUE;
-}
-
-
-static BOOLEAN
-CmiExportHive (PHHIVE Hive,
- PCWSTR KeyName)
-{
- PCM_KEY_NODE KeyCell;
- FRLDRHKEY Key;
- ULONG SubKeyCount;
- ULONG ValueCount;
- PLIST_ENTRY Entry;
- FRLDRHKEY SubKey;
- PVALUE Value;
-
- DbgPrint((DPRINT_REGISTRY, "CmiExportHive(%x, '%S') called\n", Hive,
KeyName));
-
- if (RegOpenKey (NULL, KeyName, &Key) != ERROR_SUCCESS)
- {
- DbgPrint((DPRINT_REGISTRY, "RegOpenKey() failed\n"));
- return FALSE;
- }
-
- KeyCell = HvGetCell (Hive, Hive->HiveHeader->RootCell);
- if (KeyCell == NULL)
- {
- DbgPrint((DPRINT_REGISTRY, "HvGetCell() failed\n"));
- return FALSE;
- }
-
- ValueCount = RegGetValueCount (Key);
- DbgPrint((DPRINT_REGISTRY, "ValueCount: %u\n", ValueCount));
- if (ValueCount > 0)
- {
- /* Allocate value list cell */
- if (!CmiAllocateValueListCell (Hive,
- &KeyCell->ValueList.List,
- ValueCount))
- {
- DbgPrint((DPRINT_REGISTRY, "CmiAllocateValueListCell() failed\n"));
- return FALSE;
- }
-
- if (Key->DataSize != 0)
- {
- if (!CmiExportValue (Hive, Hive->HiveHeader->RootCell, Key, NULL))
- return FALSE;
- }
-
- /* Enumerate values */
- Entry = Key->ValueList.Flink;
- while (Entry != &Key->ValueList)
- {
- Value = CONTAINING_RECORD(Entry,
- VALUE,
- ValueList);
-
- if (!CmiExportValue (Hive, Hive->HiveHeader->RootCell, Key, Value))
- return FALSE;
-
- Entry = Entry->Flink;
- }
- }
-
- SubKeyCount = RegGetSubKeyCount (Key);
- DbgPrint((DPRINT_REGISTRY, "SubKeyCount: %u\n", SubKeyCount));
- if (SubKeyCount > 0)
- {
- /* Allocate hash table cell */
- if (!CmiAllocateHashTableCell (Hive,
- &KeyCell->SubKeyLists[HvStable],
- SubKeyCount))
- {
- DbgPrint((DPRINT_REGISTRY, "CmiAllocateHashTableCell() failed\n"));
- return FALSE;
- }
-
- /* Enumerate subkeys */
- Entry = Key->SubKeyList.Flink;
- while (Entry != &Key->SubKeyList)
- {
- SubKey = CONTAINING_RECORD(Entry,
- KEY,
- KeyList);
-
- if (!CmiExportSubKey (Hive, Hive->HiveHeader->RootCell, Key, SubKey))
- return FALSE;
-
- Entry = Entry->Flink;
- }
- }
-
- return TRUE;
-}
-
static BOOLEAN
RegImportValue (PHHIVE Hive,
@@ -527,45 +51,45 @@
PVOID DataCell;
PWCHAR wName;
LONG Error;
- ULONG DataSize;
+ ULONG DataLength;
ULONG i;
- if (ValueCell->Id != REG_VALUE_CELL_ID)
+ if (ValueCell->Signature != CM_KEY_VALUE_SIGNATURE)
{
DbgPrint((DPRINT_REGISTRY, "Invalid key cell!\n"));
return FALSE;
}
- if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
- {
- wName = MmHeapAlloc((ValueCell->NameSize + 1)*sizeof(WCHAR));
- for (i = 0; i < ValueCell->NameSize; i++)
+ if (ValueCell->Flags & VALUE_COMP_NAME)
+ {
+ wName = MmHeapAlloc((ValueCell->NameLength + 1)*sizeof(WCHAR));
+ for (i = 0; i < ValueCell->NameLength; i++)
{
wName[i] = ((PCHAR)ValueCell->Name)[i];
}
- wName[ValueCell->NameSize] = 0;
+ wName[ValueCell->NameLength] = 0;
}
else
{
- wName = MmHeapAlloc(ValueCell->NameSize + sizeof(WCHAR));
+ wName = MmHeapAlloc(ValueCell->NameLength + sizeof(WCHAR));
memcpy (wName,
ValueCell->Name,
- ValueCell->NameSize);
- wName[ValueCell->NameSize / sizeof(WCHAR)] = 0;
- }
-
- DataSize = ValueCell->DataSize & REG_DATA_SIZE_MASK;
+ ValueCell->NameLength);
+ wName[ValueCell->NameLength / sizeof(WCHAR)] = 0;
+ }
+
+ DataLength = ValueCell->DataLength & REG_DATA_SIZE_MASK;
DbgPrint((DPRINT_REGISTRY, "ValueName: '%S'\n", wName));
- DbgPrint((DPRINT_REGISTRY, "DataSize: %u\n", DataSize));
-
- if (DataSize <= sizeof(HCELL_INDEX) && (ValueCell->DataSize &
REG_DATA_IN_OFFSET))
+ DbgPrint((DPRINT_REGISTRY, "DataLength: %u\n", DataLength));
+
+ if (DataLength <= sizeof(HCELL_INDEX) && (ValueCell->DataLength &
REG_DATA_IN_OFFSET))
{
Error = RegSetValue(Key,
wName,
- ValueCell->DataType,
- (PCHAR)&ValueCell->DataOffset,
- DataSize);
+ ValueCell->Type,
+ (PCHAR)&ValueCell->Data,
+ DataLength);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_REGISTRY, "RegSetValue() failed!\n"));
@@ -575,15 +99,15 @@
}
else
{
- DataCell = HvGetCell (Hive, ValueCell->DataOffset);
+ DataCell = (PVOID)HvGetCell (Hive, ValueCell->Data);
DbgPrint((DPRINT_REGISTRY, "DataCell: %x\n", DataCell));
Error = RegSetValue (Key,
wName,
- ValueCell->DataType,
+ ValueCell->Type,
DataCell,
- DataSize);
-
+ DataLength);
+
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_REGISTRY, "RegSetValue() failed!\n"));
@@ -603,7 +127,7 @@
PCM_KEY_NODE KeyCell,
FRLDRHKEY ParentKey)
{
- PHASH_TABLE_CELL HashCell;
+ PCM_KEY_FAST_INDEX HashCell;
PCM_KEY_NODE SubKeyCell;
PVALUE_LIST_CELL ValueListCell;
PCM_KEY_VALUE ValueCell = NULL;
@@ -614,29 +138,29 @@
DbgPrint((DPRINT_REGISTRY, "KeyCell: %x\n", KeyCell));
- DbgPrint((DPRINT_REGISTRY, "KeyCell->Id: %x\n", KeyCell->Id));
- if (KeyCell->Id != REG_KEY_CELL_ID)
- {
- DbgPrint((DPRINT_REGISTRY, "Invalid key cell id!\n"));
- return FALSE;
- }
-
- if (KeyCell->Flags & REG_KEY_NAME_PACKED)
- {
- wName = MmHeapAlloc ((KeyCell->NameSize + 1) * sizeof(WCHAR));
- for (i = 0; i < KeyCell->NameSize; i++)
+ DbgPrint((DPRINT_REGISTRY, "KeyCell->Signature: %x\n",
KeyCell->Signature));
+ if (KeyCell->Signature != CM_KEY_NODE_SIGNATURE)
+ {
+ DbgPrint((DPRINT_REGISTRY, "Invalid key cell Signature!\n"));
+ return FALSE;
+ }
+
+ if (KeyCell->Flags & KEY_COMP_NAME)
+ {
+ wName = MmHeapAlloc ((KeyCell->NameLength + 1) * sizeof(WCHAR));
+ for (i = 0; i < KeyCell->NameLength; i++)
{
wName[i] = ((PCHAR)KeyCell->Name)[i];
}
- wName[KeyCell->NameSize] = 0;
+ wName[KeyCell->NameLength] = 0;
}
else
{
- wName = MmHeapAlloc (KeyCell->NameSize + sizeof(WCHAR));
+ wName = MmHeapAlloc (KeyCell->NameLength + sizeof(WCHAR));
memcpy (wName,
KeyCell->Name,
- KeyCell->NameSize);
- wName[KeyCell->NameSize/sizeof(WCHAR)] = 0;
+ KeyCell->NameLength);
+ wName[KeyCell->NameLength/sizeof(WCHAR)] = 0;
}
DbgPrint((DPRINT_REGISTRY, "KeyName: '%S'\n", wName));
@@ -674,18 +198,17 @@
}
/* Enumerate and add subkeys */
- if (KeyCell->SubKeyCounts[HvStable] > 0)
- {
- HashCell = (PHASH_TABLE_CELL) HvGetCell (Hive, KeyCell->SubKeyLists[HvStable]);
+ if (KeyCell->SubKeyCounts[Stable] > 0)
+ {
+ HashCell = (PCM_KEY_FAST_INDEX) HvGetCell (Hive, KeyCell->SubKeyLists[Stable]);
DbgPrint((DPRINT_REGISTRY, "HashCell: %x\n", HashCell));
- DbgPrint((DPRINT_REGISTRY, "HashCell->Id: %x\n", HashCell->Id));
DbgPrint((DPRINT_REGISTRY, "SubKeyCounts: %x\n",
KeyCell->SubKeyCounts));
- for (i = 0; i < KeyCell->SubKeyCounts[HvStable]; i++)
- {
- DbgPrint((DPRINT_REGISTRY, "KeyOffset[%d]: %x\n", i,
HashCell->Table[i].KeyOffset));
-
- SubKeyCell = (PCM_KEY_NODE) HvGetCell (Hive, HashCell->Table[i].KeyOffset);
+ for (i = 0; i < KeyCell->SubKeyCounts[Stable]; i++)
+ {
+ DbgPrint((DPRINT_REGISTRY, "Cell[%d]: %x\n", i,
HashCell->List[i].Cell));
+
+ SubKeyCell = (PCM_KEY_NODE) HvGetCell (Hive, HashCell->List[i].Cell);
DbgPrint((DPRINT_REGISTRY, "SubKeyCell[%d]: %x\n", i, SubKeyCell));
@@ -703,35 +226,44 @@
ULONG ChunkSize)
{
PCM_KEY_NODE KeyCell;
- PHASH_TABLE_CELL HashCell;
+ PCM_KEY_FAST_INDEX HashCell;
PCM_KEY_NODE SubKeyCell;
FRLDRHKEY SystemKey;
ULONG i;
LONG Error;
- PEREGISTRY_HIVE CmHive;
+ PCMHIVE CmHive;
PHHIVE Hive;
NTSTATUS Status;
DbgPrint((DPRINT_REGISTRY, "RegImportBinaryHive(%x, %u)
called\n",ChunkBase,ChunkSize));
- CmHive = CmpAllocate(sizeof(EREGISTRY_HIVE), TRUE);
- Status = HvInitialize (&CmHive->Hive, HV_OPERATION_MEMORY_INPLACE, 0, 0,
- (ULONG_PTR)ChunkBase, 0,
- CmpAllocate, CmpFree,
- NULL, NULL, NULL, NULL, NULL);
+ CmHive = CmpAllocate(sizeof(CMHIVE), TRUE, 0);
+ Status = HvInitialize (&CmHive->Hive,
+ HINIT_FLAT,
+ 0,
+ 0,
+ ChunkBase,
+ CmpAllocate,
+ CmpFree,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 1,
+ NULL);
if (!NT_SUCCESS(Status))
{
- DbgPrint((DPRINT_REGISTRY, "Invalid hive id!\n"));
+ DbgPrint((DPRINT_REGISTRY, "Invalid hive Signature!\n"));
return FALSE;
}
Hive = &CmHive->Hive;
- KeyCell = HvGetCell (Hive, Hive->HiveHeader->RootCell);
+ KeyCell = (PCM_KEY_NODE)HvGetCell (Hive, Hive->BaseBlock->RootCell);
DbgPrint((DPRINT_REGISTRY, "KeyCell: %x\n", KeyCell));
- DbgPrint((DPRINT_REGISTRY, "KeyCell->Id: %x\n", KeyCell->Id));
- if (KeyCell->Id != REG_KEY_CELL_ID)
- {
- DbgPrint((DPRINT_REGISTRY, "Invalid key cell id!\n"));
+ DbgPrint((DPRINT_REGISTRY, "KeyCell->Signature: %x\n",
KeyCell->Signature));
+ if (KeyCell->Signature != CM_KEY_NODE_SIGNATURE)
+ {
+ DbgPrint((DPRINT_REGISTRY, "Invalid key cell Signature!\n"));
return FALSE;
}
@@ -749,17 +281,17 @@
}
/* Enumerate and add subkeys */
- if (KeyCell->SubKeyCounts[HvStable] > 0)
- {
- HashCell = HvGetCell (Hive, KeyCell->SubKeyLists[HvStable]);
+ if (KeyCell->SubKeyCounts[Stable] > 0)
+ {
+ HashCell = (PCM_KEY_FAST_INDEX)HvGetCell (Hive, KeyCell->SubKeyLists[Stable]);
DbgPrint((DPRINT_REGISTRY, "HashCell: %x\n", HashCell));
- DbgPrint((DPRINT_REGISTRY, "SubKeyCounts: %x\n",
KeyCell->SubKeyCounts[HvStable]));
-
- for (i = 0; i < KeyCell->SubKeyCounts[HvStable]; i++)
- {
- DbgPrint((DPRINT_REGISTRY, "KeyOffset[%d]: %x\n", i,
HashCell->Table[i].KeyOffset));
-
- SubKeyCell = HvGetCell (Hive, HashCell->Table[i].KeyOffset);
+ DbgPrint((DPRINT_REGISTRY, "SubKeyCounts: %x\n",
KeyCell->SubKeyCounts[Stable]));
+
+ for (i = 0; i < KeyCell->SubKeyCounts[Stable]; i++)
+ {
+ DbgPrint((DPRINT_REGISTRY, "Cell[%d]: %x\n", i,
HashCell->List[i].Cell));
+
+ SubKeyCell = (PCM_KEY_NODE)HvGetCell (Hive, HashCell->List[i].Cell);
DbgPrint((DPRINT_REGISTRY, "SubKeyCell[%d]: %x\n", i, SubKeyCell));
@@ -771,76 +303,4 @@
return TRUE;
}
-
-static VOID
-CmiWriteHive(PHHIVE Hive,
- PCHAR ChunkBase,
- ULONG* ChunkSize)
-{
- PHBIN Bin;
- ULONG i, Size;
-
- /* Write hive header */
- memcpy (ChunkBase, Hive->HiveHeader, HV_BLOCK_SIZE);
- Size = HV_BLOCK_SIZE;
-
- Bin = NULL;
- for (i = 0; i < Hive->Storage[HvStable].Length; i++)
- {
- if (Hive->Storage[HvStable].BlockList[i].Bin != (ULONG_PTR)Bin)
- {
- Bin = (PHBIN)Hive->Storage[HvStable].BlockList[i].Bin;
- memcpy (ChunkBase + (i + 1) * HV_BLOCK_SIZE,
- Bin, Bin->Size);
- Size += Bin->Size;
- }
- }
-
- DbgPrint((DPRINT_REGISTRY, "ChunkSize: %x\n", Size));
-
- *ChunkSize = Size;
-}
-
-
-BOOLEAN
-RegExportBinaryHive(PCWSTR KeyName,
- PCHAR ChunkBase,
- ULONG* ChunkSize)
-{
- PEREGISTRY_HIVE CmHive;
- PHHIVE Hive;
- NTSTATUS Status;
-
- DbgPrint((DPRINT_REGISTRY, "Creating binary hardware hive\n"));
-
- CmHive = CmpAllocate(sizeof(EREGISTRY_HIVE), TRUE);
- Status = HvInitialize (&CmHive->Hive, HV_OPERATION_CREATE_HIVE, 0, 0, 0, 0,
- CmpAllocate, CmpFree,
- NULL, NULL, NULL, NULL, NULL);
- Hive = &CmHive->Hive;
- if (!NT_SUCCESS(Status))
- {
- return FALSE;
- }
-
- /* Init root key cell */
- if (!CmCreateRootNode (Hive, KeyName))
- {
- HvFree (Hive);
- return FALSE;
- }
-
- if (!CmiExportHive (Hive, KeyName))
- {
- HvFree (Hive);
- return FALSE;
- }
-
- CmiWriteHive (Hive, ChunkBase, ChunkSize);
-
- HvFree (Hive);
-
- return TRUE;
-}
-
/* EOF */
Modified: branches/winldr/reactos/reactos.c
URL:
http://svn.reactos.org/svn/reactos/branches/winldr/reactos/reactos.c?rev=31…
==============================================================================
--- branches/winldr/reactos/reactos.c (original)
+++ branches/winldr/reactos/reactos.c Sun Dec 16 19:02:56 2007
@@ -900,7 +900,7 @@
* Export the hardware hive
*/
Base = FrLdrCreateModule ("HARDWARE");
- RegExportBinaryHive (L"\\Registry\\Machine\\HARDWARE", (PCHAR)Base,
&Size);
+ //RegExportBinaryHive (L"\\Registry\\Machine\\HARDWARE", (PCHAR)Base,
&Size);
FrLdrCloseModule (Base, Size);
UiDrawProgressBarCenter(20, 100, szLoadingMsg);
Modified: branches/winldr/reactos/setupldr.c
URL:
http://svn.reactos.org/svn/reactos/branches/winldr/reactos/setupldr.c?rev=3…
==============================================================================
--- branches/winldr/reactos/setupldr.c (original)
+++ branches/winldr/reactos/setupldr.c Sun Dec 16 19:02:56 2007
@@ -279,8 +279,8 @@
VOID RunLoader(VOID)
{
- ULONG_PTR Base;
- ULONG Size;
+ //ULONG_PTR Base;
+ //ULONG Size;
const char *SourcePath;
const char *LoadOptions = "", *DbgLoadOptions = "";
UINT i;
@@ -447,9 +447,9 @@
LoadKernelSymbols(SourcePath, "ntoskrnl.exe");
/* Export the hardware hive */
- Base = FrLdrCreateModule ("HARDWARE");
- RegExportBinaryHive (L"\\Registry\\Machine\\HARDWARE", (PVOID)Base,
&Size);
- FrLdrCloseModule (Base, Size);
+ //Base = FrLdrCreateModule ("HARDWARE");
+ //RegExportBinaryHive (L"\\Registry\\Machine\\HARDWARE", (PVOID)Base,
&Size);
+ //FrLdrCloseModule (Base, Size);
#if 0
printf("Base: %x\n", Base);