mirror of
https://github.com/reactos/reactos.git
synced 2025-04-05 21:21:33 +00:00
Let mkhive use cmlib. "make install" now works and this let the livecd go further than before
svn path=/trunk/; revision=24026
This commit is contained in:
parent
2ca81c5573
commit
6702dd5240
12 changed files with 1813 additions and 2277 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2003 ReactOS Team
|
||||
* Copyright (C) 2006 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,20 +16,20 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id$
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/binhive.h
|
||||
* PURPOSE: Binary hive export code
|
||||
* PROGRAMMER: Eric Kohl
|
||||
* PROGRAMMER: Hervé Poussineau
|
||||
*/
|
||||
|
||||
#ifndef __BINHIVE_H__
|
||||
#define __BINHIVE_H__
|
||||
|
||||
BOOL
|
||||
ExportBinaryHive (PCHAR FileName,
|
||||
PCHAR KeyName);
|
||||
ExportBinaryHive(
|
||||
IN PCSTR FileName,
|
||||
IN PEREGISTRY_HIVE Hive);
|
||||
|
||||
#endif /* __BINHIVE_H__ */
|
||||
|
||||
|
|
791
reactos/tools/mkhive/cmi.c
Normal file
791
reactos/tools/mkhive/cmi.c
Normal file
|
@ -0,0 +1,791 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2006 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/cmi.c
|
||||
* PURPOSE: Registry file manipulation routines
|
||||
* PROGRAMMER: Hervé Poussineau
|
||||
*/
|
||||
|
||||
#define NDEBUG
|
||||
#include "mkhive.h"
|
||||
|
||||
static PVOID
|
||||
CmpAllocate(
|
||||
IN SIZE_T Size,
|
||||
IN BOOLEAN Paged)
|
||||
{
|
||||
return malloc(Size);
|
||||
}
|
||||
|
||||
static VOID
|
||||
CmpFree(
|
||||
IN PVOID Ptr)
|
||||
{
|
||||
free(Ptr);
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
CmpFileRead(
|
||||
IN PHHIVE RegistryHive,
|
||||
IN ULONG FileType,
|
||||
IN ULONGLONG FileOffset,
|
||||
OUT PVOID Buffer,
|
||||
IN SIZE_T BufferLength)
|
||||
{
|
||||
DPRINT1("CmpFileRead() unimplemented\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
CmpFileWrite(
|
||||
IN PHHIVE RegistryHive,
|
||||
IN ULONG FileType,
|
||||
IN ULONGLONG FileOffset,
|
||||
IN PVOID Buffer,
|
||||
IN SIZE_T BufferLength)
|
||||
{
|
||||
PEREGISTRY_HIVE CmHive = (PEREGISTRY_HIVE)RegistryHive;
|
||||
FILE *File = CmHive->HiveHandle;
|
||||
if (0 != fseek (File, (long)FileOffset, SEEK_SET))
|
||||
return FALSE;
|
||||
return BufferLength == fwrite (Buffer, 1, BufferLength, File);
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
CmpFileSetSize(
|
||||
IN PHHIVE RegistryHive,
|
||||
IN ULONG FileType,
|
||||
IN ULONGLONG FileSize)
|
||||
{
|
||||
DPRINT1("CmpFileSetSize() unimplemented\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
CmpFileFlush(
|
||||
IN PHHIVE RegistryHive,
|
||||
IN ULONG FileType)
|
||||
{
|
||||
PEREGISTRY_HIVE CmHive = (PEREGISTRY_HIVE)RegistryHive;
|
||||
FILE *File = CmHive->HiveHandle;
|
||||
return 0 == fflush (File);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CmiInitializeTempHive(
|
||||
IN OUT PEREGISTRY_HIVE Hive)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
RtlZeroMemory (
|
||||
Hive,
|
||||
sizeof(EREGISTRY_HIVE));
|
||||
|
||||
DPRINT("Hive 0x%p\n", Hive);
|
||||
|
||||
Status = HvInitialize(
|
||||
&Hive->Hive,
|
||||
HV_OPERATION_CREATE_HIVE, 0, 0,
|
||||
CmpAllocate, CmpFree,
|
||||
CmpFileRead, CmpFileWrite, CmpFileSetSize,
|
||||
CmpFileFlush, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (!CmCreateRootNode (&Hive->Hive, L""))
|
||||
{
|
||||
HvFree (&Hive->Hive);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
Hive->Flags = HIVE_NO_FILE;
|
||||
|
||||
/* Add the new hive to the hive list */
|
||||
InsertTailList (
|
||||
&CmiHiveListHead,
|
||||
&Hive->HiveList);
|
||||
|
||||
VERIFY_REGISTRY_HIVE (Hive);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
CmiAddKeyToHashTable(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
IN OUT PHASH_TABLE_CELL HashCell,
|
||||
IN PCM_KEY_NODE KeyCell,
|
||||
IN HV_STORAGE_TYPE StorageType,
|
||||
IN PCM_KEY_NODE NewKeyCell,
|
||||
IN HCELL_INDEX NKBOffset)
|
||||
{
|
||||
ULONG i = KeyCell->SubKeyCounts[StorageType];
|
||||
|
||||
HashCell->Table[i].KeyOffset = NKBOffset;
|
||||
HashCell->Table[i].HashValue = 0;
|
||||
if (NewKeyCell->Flags & REG_KEY_NAME_PACKED)
|
||||
{
|
||||
RtlCopyMemory(
|
||||
&HashCell->Table[i].HashValue,
|
||||
NewKeyCell->Name,
|
||||
min(NewKeyCell->NameSize, sizeof(ULONG)));
|
||||
}
|
||||
HvMarkCellDirty(&RegistryHive->Hive, KeyCell->SubKeyLists[StorageType]);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
CmiAllocateHashTableCell (
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
OUT PHASH_TABLE_CELL *HashBlock,
|
||||
OUT HCELL_INDEX *HBOffset,
|
||||
IN USHORT SubKeyCount,
|
||||
IN HV_STORAGE_TYPE Storage)
|
||||
{
|
||||
PHASH_TABLE_CELL NewHashBlock;
|
||||
ULONG NewHashSize;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
*HashBlock = NULL;
|
||||
NewHashSize = sizeof(HASH_TABLE_CELL) +
|
||||
(SubKeyCount * sizeof(HASH_RECORD));
|
||||
*HBOffset = HvAllocateCell(&RegistryHive->Hive, NewHashSize, Storage);
|
||||
|
||||
if (*HBOffset == HCELL_NULL)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(SubKeyCount <= USHORT_MAX);
|
||||
NewHashBlock = HvGetCell (&RegistryHive->Hive, *HBOffset);
|
||||
NewHashBlock->Id = REG_HASH_TABLE_CELL_ID;
|
||||
NewHashBlock->HashTableSize = SubKeyCount;
|
||||
*HashBlock = NewHashBlock;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CmiAddSubKey(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
IN PCM_KEY_NODE ParentKeyCell,
|
||||
IN HCELL_INDEX ParentKeyCellOffset,
|
||||
IN PCUNICODE_STRING SubKeyName,
|
||||
IN ULONG CreateOptions,
|
||||
OUT PCM_KEY_NODE *pSubKeyCell,
|
||||
OUT HCELL_INDEX *pBlockOffset)
|
||||
{
|
||||
PHASH_TABLE_CELL HashBlock;
|
||||
HCELL_INDEX NKBOffset;
|
||||
PCM_KEY_NODE NewKeyCell;
|
||||
ULONG NewBlockSize;
|
||||
NTSTATUS Status;
|
||||
USHORT NameSize;
|
||||
PWSTR NamePtr;
|
||||
BOOLEAN Packable;
|
||||
HV_STORAGE_TYPE Storage;
|
||||
ULONG i;
|
||||
|
||||
DPRINT("CmiAddSubKey(%p '%wZ')\n", RegistryHive, SubKeyName);
|
||||
|
||||
VERIFY_KEY_CELL(ParentKeyCell);
|
||||
|
||||
/* Skip leading backslash */
|
||||
if (SubKeyName->Buffer[0] == L'\\')
|
||||
{
|
||||
NamePtr = &SubKeyName->Buffer[1];
|
||||
NameSize = SubKeyName->Length - sizeof(WCHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
NamePtr = SubKeyName->Buffer;
|
||||
NameSize = SubKeyName->Length;
|
||||
}
|
||||
|
||||
/* Check whether key name can be packed */
|
||||
Packable = TRUE;
|
||||
for (i = 0; i < NameSize / sizeof(WCHAR); i++)
|
||||
{
|
||||
if (NamePtr[i] & 0xFF00)
|
||||
{
|
||||
Packable = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Adjust name size */
|
||||
if (Packable)
|
||||
{
|
||||
NameSize = NameSize / sizeof(WCHAR);
|
||||
}
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
Storage = (CreateOptions & REG_OPTION_VOLATILE) ? HvVolatile : HvStable;
|
||||
NewBlockSize = sizeof(CM_KEY_NODE) + NameSize;
|
||||
NKBOffset = HvAllocateCell(&RegistryHive->Hive, NewBlockSize, Storage);
|
||||
if (NKBOffset == HCELL_NULL)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewKeyCell = HvGetCell (&RegistryHive->Hive, NKBOffset);
|
||||
NewKeyCell->Id = REG_KEY_CELL_ID;
|
||||
if (CreateOptions & REG_OPTION_VOLATILE)
|
||||
{
|
||||
NewKeyCell->Flags = REG_KEY_VOLATILE_CELL;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewKeyCell->Flags = 0;
|
||||
}
|
||||
KeQuerySystemTime(&NewKeyCell->LastWriteTime);
|
||||
NewKeyCell->Parent = HCELL_NULL;
|
||||
NewKeyCell->SubKeyCounts[HvStable] = 0;
|
||||
NewKeyCell->SubKeyCounts[HvVolatile] = 0;
|
||||
NewKeyCell->SubKeyLists[HvStable] = HCELL_NULL;
|
||||
NewKeyCell->SubKeyLists[HvVolatile] = HCELL_NULL;
|
||||
NewKeyCell->ValueList.Count = 0;
|
||||
NewKeyCell->ValueList.List = HCELL_NULL;
|
||||
NewKeyCell->SecurityKeyOffset = HCELL_NULL;
|
||||
NewKeyCell->ClassNameOffset = HCELL_NULL;
|
||||
|
||||
/* Pack the key name */
|
||||
NewKeyCell->NameSize = NameSize;
|
||||
if (Packable)
|
||||
{
|
||||
NewKeyCell->Flags |= REG_KEY_NAME_PACKED;
|
||||
for (i = 0; i < NameSize; i++)
|
||||
{
|
||||
NewKeyCell->Name[i] = (CHAR)(NamePtr[i] & 0x00FF);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlCopyMemory(
|
||||
NewKeyCell->Name,
|
||||
NamePtr,
|
||||
NameSize);
|
||||
}
|
||||
|
||||
VERIFY_KEY_CELL(NewKeyCell);
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (ParentKeyCell->SubKeyLists[Storage] == HCELL_NULL)
|
||||
{
|
||||
Status = CmiAllocateHashTableCell (
|
||||
RegistryHive,
|
||||
&HashBlock,
|
||||
&ParentKeyCell->SubKeyLists[Storage],
|
||||
REG_INIT_HASH_TABLE_SIZE,
|
||||
Storage);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HashBlock = HvGetCell (
|
||||
&RegistryHive->Hive,
|
||||
ParentKeyCell->SubKeyLists[Storage]);
|
||||
ASSERT(HashBlock->Id == REG_HASH_TABLE_CELL_ID);
|
||||
|
||||
if (((ParentKeyCell->SubKeyCounts[Storage] + 1) >= HashBlock->HashTableSize))
|
||||
{
|
||||
PHASH_TABLE_CELL NewHashBlock;
|
||||
HCELL_INDEX HTOffset;
|
||||
|
||||
/* Reallocate the hash table cell */
|
||||
Status = CmiAllocateHashTableCell (
|
||||
RegistryHive,
|
||||
&NewHashBlock,
|
||||
&HTOffset,
|
||||
HashBlock->HashTableSize +
|
||||
REG_EXTEND_HASH_TABLE_SIZE,
|
||||
Storage);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
RtlZeroMemory(
|
||||
&NewHashBlock->Table[0],
|
||||
sizeof(NewHashBlock->Table[0]) * NewHashBlock->HashTableSize);
|
||||
RtlCopyMemory(
|
||||
&NewHashBlock->Table[0],
|
||||
&HashBlock->Table[0],
|
||||
sizeof(NewHashBlock->Table[0]) * HashBlock->HashTableSize);
|
||||
HvFreeCell (&RegistryHive->Hive, ParentKeyCell->SubKeyLists[Storage]);
|
||||
ParentKeyCell->SubKeyLists[Storage] = HTOffset;
|
||||
HashBlock = NewHashBlock;
|
||||
}
|
||||
}
|
||||
|
||||
Status = CmiAddKeyToHashTable(
|
||||
RegistryHive,
|
||||
HashBlock,
|
||||
ParentKeyCell,
|
||||
Storage,
|
||||
NewKeyCell,
|
||||
NKBOffset);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
ParentKeyCell->SubKeyCounts[Storage]++;
|
||||
*pSubKeyCell = NewKeyCell;
|
||||
*pBlockOffset = NKBOffset;
|
||||
}
|
||||
|
||||
KeQuerySystemTime(&ParentKeyCell->LastWriteTime);
|
||||
HvMarkCellDirty(&RegistryHive->Hive, ParentKeyCellOffset);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
CmiCompareHash(
|
||||
IN PCUNICODE_STRING KeyName,
|
||||
IN PCHAR HashString)
|
||||
{
|
||||
CHAR Buffer[4];
|
||||
|
||||
Buffer[0] = (KeyName->Length >= 2) ? (CHAR)KeyName->Buffer[0] : 0;
|
||||
Buffer[1] = (KeyName->Length >= 4) ? (CHAR)KeyName->Buffer[1] : 0;
|
||||
Buffer[2] = (KeyName->Length >= 6) ? (CHAR)KeyName->Buffer[2] : 0;
|
||||
Buffer[3] = (KeyName->Length >= 8) ? (CHAR)KeyName->Buffer[3] : 0;
|
||||
|
||||
return (strncmp(Buffer, HashString, 4) == 0);
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
CmiCompareHashI(
|
||||
IN PCUNICODE_STRING KeyName,
|
||||
IN PCHAR HashString)
|
||||
{
|
||||
CHAR Buffer[4];
|
||||
|
||||
Buffer[0] = (KeyName->Length >= 2) ? (CHAR)KeyName->Buffer[0] : 0;
|
||||
Buffer[1] = (KeyName->Length >= 4) ? (CHAR)KeyName->Buffer[1] : 0;
|
||||
Buffer[2] = (KeyName->Length >= 6) ? (CHAR)KeyName->Buffer[2] : 0;
|
||||
Buffer[3] = (KeyName->Length >= 8) ? (CHAR)KeyName->Buffer[3] : 0;
|
||||
|
||||
return (_strnicmp(Buffer, HashString, 4) == 0);
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
CmiCompareKeyNames(
|
||||
IN PCUNICODE_STRING KeyName,
|
||||
IN PCM_KEY_NODE KeyCell)
|
||||
{
|
||||
PWCHAR UnicodeName;
|
||||
USHORT i;
|
||||
|
||||
if (KeyCell->Flags & REG_KEY_NAME_PACKED)
|
||||
{
|
||||
if (KeyName->Length != KeyCell->NameSize * sizeof(WCHAR))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < KeyCell->NameSize; i++)
|
||||
{
|
||||
if (KeyName->Buffer[i] != (WCHAR)KeyCell->Name[i])
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (KeyName->Length != KeyCell->NameSize)
|
||||
return FALSE;
|
||||
|
||||
UnicodeName = (PWCHAR)KeyCell->Name;
|
||||
for (i = 0; i < KeyCell->NameSize / sizeof(WCHAR); i++)
|
||||
{
|
||||
if (KeyName->Buffer[i] != UnicodeName[i])
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
CmiCompareKeyNamesI(
|
||||
IN PCUNICODE_STRING KeyName,
|
||||
IN PCM_KEY_NODE KeyCell)
|
||||
{
|
||||
PWCHAR UnicodeName;
|
||||
USHORT i;
|
||||
|
||||
DPRINT("Flags: %hx\n", KeyCell->Flags);
|
||||
|
||||
if (KeyCell->Flags & REG_KEY_NAME_PACKED)
|
||||
{
|
||||
if (KeyName->Length != KeyCell->NameSize * sizeof(WCHAR))
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: use _strnicmp */
|
||||
for (i = 0; i < KeyCell->NameSize; i++)
|
||||
{
|
||||
if (RtlUpcaseUnicodeChar(KeyName->Buffer[i]) !=
|
||||
RtlUpcaseUnicodeChar((WCHAR)KeyCell->Name[i]))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (KeyName->Length != KeyCell->NameSize)
|
||||
return FALSE;
|
||||
|
||||
UnicodeName = (PWCHAR)KeyCell->Name;
|
||||
/* FIXME: use _strnicmp */
|
||||
for (i = 0; i < KeyCell->NameSize / sizeof(WCHAR); i++)
|
||||
{
|
||||
if (RtlUpcaseUnicodeChar(KeyName->Buffer[i]) !=
|
||||
RtlUpcaseUnicodeChar(UnicodeName[i]))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CmiScanForSubKey(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
IN PCM_KEY_NODE KeyCell,
|
||||
IN PCUNICODE_STRING SubKeyName,
|
||||
IN ULONG Attributes,
|
||||
OUT PCM_KEY_NODE *pSubKeyCell,
|
||||
OUT HCELL_INDEX *pBlockOffset)
|
||||
{
|
||||
PHASH_TABLE_CELL HashBlock;
|
||||
PCM_KEY_NODE CurSubKeyCell;
|
||||
ULONG Storage;
|
||||
ULONG i;
|
||||
|
||||
VERIFY_KEY_CELL(KeyCell);
|
||||
|
||||
DPRINT("CmiScanForSubKey('%wZ')\n", SubKeyName);
|
||||
|
||||
ASSERT(RegistryHive);
|
||||
|
||||
*pSubKeyCell = NULL;
|
||||
|
||||
for (Storage = HvStable; Storage < HvMaxStorageType; Storage++)
|
||||
{
|
||||
if (KeyCell->SubKeyLists[Storage] == HCELL_NULL)
|
||||
{
|
||||
/* The key does not have any subkeys */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Get hash table */
|
||||
HashBlock = HvGetCell (&RegistryHive->Hive, KeyCell->SubKeyLists[Storage]);
|
||||
if (!HashBlock || HashBlock->Id != REG_HASH_TABLE_CELL_ID)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
|
||||
for (i = 0; i < KeyCell->SubKeyCounts[Storage]; i++)
|
||||
{
|
||||
if (Attributes & OBJ_CASE_INSENSITIVE)
|
||||
{
|
||||
if ((HashBlock->Table[i].HashValue == 0
|
||||
|| CmiCompareHashI(SubKeyName, (PCHAR)&HashBlock->Table[i].HashValue)))
|
||||
{
|
||||
CurSubKeyCell = HvGetCell (
|
||||
&RegistryHive->Hive,
|
||||
HashBlock->Table[i].KeyOffset);
|
||||
|
||||
if (CmiCompareKeyNamesI(SubKeyName, CurSubKeyCell))
|
||||
{
|
||||
*pSubKeyCell = CurSubKeyCell;
|
||||
*pBlockOffset = HashBlock->Table[i].KeyOffset;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((HashBlock->Table[i].HashValue == 0
|
||||
|| CmiCompareHash(SubKeyName, (PCHAR)&HashBlock->Table[i].HashValue)))
|
||||
{
|
||||
CurSubKeyCell = HvGetCell (
|
||||
&RegistryHive->Hive,
|
||||
HashBlock->Table[i].KeyOffset);
|
||||
|
||||
if (CmiCompareKeyNames(SubKeyName, CurSubKeyCell))
|
||||
{
|
||||
*pSubKeyCell = CurSubKeyCell;
|
||||
*pBlockOffset = HashBlock->Table[i].KeyOffset;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
static USHORT
|
||||
CmiGetPackedNameLength(
|
||||
IN PCUNICODE_STRING Name,
|
||||
OUT PBOOLEAN pPackable)
|
||||
{
|
||||
USHORT i;
|
||||
|
||||
*pPackable = TRUE;
|
||||
|
||||
for (i = 0; i < Name->Length / sizeof(WCHAR); i++)
|
||||
{
|
||||
if (Name->Buffer[i] & 0xFF00)
|
||||
{
|
||||
*pPackable = FALSE;
|
||||
return Name->Length;
|
||||
}
|
||||
}
|
||||
|
||||
return (Name->Length / sizeof(WCHAR));
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
CmiAllocateValueCell(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
OUT PCM_KEY_VALUE *ValueCell,
|
||||
OUT HCELL_INDEX *VBOffset,
|
||||
IN PCUNICODE_STRING ValueName,
|
||||
IN HV_STORAGE_TYPE Storage)
|
||||
{
|
||||
PCM_KEY_VALUE NewValueCell;
|
||||
BOOLEAN Packable;
|
||||
USHORT NameSize, i;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
NameSize = CmiGetPackedNameLength(ValueName, &Packable);
|
||||
|
||||
DPRINT("ValueName->Length %lu NameSize %lu\n", ValueName->Length, NameSize);
|
||||
|
||||
*VBOffset = HvAllocateCell(&RegistryHive->Hive, sizeof(CM_KEY_VALUE) + NameSize, Storage);
|
||||
if (*VBOffset == HCELL_NULL)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(NameSize <= USHORT_MAX);
|
||||
NewValueCell = HvGetCell (&RegistryHive->Hive, *VBOffset);
|
||||
NewValueCell->Id = REG_VALUE_CELL_ID;
|
||||
NewValueCell->NameSize = (USHORT)NameSize;
|
||||
if (Packable)
|
||||
{
|
||||
/* Pack the value name */
|
||||
for (i = 0; i < NameSize; i++)
|
||||
NewValueCell->Name[i] = (CHAR)ValueName->Buffer[i];
|
||||
NewValueCell->Flags |= REG_VALUE_NAME_PACKED;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Copy the value name */
|
||||
RtlCopyMemory(
|
||||
NewValueCell->Name,
|
||||
ValueName->Buffer,
|
||||
NameSize);
|
||||
NewValueCell->Flags = 0;
|
||||
}
|
||||
NewValueCell->DataType = 0;
|
||||
NewValueCell->DataSize = 0;
|
||||
NewValueCell->DataOffset = HCELL_NULL;
|
||||
*ValueCell = NewValueCell;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CmiAddValueKey(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
IN PCM_KEY_NODE KeyCell,
|
||||
IN HCELL_INDEX KeyCellOffset,
|
||||
IN PCUNICODE_STRING ValueName,
|
||||
OUT PCM_KEY_VALUE *pValueCell,
|
||||
OUT HCELL_INDEX *pValueCellOffset)
|
||||
{
|
||||
PVALUE_LIST_CELL ValueListCell;
|
||||
PCM_KEY_VALUE NewValueCell;
|
||||
HCELL_INDEX ValueListCellOffset;
|
||||
HCELL_INDEX NewValueCellOffset;
|
||||
ULONG CellSize;
|
||||
HV_STORAGE_TYPE Storage;
|
||||
NTSTATUS Status;
|
||||
|
||||
Storage = (KeyCell->Flags & REG_KEY_VOLATILE_CELL) ? HvVolatile : HvStable;
|
||||
if (KeyCell->ValueList.List == HCELL_NULL)
|
||||
{
|
||||
/* Allocate some room for the value list */
|
||||
CellSize = sizeof(VALUE_LIST_CELL) + (3 * sizeof(HCELL_INDEX));
|
||||
ValueListCellOffset = HvAllocateCell(&RegistryHive->Hive, CellSize, Storage);
|
||||
if (ValueListCellOffset == HCELL_NULL)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
ValueListCell = HvGetCell(&RegistryHive->Hive, ValueListCellOffset);
|
||||
if (!ValueListCell)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
KeyCell->ValueList.List = ValueListCellOffset;
|
||||
HvMarkCellDirty(&RegistryHive->Hive, KeyCellOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
ValueListCell = (PVALUE_LIST_CELL)HvGetCell(&RegistryHive->Hive, KeyCell->ValueList.List);
|
||||
if (!ValueListCell)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
CellSize = ABS_VALUE(HvGetCellSize(&RegistryHive->Hive, ValueListCell));
|
||||
|
||||
if (KeyCell->ValueList.Count >= CellSize / sizeof(HCELL_INDEX))
|
||||
{
|
||||
CellSize *= 2;
|
||||
ValueListCellOffset = HvReallocateCell(&RegistryHive->Hive, KeyCell->ValueList.List, CellSize);
|
||||
if (ValueListCellOffset == HCELL_NULL)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
ValueListCell = HvGetCell(&RegistryHive->Hive, ValueListCellOffset);
|
||||
if (!ValueListCell)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
KeyCell->ValueList.List = ValueListCellOffset;
|
||||
HvMarkCellDirty(&RegistryHive->Hive, KeyCellOffset);
|
||||
}
|
||||
}
|
||||
|
||||
Status = CmiAllocateValueCell(
|
||||
RegistryHive,
|
||||
&NewValueCell,
|
||||
&NewValueCellOffset,
|
||||
ValueName,
|
||||
Storage);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
ValueListCell->ValueOffset[KeyCell->ValueList.Count] = NewValueCellOffset;
|
||||
KeyCell->ValueList.Count++;
|
||||
|
||||
HvMarkCellDirty(&RegistryHive->Hive, KeyCellOffset);
|
||||
HvMarkCellDirty(&RegistryHive->Hive, KeyCell->ValueList.List);
|
||||
HvMarkCellDirty(&RegistryHive->Hive, NewValueCellOffset);
|
||||
|
||||
*pValueCell = NewValueCell;
|
||||
*pValueCellOffset = NewValueCellOffset;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
CmiComparePackedNames(
|
||||
IN PCUNICODE_STRING Name,
|
||||
IN PUCHAR NameBuffer,
|
||||
IN USHORT NameBufferSize,
|
||||
IN BOOLEAN NamePacked)
|
||||
{
|
||||
PWCHAR UNameBuffer;
|
||||
ULONG i;
|
||||
|
||||
if (NamePacked == TRUE)
|
||||
{
|
||||
if (Name->Length != NameBufferSize * sizeof(WCHAR))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < Name->Length / sizeof(WCHAR); i++)
|
||||
{
|
||||
if (RtlUpcaseUnicodeChar(Name->Buffer[i]) != RtlUpcaseUnicodeChar((WCHAR)NameBuffer[i]))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Name->Length != NameBufferSize)
|
||||
return FALSE;
|
||||
|
||||
UNameBuffer = (PWCHAR)NameBuffer;
|
||||
|
||||
for (i = 0; i < Name->Length / sizeof(WCHAR); i++)
|
||||
{
|
||||
if (RtlUpcaseUnicodeChar(Name->Buffer[i]) != RtlUpcaseUnicodeChar(UNameBuffer[i]))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CmiScanForValueKey(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
IN PCM_KEY_NODE KeyCell,
|
||||
IN PCUNICODE_STRING ValueName,
|
||||
OUT PCM_KEY_VALUE *pValueCell,
|
||||
OUT HCELL_INDEX *pValueCellOffset)
|
||||
{
|
||||
PVALUE_LIST_CELL ValueListCell;
|
||||
PCM_KEY_VALUE CurValueCell;
|
||||
ULONG i;
|
||||
|
||||
*pValueCell = NULL;
|
||||
*pValueCellOffset = HCELL_NULL;
|
||||
|
||||
/* The key does not have any values */
|
||||
if (KeyCell->ValueList.List == HCELL_NULL)
|
||||
{
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
ValueListCell = HvGetCell(&RegistryHive->Hive, KeyCell->ValueList.List);
|
||||
|
||||
VERIFY_VALUE_LIST_CELL(ValueListCell);
|
||||
|
||||
for (i = 0; i < KeyCell->ValueList.Count; i++)
|
||||
{
|
||||
CurValueCell = HvGetCell(
|
||||
&RegistryHive->Hive,
|
||||
ValueListCell->ValueOffset[i]);
|
||||
|
||||
if (CmiComparePackedNames(
|
||||
ValueName,
|
||||
CurValueCell->Name,
|
||||
CurValueCell->NameSize,
|
||||
(BOOLEAN)((CurValueCell->Flags & REG_VALUE_NAME_PACKED) ? TRUE : FALSE)))
|
||||
{
|
||||
*pValueCell = CurValueCell;
|
||||
*pValueCellOffset = ValueListCell->ValueOffset[i];
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
67
reactos/tools/mkhive/cmi.h
Normal file
67
reactos/tools/mkhive/cmi.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2006 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/cmi.h
|
||||
* PURPOSE: Registry file manipulation routines
|
||||
* PROGRAMMER: Hervé Poussineau
|
||||
*/
|
||||
|
||||
#define VERIFY_KEY_CELL(key)
|
||||
#define VERIFY_VALUE_LIST_CELL(cell)
|
||||
|
||||
NTSTATUS
|
||||
CmiInitializeTempHive(
|
||||
IN OUT PEREGISTRY_HIVE Hive);
|
||||
|
||||
NTSTATUS
|
||||
CmiAddSubKey(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
IN PCM_KEY_NODE ParentKeyCell,
|
||||
IN HCELL_INDEX ParentKeyCellOffset,
|
||||
IN PCUNICODE_STRING SubKeyName,
|
||||
IN ULONG CreateOptions,
|
||||
OUT PCM_KEY_NODE *pSubKeyCell,
|
||||
OUT HCELL_INDEX *pBlockOffset);
|
||||
|
||||
NTSTATUS
|
||||
CmiScanForSubKey(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
IN PCM_KEY_NODE KeyCell,
|
||||
IN PCUNICODE_STRING SubKeyName,
|
||||
IN ULONG Attributes,
|
||||
OUT PCM_KEY_NODE *pSubKeyCell,
|
||||
OUT HCELL_INDEX *pBlockOffset);
|
||||
|
||||
NTSTATUS
|
||||
CmiAddValueKey(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
IN PCM_KEY_NODE KeyCell,
|
||||
IN HCELL_INDEX KeyCellOffset,
|
||||
IN PCUNICODE_STRING ValueName,
|
||||
OUT PCM_KEY_VALUE *pValueCell,
|
||||
OUT HCELL_INDEX *pValueCellOffset);
|
||||
|
||||
NTSTATUS
|
||||
CmiScanForValueKey(
|
||||
IN PEREGISTRY_HIVE RegistryHive,
|
||||
IN PCM_KEY_NODE KeyCell,
|
||||
IN PCUNICODE_STRING ValueName,
|
||||
OUT PCM_KEY_VALUE *pValueCell,
|
||||
OUT HCELL_INDEX *pValueCellOffset);
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2003 ReactOS Team
|
||||
* Copyright (C) 2003, 2006 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,12 +16,12 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id$
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/mkhive.c
|
||||
* PURPOSE: Hive maker
|
||||
* PROGRAMMER: Eric Kohl
|
||||
* Hervé Poussineau
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
@ -29,9 +29,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "mkhive.h"
|
||||
#include "registry.h"
|
||||
#include "reginf.h"
|
||||
#include "binhive.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stdlib.h>
|
||||
|
@ -105,41 +102,33 @@ int main (int argc, char *argv[])
|
|||
convert_path (FileName, argv[1]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "hivesys.inf");
|
||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||
ImportRegistryFile (FileName);
|
||||
|
||||
convert_path (FileName, argv[1]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "hivecls.inf");
|
||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||
ImportRegistryFile (FileName);
|
||||
|
||||
convert_path (FileName, argv[1]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "hivesft.inf");
|
||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||
ImportRegistryFile (FileName);
|
||||
|
||||
convert_path (FileName, argv[1]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "hivedef.inf");
|
||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||
ImportRegistryFile (FileName);
|
||||
|
||||
for (Param = 3; Param < argc; Param++)
|
||||
{
|
||||
convert_path (FileName, argv[Param]);
|
||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||
ImportRegistryFile (FileName);
|
||||
}
|
||||
|
||||
convert_path (FileName, argv[2]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "system");
|
||||
if (!ExportBinaryHive (FileName, "\\Registry\\Machine\\SYSTEM"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
convert_path (FileName, argv[2]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "software");
|
||||
if (!ExportBinaryHive (FileName, "\\Registry\\Machine\\SOFTWARE"))
|
||||
strcat (FileName, "default");
|
||||
if (!ExportBinaryHive (FileName, &DefaultHive))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -147,7 +136,7 @@ int main (int argc, char *argv[])
|
|||
convert_path (FileName, argv[2]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "sam");
|
||||
if (!ExportBinaryHive (FileName, "\\Registry\\Machine\\SAM"))
|
||||
if (!ExportBinaryHive (FileName, &SamHive))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -155,15 +144,23 @@ int main (int argc, char *argv[])
|
|||
convert_path (FileName, argv[2]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "security");
|
||||
if (!ExportBinaryHive (FileName, "\\Registry\\Machine\\SECURITY"))
|
||||
if (!ExportBinaryHive (FileName, &SecurityHive))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
convert_path (FileName, argv[2]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "default");
|
||||
if (!ExportBinaryHive (FileName, "\\Registry\\User\\.DEFAULT"))
|
||||
strcat (FileName, "software");
|
||||
if (!ExportBinaryHive (FileName, &SoftwareHive))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
convert_path (FileName, argv[2]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "system");
|
||||
if (!ExportBinaryHive (FileName, &SystemHive))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2003 ReactOS Team
|
||||
* Copyright (C) 2003, 2006 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,43 +16,33 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id$
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/mkhive.h
|
||||
* PURPOSE: Hive maker
|
||||
* PROGRAMMER: Eric Kohl
|
||||
* Hervé Poussineau
|
||||
*/
|
||||
|
||||
#ifndef __MKHIVE_H__
|
||||
#define __MKHIVE_H__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define VOID void
|
||||
typedef void *PVOID;
|
||||
typedef char CHAR, *PCHAR;
|
||||
typedef short WCHAR, *PWCHAR;
|
||||
typedef unsigned char UCHAR, *PUCHAR;
|
||||
typedef short SHORT, *PSHORT;
|
||||
typedef unsigned short USHORT, *PUSHORT;
|
||||
typedef long LONG, *PLONG;
|
||||
typedef unsigned long ULONG, *PULONG;
|
||||
|
||||
typedef unsigned long ULONG_PTR;
|
||||
|
||||
typedef int BOOL, *PBOOL;
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
#define NTOS_MODE_USER
|
||||
#define WIN32_NO_STATUS
|
||||
#include <ntddk.h>
|
||||
#include <cmlib.h>
|
||||
#include <infhost.h>
|
||||
#include "reginf.h"
|
||||
#include "cmi.h"
|
||||
#include "registry.h"
|
||||
#include "binhive.h"
|
||||
|
||||
#define HIVE_NO_FILE 2
|
||||
#define VERIFY_REGISTRY_HIVE(hive)
|
||||
extern LIST_ENTRY CmiHiveListHead;
|
||||
#define ABS_VALUE(V) (((V) < 0) ? -(V) : (V))
|
||||
|
||||
#ifndef max
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
@ -88,7 +78,7 @@ static void DPRINT ( const char* fmt, ... )
|
|||
|
||||
#ifdef WIN32
|
||||
#define strncasecmp strnicmp
|
||||
#define strcasecmp stricmp
|
||||
#define strcasecmp _stricmp
|
||||
#endif//WIN32
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -1,61 +1,73 @@
|
|||
MKHIVE_BASE = $(TOOLS_BASE_)mkhive
|
||||
MKHIVE_BASE_ = $(MKHIVE_BASE)$(SEP)
|
||||
MKHIVE_INT = $(INTERMEDIATE_)$(MKHIVE_BASE)
|
||||
MKHIVE_INT_ = $(MKHIVE_INT)$(SEP)
|
||||
MKHIVE_OUT = $(OUTPUT_)$(MKHIVE_BASE)
|
||||
MKHIVE_OUT_ = $(MKHIVE_OUT)$(SEP)
|
||||
|
||||
$(MKHIVE_INT): | $(TOOLS_INT)
|
||||
$(ECHO_MKDIR)
|
||||
${mkdir} $@
|
||||
|
||||
ifneq ($(INTERMEDIATE),$(OUTPUT))
|
||||
$(MKHIVE_OUT): | $(TOOLS_OUT)
|
||||
$(ECHO_MKDIR)
|
||||
${mkdir} $@
|
||||
endif
|
||||
|
||||
MKHIVE_TARGET = \
|
||||
$(EXEPREFIX)$(MKHIVE_OUT_)mkhive$(EXEPOSTFIX)
|
||||
|
||||
MKHIVE_SOURCES = $(addprefix $(MKHIVE_BASE_), \
|
||||
binhive.c \
|
||||
mkhive.c \
|
||||
reginf.c \
|
||||
registry.c \
|
||||
)
|
||||
|
||||
MKHIVE_OBJECTS = \
|
||||
$(addprefix $(INTERMEDIATE_), $(MKHIVE_SOURCES:.c=.o))
|
||||
|
||||
MKHIVE_HOST_CFLAGS = $(xTOOLS_CFLAGS) -I$(INFLIB_BASE) -g3
|
||||
|
||||
MKHIVE_HOST_LFLAGS = $(xTOOLS_LFLAGS) -g3
|
||||
|
||||
.PHONY: mkhive
|
||||
mkhive: $(MKHIVE_TARGET)
|
||||
|
||||
$(MKHIVE_TARGET): $(MKHIVE_OBJECTS) $(INFLIB_HOST_OBJECTS) | $(MKHIVE_OUT)
|
||||
$(ECHO_LD)
|
||||
${host_gcc} $(MKHIVE_OBJECTS) $(INFLIB_HOST_OBJECTS) $(MKHIVE_HOST_LFLAGS) -o $@
|
||||
|
||||
$(MKHIVE_INT_)binhive.o: $(MKHIVE_BASE_)binhive.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(MKHIVE_INT_)mkhive.o: $(MKHIVE_BASE_)mkhive.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(MKHIVE_INT_)reginf.o: $(MKHIVE_BASE_)reginf.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(MKHIVE_INT_)registry.o: $(MKHIVE_BASE_)registry.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
.PHONY: mkhive_clean
|
||||
mkhive_clean:
|
||||
-@$(rm) $(MKHIVE_TARGET) $(MKHIVE_OBJECTS) 2>$(NUL)
|
||||
clean: mkhive_clean
|
||||
MKHIVE_BASE = $(TOOLS_BASE_)mkhive
|
||||
MKHIVE_BASE_ = $(MKHIVE_BASE)$(SEP)
|
||||
MKHIVE_INT = $(INTERMEDIATE_)$(MKHIVE_BASE)
|
||||
MKHIVE_INT_ = $(MKHIVE_INT)$(SEP)
|
||||
MKHIVE_OUT = $(OUTPUT_)$(MKHIVE_BASE)
|
||||
MKHIVE_OUT_ = $(MKHIVE_OUT)$(SEP)
|
||||
|
||||
$(MKHIVE_INT): | $(TOOLS_INT)
|
||||
$(ECHO_MKDIR)
|
||||
${mkdir} $@
|
||||
|
||||
ifneq ($(INTERMEDIATE),$(OUTPUT))
|
||||
$(MKHIVE_OUT): | $(TOOLS_OUT)
|
||||
$(ECHO_MKDIR)
|
||||
${mkdir} $@
|
||||
endif
|
||||
|
||||
MKHIVE_TARGET = \
|
||||
$(EXEPREFIX)$(MKHIVE_OUT_)mkhive$(EXEPOSTFIX)
|
||||
|
||||
MKHIVE_SOURCES = $(addprefix $(MKHIVE_BASE_), \
|
||||
binhive.c \
|
||||
cmi.c \
|
||||
mkhive.c \
|
||||
reginf.c \
|
||||
registry.c \
|
||||
rtl.c \
|
||||
)
|
||||
|
||||
MKHIVE_OBJECTS = \
|
||||
$(addprefix $(INTERMEDIATE_), $(MKHIVE_SOURCES:.c=.o))
|
||||
|
||||
MKHIVE_HOST_CFLAGS = $(xTOOLS_CFLAGS) -I$(INFLIB_BASE) -I$(CMLIB_BASE) \
|
||||
-D_NTOSKRNL_ \
|
||||
-Iinclude/reactos -Iinclude/ddk -Iinclude/ndk -Iinclude/psdk -Iinclude -g3
|
||||
|
||||
MKHIVE_HOST_LFLAGS = $(xTOOLS_LFLAGS) -g3
|
||||
|
||||
.PHONY: mkhive
|
||||
mkhive: $(MKHIVE_TARGET)
|
||||
|
||||
$(MKHIVE_TARGET): $(MKHIVE_OBJECTS) $(INFLIB_HOST_OBJECTS) $(CMLIB_HOST_OBJECTS) | $(MKHIVE_OUT)
|
||||
$(ECHO_LD)
|
||||
${host_gcc} $(MKHIVE_OBJECTS) $(INFLIB_HOST_OBJECTS) $(CMLIB_HOST_OBJECTS) $(MKHIVE_HOST_LFLAGS) -o $@
|
||||
|
||||
$(MKHIVE_INT_)binhive.o: $(MKHIVE_BASE_)binhive.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(MKHIVE_INT_)cmi.o: $(MKHIVE_BASE_)cmi.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(MKHIVE_INT_)mkhive.o: $(MKHIVE_BASE_)mkhive.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(MKHIVE_INT_)reginf.o: $(MKHIVE_BASE_)reginf.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(MKHIVE_INT_)registry.o: $(MKHIVE_BASE_)registry.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(MKHIVE_INT_)rtl.o: $(MKHIVE_BASE_)rtl.c | $(MKHIVE_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gcc} $(MKHIVE_HOST_CFLAGS) -Ilib/rtl -c $< -o $@
|
||||
|
||||
.PHONY: mkhive_clean
|
||||
mkhive_clean:
|
||||
-@$(rm) $(MKHIVE_TARGET) $(MKHIVE_OBJECTS) 2>$(NUL)
|
||||
clean: mkhive_clean
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2003 ReactOS Team
|
||||
* Copyright (C) 2003, 2006 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,12 +16,12 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id$
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/reginf.h
|
||||
* PURPOSE: Inf file import code
|
||||
* PROGRAMMER: Eric Kohl
|
||||
* Hervé Poussineau
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
@ -30,11 +30,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include "mkhive.h"
|
||||
#include "registry.h"
|
||||
#include <infhost.h>
|
||||
|
||||
|
||||
|
||||
#define FLG_ADDREG_BINVALUETYPE 0x00000001
|
||||
#define FLG_ADDREG_NOCLOBBER 0x00000002
|
||||
|
@ -98,18 +95,19 @@ static VOID
|
|||
AppendMultiSzValue (HKEY KeyHandle,
|
||||
PCHAR ValueName,
|
||||
PCHAR Strings,
|
||||
ULONG StringSize)
|
||||
SIZE_T StringSize)
|
||||
{
|
||||
ULONG Size;
|
||||
SIZE_T Size;
|
||||
ULONG Type;
|
||||
ULONG Total;
|
||||
size_t Total;
|
||||
PCHAR Buffer;
|
||||
PCHAR p;
|
||||
int len;
|
||||
size_t len;
|
||||
LONG Error;
|
||||
|
||||
Error = RegQueryValue (KeyHandle,
|
||||
Error = RegQueryValueExA (KeyHandle,
|
||||
ValueName,
|
||||
NULL,
|
||||
&Type,
|
||||
NULL,
|
||||
&Size);
|
||||
|
@ -121,10 +119,11 @@ AppendMultiSzValue (HKEY KeyHandle,
|
|||
if (Buffer == NULL)
|
||||
return;
|
||||
|
||||
Error = RegQueryValue (KeyHandle,
|
||||
Error = RegQueryValueExA (KeyHandle,
|
||||
ValueName,
|
||||
NULL,
|
||||
(PCHAR)Buffer,
|
||||
NULL,
|
||||
(PUCHAR)Buffer,
|
||||
&Size);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
goto done;
|
||||
|
@ -151,11 +150,12 @@ AppendMultiSzValue (HKEY KeyHandle,
|
|||
if (Total != Size)
|
||||
{
|
||||
DPRINT ("setting value %s to %s\n", ValueName, Buffer);
|
||||
RegSetValue (KeyHandle,
|
||||
RegSetValueExA (KeyHandle,
|
||||
ValueName,
|
||||
0,
|
||||
REG_MULTI_SZ,
|
||||
(PCHAR)Buffer,
|
||||
Total);
|
||||
(ULONG)Total);
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -176,19 +176,19 @@ do_reg_operation(HKEY KeyHandle,
|
|||
{
|
||||
CHAR EmptyStr = (CHAR)0;
|
||||
ULONG Type;
|
||||
ULONG Size;
|
||||
SIZE_T Size;
|
||||
LONG Error;
|
||||
|
||||
if (Flags & FLG_ADDREG_DELVAL) /* deletion */
|
||||
{
|
||||
if (ValueName)
|
||||
{
|
||||
RegDeleteValue (KeyHandle,
|
||||
RegDeleteValueA (KeyHandle,
|
||||
ValueName);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegDeleteKey (KeyHandle,
|
||||
RegDeleteKeyA (KeyHandle,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
@ -200,10 +200,11 @@ do_reg_operation(HKEY KeyHandle,
|
|||
|
||||
if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
|
||||
{
|
||||
Error = RegQueryValue (KeyHandle,
|
||||
Error = RegQueryValueExA (KeyHandle,
|
||||
ValueName,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
if ((Error == ERROR_SUCCESS) &&
|
||||
(Flags & FLG_ADDREG_NOCLOBBER))
|
||||
|
@ -300,10 +301,11 @@ do_reg_operation(HKEY KeyHandle,
|
|||
|
||||
DPRINT("setting dword %s to %lx\n", ValueName, dw);
|
||||
|
||||
RegSetValue (KeyHandle,
|
||||
RegSetValueExA (KeyHandle,
|
||||
ValueName,
|
||||
0,
|
||||
Type,
|
||||
(PVOID)&dw,
|
||||
(const PUCHAR)&dw,
|
||||
sizeof(ULONG));
|
||||
}
|
||||
else
|
||||
|
@ -312,19 +314,21 @@ do_reg_operation(HKEY KeyHandle,
|
|||
|
||||
if (Str)
|
||||
{
|
||||
RegSetValue (KeyHandle,
|
||||
RegSetValueExA (KeyHandle,
|
||||
ValueName,
|
||||
0,
|
||||
Type,
|
||||
(PVOID)Str,
|
||||
Size);
|
||||
(ULONG)Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegSetValue (KeyHandle,
|
||||
RegSetValueExA (KeyHandle,
|
||||
ValueName,
|
||||
0,
|
||||
Type,
|
||||
(PVOID)&EmptyStr,
|
||||
sizeof(CHAR));
|
||||
(ULONG)sizeof(CHAR));
|
||||
}
|
||||
}
|
||||
free (Str);
|
||||
|
@ -346,11 +350,12 @@ do_reg_operation(HKEY KeyHandle,
|
|||
InfHostGetBinaryField (Context, 5, Data, Size, NULL);
|
||||
}
|
||||
|
||||
RegSetValue (KeyHandle,
|
||||
RegSetValueExA (KeyHandle,
|
||||
ValueName,
|
||||
0,
|
||||
Type,
|
||||
(PVOID)Data,
|
||||
Size);
|
||||
(ULONG)Size);
|
||||
|
||||
free (Data);
|
||||
}
|
||||
|
@ -370,7 +375,7 @@ registry_callback (HINF hInf, PCHAR Section, BOOL Delete)
|
|||
CHAR Buffer[MAX_INF_STRING_LENGTH];
|
||||
PCHAR ValuePtr;
|
||||
ULONG Flags;
|
||||
ULONG Length;
|
||||
size_t Length;
|
||||
|
||||
PINFCONTEXT Context = NULL;
|
||||
HKEY KeyHandle;
|
||||
|
@ -411,7 +416,7 @@ registry_callback (HINF hInf, PCHAR Section, BOOL Delete)
|
|||
|
||||
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
|
||||
{
|
||||
if (RegOpenKey (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
||||
if (RegOpenKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT("RegOpenKey(%s) failed\n", Buffer);
|
||||
continue; /* ignore if it doesn't exist */
|
||||
|
@ -419,7 +424,7 @@ registry_callback (HINF hInf, PCHAR Section, BOOL Delete)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (RegCreateKey (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
||||
if (RegCreateKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT("RegCreateKey(%s) failed\n", Buffer);
|
||||
continue;
|
||||
|
@ -450,9 +455,7 @@ registry_callback (HINF hInf, PCHAR Section, BOOL Delete)
|
|||
|
||||
|
||||
BOOL
|
||||
ImportRegistryFile(PCHAR FileName,
|
||||
PCHAR Section,
|
||||
BOOL Delete)
|
||||
ImportRegistryFile(PCHAR FileName)
|
||||
{
|
||||
HINF hInf;
|
||||
ULONG ErrorLine;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2003 ReactOS Team
|
||||
* Copyright (C) 2006 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,21 +16,18 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id$
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/reginf.h
|
||||
* PURPOSE: Inf file import code
|
||||
* PROGRAMMER: Eric Kohl
|
||||
* PROGRAMMER: Hervé Poussineau
|
||||
*/
|
||||
|
||||
#ifndef __REGINF_H__
|
||||
#define __REGINF_H__
|
||||
|
||||
BOOL
|
||||
ImportRegistryFile(PCHAR Filename,
|
||||
PCHAR Section,
|
||||
BOOL Delete);
|
||||
ImportRegistryFile(PCHAR Filename);
|
||||
|
||||
#endif /* __REGINF_H__ */
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,61 +1,12 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2003 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id$
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/registry.h
|
||||
* PURPOSE: Registry code
|
||||
* PROGRAMMER: Eric Kohl
|
||||
*/
|
||||
|
||||
#ifndef __REGISTRY_H__
|
||||
#define __REGISTRY_H__
|
||||
|
||||
|
||||
#define INVALID_HANDLE_VALUE NULL
|
||||
|
||||
typedef struct _LIST_ENTRY
|
||||
{
|
||||
struct _LIST_ENTRY *Flink;
|
||||
struct _LIST_ENTRY *Blink;
|
||||
} LIST_ENTRY, *PLIST_ENTRY;
|
||||
|
||||
|
||||
typedef struct _REG_KEY
|
||||
{
|
||||
LIST_ENTRY KeyList;
|
||||
LIST_ENTRY SubKeyList;
|
||||
LIST_ENTRY ValueList;
|
||||
|
||||
USHORT SubKeyCount;
|
||||
ULONG ValueCount;
|
||||
|
||||
USHORT NameSize;
|
||||
PCHAR Name;
|
||||
|
||||
/* default data */
|
||||
ULONG DataType;
|
||||
ULONG DataSize;
|
||||
PCHAR Data;
|
||||
} KEY, *HKEY, **PHKEY;
|
||||
|
||||
|
||||
typedef struct _REG_VALUE
|
||||
{
|
||||
LIST_ENTRY ValueList;
|
||||
|
@ -70,9 +21,43 @@ typedef struct _REG_VALUE
|
|||
PCHAR Data;
|
||||
} VALUE, *PVALUE;
|
||||
|
||||
typedef struct _REG_KEY
|
||||
{
|
||||
LIST_ENTRY KeyList;
|
||||
LIST_ENTRY SubKeyList;
|
||||
LIST_ENTRY ValueList;
|
||||
|
||||
ULONG SubKeyCount;
|
||||
ULONG ValueCount;
|
||||
|
||||
ULONG NameSize;
|
||||
PWCHAR Name;
|
||||
|
||||
/* default data */
|
||||
ULONG DataType;
|
||||
ULONG DataSize;
|
||||
PCHAR Data;
|
||||
|
||||
/* Information on hard disk structure */
|
||||
HCELL_INDEX KeyCellOffset;
|
||||
PCM_KEY_NODE KeyCell;
|
||||
PEREGISTRY_HIVE RegistryHive;
|
||||
|
||||
/* Used when linking to another key */
|
||||
struct _REG_KEY* LinkedKey;
|
||||
} KEY, *FRLDRHKEY, **PFRLDRHKEY, *MEMKEY, **PMEMKEY;
|
||||
|
||||
#define HKEY_TO_MEMKEY(hKey) ((MEMKEY)(hKey))
|
||||
#define MEMKEY_TO_HKEY(memKey) ((HKEY)(memKey))
|
||||
|
||||
extern EREGISTRY_HIVE DefaultHive; /* \Registry\User\.DEFAULT */
|
||||
extern EREGISTRY_HIVE SamHive; /* \Registry\Machine\SAM */
|
||||
extern EREGISTRY_HIVE SecurityHive; /* \Registry\Machine\SECURITY */
|
||||
extern EREGISTRY_HIVE SoftwareHive; /* \Registry\Machine\SOFTWARE */
|
||||
extern EREGISTRY_HIVE SystemHive; /* \Registry\Machine\SYSTEM */
|
||||
|
||||
#define ERROR_SUCCESS 0L
|
||||
#define ERROR_PATH_NOT_FOUND 2L
|
||||
#define ERROR_UNSUCCESSFUL 1L
|
||||
#define ERROR_OUTOFMEMORY 14L
|
||||
#define ERROR_INVALID_PARAMETER 87L
|
||||
#define ERROR_MORE_DATA 234L
|
||||
|
@ -155,22 +140,6 @@ typedef struct _REG_VALUE
|
|||
assert((ListEntry)->Flink->Blink == (ListEntry)); \
|
||||
}
|
||||
|
||||
/*
|
||||
* BOOLEAN
|
||||
* IsListEmpty (
|
||||
* PLIST_ENTRY ListHead
|
||||
* );
|
||||
*
|
||||
* FUNCTION:
|
||||
* Checks if a double linked list is empty
|
||||
*
|
||||
* ARGUMENTS:
|
||||
* ListHead = Head of the list
|
||||
*/
|
||||
#define IsListEmpty(ListHead) \
|
||||
((ListHead)->Flink == (ListHead))
|
||||
|
||||
|
||||
/*
|
||||
*VOID
|
||||
*RemoveEntryList (
|
||||
|
@ -200,11 +169,6 @@ typedef struct _REG_VALUE
|
|||
(ListEntry)->Blink = NULL; \
|
||||
}
|
||||
|
||||
/*
|
||||
* PURPOSE: Returns the byte offset of a field within a structure
|
||||
*/
|
||||
#define FIELD_OFFSET(Type,Field) (LONG)(&(((Type *)(0))->Field))
|
||||
|
||||
/*
|
||||
* PURPOSE: Returns the base address structure if the caller knows the
|
||||
* address of a field within the structure
|
||||
|
@ -230,58 +194,42 @@ typedef struct _REG_VALUE
|
|||
#define REG_FULL_RESOURCE_DESCRIPTOR 9
|
||||
#define REG_RESOURCE_REQUIREMENTS_LIST 10
|
||||
|
||||
LONG WINAPI
|
||||
RegCreateKeyA(
|
||||
IN HKEY hKey,
|
||||
IN LPCSTR lpSubKey,
|
||||
OUT PHKEY phkResult);
|
||||
|
||||
LONG WINAPI
|
||||
RegOpenKeyA(
|
||||
IN HKEY hKey,
|
||||
IN LPCSTR lpSubKey,
|
||||
OUT PHKEY phkResult);
|
||||
|
||||
VOID
|
||||
RegInitializeRegistry(VOID);
|
||||
|
||||
LONG
|
||||
RegCreateKey(HKEY ParentKey,
|
||||
PCHAR KeyName,
|
||||
PHKEY Key);
|
||||
|
||||
LONG
|
||||
RegDeleteKey(HKEY Key,
|
||||
PCHAR Name);
|
||||
|
||||
LONG
|
||||
RegEnumKey(HKEY Key,
|
||||
ULONG Index,
|
||||
PCHAR Name,
|
||||
PULONG NameSize);
|
||||
|
||||
LONG
|
||||
RegOpenKey(HKEY ParentKey,
|
||||
PCHAR KeyName,
|
||||
PHKEY Key);
|
||||
|
||||
|
||||
LONG
|
||||
RegSetValue(HKEY Key,
|
||||
PCHAR ValueName,
|
||||
ULONG Type,
|
||||
PCHAR Data,
|
||||
ULONG DataSize);
|
||||
|
||||
LONG
|
||||
RegQueryValue(HKEY Key,
|
||||
PCHAR ValueName,
|
||||
LONG WINAPI
|
||||
RegQueryValueExA(HKEY Key,
|
||||
LPCSTR ValueName,
|
||||
PULONG Reserved,
|
||||
PULONG Type,
|
||||
PCHAR Data,
|
||||
PULONG DataSize);
|
||||
PUCHAR Data,
|
||||
PSIZE_T DataSize);
|
||||
|
||||
LONG
|
||||
RegDeleteValue(HKEY Key,
|
||||
PCHAR ValueName);
|
||||
LONG WINAPI
|
||||
RegSetValueExA(
|
||||
IN HKEY hKey,
|
||||
IN LPCSTR lpValueName OPTIONAL,
|
||||
ULONG Reserved,
|
||||
IN ULONG dwType,
|
||||
IN const PUCHAR lpData,
|
||||
IN ULONG cbData);
|
||||
|
||||
LONG
|
||||
RegEnumValue(HKEY Key,
|
||||
ULONG Index,
|
||||
PCHAR ValueName,
|
||||
PULONG NameSize,
|
||||
PULONG Type,
|
||||
PCHAR Data,
|
||||
PULONG DataSize);
|
||||
LONG WINAPI
|
||||
RegDeleteValueA(HKEY Key,
|
||||
LPCSTR ValueName);
|
||||
|
||||
LONG WINAPI
|
||||
RegDeleteKeyA(HKEY Key,
|
||||
LPCSTR Name);
|
||||
|
||||
USHORT
|
||||
RegGetSubKeyCount (HKEY Key);
|
||||
|
@ -289,16 +237,8 @@ RegGetSubKeyCount (HKEY Key);
|
|||
ULONG
|
||||
RegGetValueCount (HKEY Key);
|
||||
|
||||
|
||||
#if 0
|
||||
BOOL
|
||||
RegImportTextHive(PCHAR ChunkBase,
|
||||
U32 ChunkSize);
|
||||
|
||||
BOOL
|
||||
RegImportBinaryHive(PCHAR ChunkBase,
|
||||
U32 ChunkSize);
|
||||
#endif
|
||||
VOID
|
||||
RegInitializeRegistry(VOID);
|
||||
|
||||
#endif /* __REGISTRY_H__ */
|
||||
|
||||
|
|
143
reactos/tools/mkhive/rtl.c
Normal file
143
reactos/tools/mkhive/rtl.c
Normal file
|
@ -0,0 +1,143 @@
|
|||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/rtl.c
|
||||
* PURPOSE: Runtime Library
|
||||
*/
|
||||
|
||||
#define RTL_H
|
||||
|
||||
#define NTOS_MODE_USER
|
||||
#define WIN32_NO_STATUS
|
||||
#include <ntddk.h>
|
||||
#include <bitmap.c>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*
|
||||
* NOTES
|
||||
* If source is NULL the length of source is assumed to be 0.
|
||||
*/
|
||||
VOID NTAPI
|
||||
RtlInitAnsiString(
|
||||
IN OUT PANSI_STRING DestinationString,
|
||||
IN PCSTR SourceString)
|
||||
{
|
||||
SIZE_T DestSize;
|
||||
|
||||
if(SourceString)
|
||||
{
|
||||
DestSize = strlen(SourceString);
|
||||
DestinationString->Length = (USHORT)DestSize;
|
||||
DestinationString->MaximumLength = (USHORT)DestSize + sizeof(CHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
DestinationString->Length = 0;
|
||||
DestinationString->MaximumLength = 0;
|
||||
}
|
||||
|
||||
DestinationString->Buffer = (PCHAR)SourceString;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*
|
||||
* NOTES
|
||||
* If source is NULL the length of source is assumed to be 0.
|
||||
*/
|
||||
VOID NTAPI
|
||||
RtlInitUnicodeString(
|
||||
IN OUT PUNICODE_STRING DestinationString,
|
||||
IN PCWSTR SourceString)
|
||||
{
|
||||
SIZE_T DestSize;
|
||||
|
||||
if(SourceString)
|
||||
{
|
||||
DestSize = wcslen(SourceString) * sizeof(WCHAR);
|
||||
DestinationString->Length = (USHORT)DestSize;
|
||||
DestinationString->MaximumLength = (USHORT)DestSize + sizeof(WCHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
DestinationString->Length = 0;
|
||||
DestinationString->MaximumLength = 0;
|
||||
}
|
||||
|
||||
DestinationString->Buffer = (PWCHAR)SourceString;
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
RtlAnsiStringToUnicodeString(
|
||||
IN OUT PUNICODE_STRING UniDest,
|
||||
IN PANSI_STRING AnsiSource,
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
ULONG Length;
|
||||
PUCHAR WideString;
|
||||
USHORT i;
|
||||
|
||||
Length = AnsiSource->Length * sizeof(WCHAR);
|
||||
if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2;
|
||||
UniDest->Length = (USHORT)Length;
|
||||
|
||||
if (AllocateDestinationString)
|
||||
{
|
||||
UniDest->MaximumLength = (USHORT)Length + sizeof(WCHAR);
|
||||
UniDest->Buffer = malloc(UniDest->MaximumLength);
|
||||
if (!UniDest->Buffer)
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
else if (UniDest->Length >= UniDest->MaximumLength)
|
||||
{
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
WideString = (PUCHAR)UniDest->Buffer;
|
||||
for (i = 0; i <= AnsiSource->Length; i++)
|
||||
{
|
||||
WideString[2 * i + 0] = AnsiSource->Buffer[i];
|
||||
WideString[2 * i + 1] = 0;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
WCHAR NTAPI
|
||||
RtlUpcaseUnicodeChar(
|
||||
IN WCHAR Source)
|
||||
{
|
||||
USHORT Offset;
|
||||
|
||||
if (Source < 'a')
|
||||
return Source;
|
||||
|
||||
if (Source <= 'z')
|
||||
return (Source - ('a' - 'A'));
|
||||
|
||||
Offset = 0;
|
||||
|
||||
return Source + (SHORT)Offset;
|
||||
}
|
||||
|
||||
VOID NTAPI
|
||||
KeQuerySystemTime(
|
||||
OUT PLARGE_INTEGER CurrentTime)
|
||||
{
|
||||
DPRINT1("KeQuerySystemTime() unimplemented\n");
|
||||
}
|
||||
|
||||
PVOID NTAPI
|
||||
ExAllocatePool(
|
||||
IN POOL_TYPE PoolType,
|
||||
IN SIZE_T NumberOfBytes)
|
||||
{
|
||||
return malloc(NumberOfBytes);
|
||||
}
|
||||
|
||||
VOID NTAPI
|
||||
ExFreePool(
|
||||
IN PVOID p)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
|
Loading…
Reference in a new issue