mirror of
https://github.com/reactos/reactos.git
synced 2024-08-06 11:24:58 +00:00
[MKHIVE] Remove dead code and unused structure fields
Use MEMKEY/PMEMKEY names to represent registry key node in memory. svn path=/trunk/; revision=64548
This commit is contained in:
parent
0744b08c52
commit
32e7565688
|
@ -41,36 +41,28 @@
|
||||||
#define REG_DATA_IN_OFFSET 0x80000000
|
#define REG_DATA_IN_OFFSET 0x80000000
|
||||||
|
|
||||||
static CMHIVE RootHive;
|
static CMHIVE RootHive;
|
||||||
static MEMKEY RootKey;
|
static PMEMKEY RootKey;
|
||||||
CMHIVE DefaultHive; /* \Registry\User\.DEFAULT */
|
CMHIVE DefaultHive; /* \Registry\User\.DEFAULT */
|
||||||
CMHIVE SamHive; /* \Registry\Machine\SAM */
|
CMHIVE SamHive; /* \Registry\Machine\SAM */
|
||||||
CMHIVE SecurityHive; /* \Registry\Machine\SECURITY */
|
CMHIVE SecurityHive; /* \Registry\Machine\SECURITY */
|
||||||
CMHIVE SoftwareHive; /* \Registry\Machine\SOFTWARE */
|
CMHIVE SoftwareHive; /* \Registry\Machine\SOFTWARE */
|
||||||
CMHIVE SystemHive; /* \Registry\Machine\SYSTEM */
|
CMHIVE SystemHive; /* \Registry\Machine\SYSTEM */
|
||||||
|
|
||||||
static MEMKEY
|
static PMEMKEY
|
||||||
CreateInMemoryStructure(
|
CreateInMemoryStructure(
|
||||||
IN PCMHIVE RegistryHive,
|
IN PCMHIVE RegistryHive,
|
||||||
IN HCELL_INDEX KeyCellOffset,
|
IN HCELL_INDEX KeyCellOffset,
|
||||||
IN PCUNICODE_STRING KeyName)
|
IN PCUNICODE_STRING KeyName)
|
||||||
{
|
{
|
||||||
MEMKEY Key;
|
PMEMKEY Key;
|
||||||
|
|
||||||
Key = (MEMKEY) malloc (sizeof(KEY));
|
Key = (PMEMKEY) malloc (sizeof(MEMKEY));
|
||||||
if (!Key)
|
if (!Key)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
InitializeListHead (&Key->SubKeyList);
|
InitializeListHead (&Key->SubKeyList);
|
||||||
InitializeListHead (&Key->ValueList);
|
|
||||||
InitializeListHead (&Key->KeyList);
|
InitializeListHead (&Key->KeyList);
|
||||||
|
|
||||||
Key->SubKeyCount = 0;
|
|
||||||
Key->ValueCount = 0;
|
|
||||||
|
|
||||||
Key->DataType = 0;
|
|
||||||
Key->DataSize = 0;
|
|
||||||
Key->Data = NULL;
|
|
||||||
|
|
||||||
Key->RegistryHive = RegistryHive;
|
Key->RegistryHive = RegistryHive;
|
||||||
Key->KeyCellOffset = Key->KeyCellOffsetInParentHive = KeyCellOffset;
|
Key->KeyCellOffset = Key->KeyCellOffsetInParentHive = KeyCellOffset;
|
||||||
Key->KeyCell = (PCM_KEY_NODE)HvGetCell (&RegistryHive->Hive, Key->KeyCellOffset);
|
Key->KeyCell = (PCM_KEY_NODE)HvGetCell (&RegistryHive->Hive, Key->KeyCellOffset);
|
||||||
|
@ -81,7 +73,6 @@ CreateInMemoryStructure(
|
||||||
}
|
}
|
||||||
Key->KeyCell->SubKeyLists[Stable] = HCELL_NIL;
|
Key->KeyCell->SubKeyLists[Stable] = HCELL_NIL;
|
||||||
Key->KeyCell->SubKeyLists[Volatile] = HCELL_NIL;
|
Key->KeyCell->SubKeyLists[Volatile] = HCELL_NIL;
|
||||||
Key->LinkedKey = NULL;
|
|
||||||
return Key;
|
return Key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +87,8 @@ RegpOpenOrCreateKey(
|
||||||
PWSTR End;
|
PWSTR End;
|
||||||
UNICODE_STRING KeyString;
|
UNICODE_STRING KeyString;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
MEMKEY ParentKey;
|
PMEMKEY ParentKey;
|
||||||
MEMKEY CurrentKey;
|
PMEMKEY CurrentKey;
|
||||||
PLIST_ENTRY Ptr;
|
PLIST_ENTRY Ptr;
|
||||||
PCM_KEY_NODE SubKeyCell;
|
PCM_KEY_NODE SubKeyCell;
|
||||||
HCELL_INDEX BlockOffset;
|
HCELL_INDEX BlockOffset;
|
||||||
|
@ -163,7 +154,7 @@ RegpOpenOrCreateKey(
|
||||||
Ptr = ParentKey->SubKeyList.Flink;
|
Ptr = ParentKey->SubKeyList.Flink;
|
||||||
while (Ptr != &ParentKey->SubKeyList)
|
while (Ptr != &ParentKey->SubKeyList)
|
||||||
{
|
{
|
||||||
CurrentKey = CONTAINING_RECORD(Ptr, KEY, KeyList);
|
CurrentKey = CONTAINING_RECORD(Ptr, MEMKEY, KeyList);
|
||||||
if (CurrentKey->KeyCellOffsetInParentHive == BlockOffset)
|
if (CurrentKey->KeyCellOffsetInParentHive == BlockOffset)
|
||||||
{
|
{
|
||||||
goto nextsubkey;
|
goto nextsubkey;
|
||||||
|
@ -196,7 +187,6 @@ RegpOpenOrCreateKey(
|
||||||
return ERROR_OUTOFMEMORY;
|
return ERROR_OUTOFMEMORY;
|
||||||
/* Add CurrentKey in ParentKey */
|
/* Add CurrentKey in ParentKey */
|
||||||
InsertTailList(&ParentKey->SubKeyList, &CurrentKey->KeyList);
|
InsertTailList(&ParentKey->SubKeyList, &CurrentKey->KeyList);
|
||||||
ParentKey->SubKeyCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -239,24 +229,6 @@ MultiByteToWideChar(
|
||||||
return Destination.Buffer;
|
return Destination.Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG WINAPI
|
|
||||||
RegCreateKeyA(
|
|
||||||
IN HKEY hKey,
|
|
||||||
IN LPCSTR lpSubKey,
|
|
||||||
OUT PHKEY phkResult)
|
|
||||||
{
|
|
||||||
PWSTR lpSubKeyW;
|
|
||||||
LONG rc;
|
|
||||||
|
|
||||||
lpSubKeyW = MultiByteToWideChar(lpSubKey);
|
|
||||||
if (!lpSubKeyW)
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
|
|
||||||
rc = RegCreateKeyW(hKey, lpSubKeyW, phkResult);
|
|
||||||
free(lpSubKeyW);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
LONG WINAPI
|
LONG WINAPI
|
||||||
RegDeleteKeyW(
|
RegDeleteKeyW(
|
||||||
IN HKEY hKey,
|
IN HKEY hKey,
|
||||||
|
@ -327,7 +299,7 @@ RegpOpenOrCreateValue(
|
||||||
OUT PCM_KEY_VALUE *ValueCell,
|
OUT PCM_KEY_VALUE *ValueCell,
|
||||||
OUT PHCELL_INDEX ValueCellOffset)
|
OUT PHCELL_INDEX ValueCellOffset)
|
||||||
{
|
{
|
||||||
MEMKEY ParentKey;
|
PMEMKEY ParentKey;
|
||||||
UNICODE_STRING ValueString;
|
UNICODE_STRING ValueString;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
@ -364,7 +336,7 @@ RegSetValueExW(
|
||||||
IN const UCHAR* lpData,
|
IN const UCHAR* lpData,
|
||||||
IN USHORT cbData)
|
IN USHORT cbData)
|
||||||
{
|
{
|
||||||
MEMKEY Key, DestKey;
|
PMEMKEY Key, DestKey;
|
||||||
PHKEY phKey;
|
PHKEY phKey;
|
||||||
PCM_KEY_VALUE ValueCell;
|
PCM_KEY_VALUE ValueCell;
|
||||||
HCELL_INDEX ValueCellOffset;
|
HCELL_INDEX ValueCellOffset;
|
||||||
|
@ -381,10 +353,6 @@ RegSetValueExW(
|
||||||
Key = HKEY_TO_MEMKEY(hKey);
|
Key = HKEY_TO_MEMKEY(hKey);
|
||||||
DestKey = HKEY_TO_MEMKEY(*phKey);
|
DestKey = HKEY_TO_MEMKEY(*phKey);
|
||||||
|
|
||||||
/* Create the link in memory */
|
|
||||||
Key->DataType = REG_LINK;
|
|
||||||
Key->LinkedKey = DestKey;
|
|
||||||
|
|
||||||
/* Create the link in registry hive (if applicable) */
|
/* Create the link in registry hive (if applicable) */
|
||||||
if (Key->RegistryHive != DestKey->RegistryHive)
|
if (Key->RegistryHive != DestKey->RegistryHive)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -469,59 +437,6 @@ RegSetValueExW(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG WINAPI
|
|
||||||
RegSetValueExA(
|
|
||||||
IN HKEY hKey,
|
|
||||||
IN LPCSTR lpValueName OPTIONAL,
|
|
||||||
IN ULONG Reserved,
|
|
||||||
IN ULONG dwType,
|
|
||||||
IN const UCHAR* lpData,
|
|
||||||
IN ULONG cbData)
|
|
||||||
{
|
|
||||||
LPWSTR lpValueNameW = NULL;
|
|
||||||
const UCHAR* lpDataW;
|
|
||||||
USHORT cbDataW;
|
|
||||||
LONG rc = ERROR_SUCCESS;
|
|
||||||
|
|
||||||
DPRINT("RegSetValueA(%s)\n", lpValueName);
|
|
||||||
if (lpValueName)
|
|
||||||
{
|
|
||||||
lpValueNameW = MultiByteToWideChar(lpValueName);
|
|
||||||
if (!lpValueNameW)
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((dwType == REG_SZ || dwType == REG_EXPAND_SZ || dwType == REG_MULTI_SZ)
|
|
||||||
&& cbData != 0)
|
|
||||||
{
|
|
||||||
ANSI_STRING AnsiString;
|
|
||||||
UNICODE_STRING Data;
|
|
||||||
|
|
||||||
if (lpData[cbData - 1] != '\0')
|
|
||||||
cbData++;
|
|
||||||
RtlInitAnsiString(&AnsiString, NULL);
|
|
||||||
AnsiString.Buffer = (PSTR)lpData;
|
|
||||||
AnsiString.Length = (USHORT)cbData - 1;
|
|
||||||
AnsiString.MaximumLength = (USHORT)cbData;
|
|
||||||
RtlAnsiStringToUnicodeString (&Data, &AnsiString, TRUE);
|
|
||||||
lpDataW = (const UCHAR*)Data.Buffer;
|
|
||||||
cbDataW = Data.MaximumLength;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lpDataW = lpData;
|
|
||||||
cbDataW = (USHORT)cbData;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc == ERROR_SUCCESS)
|
|
||||||
rc = RegSetValueExW(hKey, lpValueNameW, 0, dwType, lpDataW, cbDataW);
|
|
||||||
if (lpValueNameW)
|
|
||||||
free(lpValueNameW);
|
|
||||||
if (lpData != lpDataW)
|
|
||||||
free((PVOID)lpDataW);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
LONG WINAPI
|
LONG WINAPI
|
||||||
RegQueryValueExW(
|
RegQueryValueExW(
|
||||||
IN HKEY hKey,
|
IN HKEY hKey,
|
||||||
|
@ -551,31 +466,6 @@ RegQueryValueExW(
|
||||||
return ERROR_UNSUCCESSFUL;
|
return ERROR_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG WINAPI
|
|
||||||
RegQueryValueExA(
|
|
||||||
IN HKEY hKey,
|
|
||||||
IN LPCSTR lpValueName,
|
|
||||||
IN PULONG lpReserved,
|
|
||||||
OUT PULONG lpType,
|
|
||||||
OUT PUCHAR lpData,
|
|
||||||
OUT PSIZE_T lpcbData)
|
|
||||||
{
|
|
||||||
LPWSTR lpValueNameW = NULL;
|
|
||||||
LONG rc;
|
|
||||||
|
|
||||||
if (lpValueName)
|
|
||||||
{
|
|
||||||
lpValueNameW = MultiByteToWideChar(lpValueName);
|
|
||||||
if (!lpValueNameW)
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = RegQueryValueExW(hKey, lpValueNameW, lpReserved, lpType, lpData, lpcbData);
|
|
||||||
if (lpValueNameW)
|
|
||||||
free(lpValueNameW);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
LONG WINAPI
|
LONG WINAPI
|
||||||
RegDeleteValueW(
|
RegDeleteValueW(
|
||||||
IN HKEY hKey,
|
IN HKEY hKey,
|
||||||
|
@ -585,27 +475,6 @@ RegDeleteValueW(
|
||||||
return ERROR_UNSUCCESSFUL;
|
return ERROR_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG WINAPI
|
|
||||||
RegDeleteValueA(
|
|
||||||
IN HKEY hKey,
|
|
||||||
IN LPCSTR lpValueName OPTIONAL)
|
|
||||||
{
|
|
||||||
LPWSTR lpValueNameW;
|
|
||||||
LONG rc;
|
|
||||||
|
|
||||||
if (lpValueName)
|
|
||||||
{
|
|
||||||
lpValueNameW = MultiByteToWideChar(lpValueName);
|
|
||||||
if (!lpValueNameW)
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
rc = RegDeleteValueW(hKey, lpValueNameW);
|
|
||||||
free(lpValueNameW);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
rc = RegDeleteValueW(hKey, NULL);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
ConnectRegistry(
|
ConnectRegistry(
|
||||||
IN HKEY RootKey,
|
IN HKEY RootKey,
|
||||||
|
@ -613,7 +482,7 @@ ConnectRegistry(
|
||||||
IN LPCWSTR Path)
|
IN LPCWSTR Path)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
MEMKEY NewKey;
|
PMEMKEY NewKey;
|
||||||
LONG rc;
|
LONG rc;
|
||||||
|
|
||||||
Status = CmiInitializeTempHive(HiveToConnect);
|
Status = CmiInitializeTempHive(HiveToConnect);
|
||||||
|
|
|
@ -6,45 +6,19 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
typedef struct _REG_VALUE
|
typedef struct _MEMKEY
|
||||||
{
|
|
||||||
LIST_ENTRY ValueList;
|
|
||||||
|
|
||||||
/* value name */
|
|
||||||
ULONG NameSize;
|
|
||||||
PCHAR Name;
|
|
||||||
|
|
||||||
/* value data */
|
|
||||||
ULONG DataType;
|
|
||||||
ULONG DataSize;
|
|
||||||
PCHAR Data;
|
|
||||||
} VALUE, *PVALUE;
|
|
||||||
|
|
||||||
typedef struct _REG_KEY
|
|
||||||
{
|
{
|
||||||
LIST_ENTRY KeyList;
|
LIST_ENTRY KeyList;
|
||||||
LIST_ENTRY SubKeyList;
|
LIST_ENTRY SubKeyList;
|
||||||
LIST_ENTRY ValueList;
|
|
||||||
|
|
||||||
ULONG SubKeyCount;
|
|
||||||
ULONG ValueCount;
|
|
||||||
|
|
||||||
/* default data */
|
|
||||||
ULONG DataType;
|
|
||||||
ULONG DataSize;
|
|
||||||
PCHAR Data;
|
|
||||||
|
|
||||||
/* Information on hard disk structure */
|
/* Information on hard disk structure */
|
||||||
HCELL_INDEX KeyCellOffsetInParentHive;
|
HCELL_INDEX KeyCellOffsetInParentHive;
|
||||||
HCELL_INDEX KeyCellOffset;
|
HCELL_INDEX KeyCellOffset;
|
||||||
PCM_KEY_NODE KeyCell;
|
PCM_KEY_NODE KeyCell;
|
||||||
PCMHIVE RegistryHive;
|
PCMHIVE RegistryHive;
|
||||||
|
} MEMKEY, *PMEMKEY;
|
||||||
|
|
||||||
/* Used when linking to another key */
|
#define HKEY_TO_MEMKEY(hKey) ((PMEMKEY)(hKey))
|
||||||
struct _REG_KEY* LinkedKey;
|
|
||||||
} KEY, *FRLDRHKEY, **PFRLDRHKEY, *MEMKEY, **PMEMKEY;
|
|
||||||
|
|
||||||
#define HKEY_TO_MEMKEY(hKey) ((MEMKEY)(hKey))
|
|
||||||
#define MEMKEY_TO_HKEY(memKey) ((HKEY)(memKey))
|
#define MEMKEY_TO_HKEY(memKey) ((HKEY)(memKey))
|
||||||
|
|
||||||
extern CMHIVE DefaultHive; /* \Registry\User\.DEFAULT */
|
extern CMHIVE DefaultHive; /* \Registry\User\.DEFAULT */
|
||||||
|
@ -73,49 +47,6 @@ extern CMHIVE SystemHive; /* \Registry\Machine\SYSTEM */
|
||||||
#define REG_FULL_RESOURCE_DESCRIPTOR 9
|
#define REG_FULL_RESOURCE_DESCRIPTOR 9
|
||||||
#define REG_RESOURCE_REQUIREMENTS_LIST 10
|
#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);
|
|
||||||
|
|
||||||
LONG WINAPI
|
|
||||||
RegQueryValueExA(HKEY Key,
|
|
||||||
LPCSTR ValueName,
|
|
||||||
PULONG Reserved,
|
|
||||||
PULONG Type,
|
|
||||||
PUCHAR Data,
|
|
||||||
PSIZE_T DataSize);
|
|
||||||
|
|
||||||
LONG WINAPI
|
|
||||||
RegSetValueExA(
|
|
||||||
IN HKEY hKey,
|
|
||||||
IN LPCSTR lpValueName OPTIONAL,
|
|
||||||
ULONG Reserved,
|
|
||||||
IN ULONG dwType,
|
|
||||||
IN const UCHAR* lpData,
|
|
||||||
IN ULONG cbData);
|
|
||||||
|
|
||||||
LONG WINAPI
|
|
||||||
RegDeleteValueA(HKEY Key,
|
|
||||||
LPCSTR ValueName);
|
|
||||||
|
|
||||||
LONG WINAPI
|
|
||||||
RegDeleteKeyA(HKEY Key,
|
|
||||||
LPCSTR Name);
|
|
||||||
|
|
||||||
USHORT
|
|
||||||
RegGetSubKeyCount (HKEY Key);
|
|
||||||
|
|
||||||
ULONG
|
|
||||||
RegGetValueCount (HKEY Key);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
RegInitializeRegistry(VOID);
|
RegInitializeRegistry(VOID);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue