mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 08:13:01 +00:00
Fixed some bugs in the registry
Improved registry test app svn path=/trunk/; revision=1343
This commit is contained in:
parent
e7365f8b00
commit
d7d755265d
5 changed files with 238 additions and 105 deletions
|
@ -22,13 +22,14 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
HKEY hKey = NULL;
|
HKEY hKey = NULL;
|
||||||
DWORD dwDisposition;
|
DWORD dwDisposition;
|
||||||
|
DWORD dwError;
|
||||||
|
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
dprintf ("RegCreateKeyExW:\n");
|
dprintf ("RegCreateKeyExW:\n");
|
||||||
RegCreateKeyExW (HKEY_LOCAL_MACHINE,
|
dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
|
||||||
L"Test",
|
L"Test",
|
||||||
0,
|
0,
|
||||||
L"",
|
L"",
|
||||||
|
@ -38,6 +39,61 @@ int main(int argc, char* argv[])
|
||||||
&hKey,
|
&hKey,
|
||||||
&dwDisposition);
|
&dwDisposition);
|
||||||
|
|
||||||
|
dprintf ("dwError %x\n", dwError);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
dprintf ("dwDisposition %x\n", dwDisposition);
|
||||||
|
|
||||||
|
dprintf ("RegSetValueExW:\n");
|
||||||
|
dwError = RegSetValueExW (hKey,
|
||||||
|
L"TestValue",
|
||||||
|
0,
|
||||||
|
REG_SZ,
|
||||||
|
L"TestString",
|
||||||
|
20);
|
||||||
|
|
||||||
|
dprintf ("dwError %x\n", dwError);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
dprintf ("RegCloseKey:\n");
|
||||||
|
dwError = RegCloseKey (hKey);
|
||||||
|
dprintf ("dwError %x\n", dwError);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
dprintf ("\n\n");
|
||||||
|
|
||||||
|
hKey = NULL;
|
||||||
|
|
||||||
|
dprintf ("RegCreateKeyExW:\n");
|
||||||
|
dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
|
||||||
|
L"Test",
|
||||||
|
0,
|
||||||
|
L"",
|
||||||
|
REG_OPTION_VOLATILE,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
&hKey,
|
||||||
|
&dwDisposition);
|
||||||
|
|
||||||
|
dprintf ("dwError %x\n", dwError);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
dprintf ("dwDisposition %x\n", dwDisposition);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
dprintf ("RegQueryKeyExW:\n");
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dprintf ("RegCloseKey:\n");
|
||||||
|
dwError = RegCloseKey (hKey);
|
||||||
|
dprintf ("dwError %x\n", dwError);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
dprintf ("\nTests done...\n");
|
dprintf ("\nTests done...\n");
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ typedef char *PTSTR;
|
||||||
/*
|
/*
|
||||||
typedef PWSTR;
|
typedef PWSTR;
|
||||||
*/
|
*/
|
||||||
typedef PVOID REGSAM;
|
typedef DWORD REGSAM;
|
||||||
|
|
||||||
|
|
||||||
typedef short RETCODE;
|
typedef short RETCODE;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: advapi32.edf,v 1.8 2000/04/06 02:29:43 ekohl Exp $
|
; $Id: advapi32.edf,v 1.9 2000/09/06 19:57:58 ekohl Exp $
|
||||||
;
|
;
|
||||||
; advapi32.def
|
; advapi32.def
|
||||||
;
|
;
|
||||||
|
@ -297,7 +297,7 @@ RegCreateKeyW=RegCreateKeyW@12
|
||||||
RegDeleteKeyA=RegDeleteKeyA@8
|
RegDeleteKeyA=RegDeleteKeyA@8
|
||||||
RegDeleteKeyW=RegDeleteKeyW@8
|
RegDeleteKeyW=RegDeleteKeyW@8
|
||||||
RegDeleteValueA=RegDeleteValueA@8
|
RegDeleteValueA=RegDeleteValueA@8
|
||||||
;RegDeleteValueW=RegDeleteValueW@8
|
RegDeleteValueW=RegDeleteValueW@8
|
||||||
RegEnumKeyA=RegEnumKeyA@16
|
RegEnumKeyA=RegEnumKeyA@16
|
||||||
RegEnumKeyExA=RegEnumKeyExA@32
|
RegEnumKeyExA=RegEnumKeyExA@32
|
||||||
;RegEnumKeyExW=RegEnumKeyExW@32
|
;RegEnumKeyExW=RegEnumKeyExW@32
|
||||||
|
@ -330,8 +330,8 @@ RegSaveKeyA=RegSaveKeyA@12
|
||||||
;RegSetKeySecurity=RegSetKeySecurity@12
|
;RegSetKeySecurity=RegSetKeySecurity@12
|
||||||
RegSetValueA=RegSetValueA@20
|
RegSetValueA=RegSetValueA@20
|
||||||
RegSetValueExA=RegSetValueExA@24
|
RegSetValueExA=RegSetValueExA@24
|
||||||
;RegSetValueExW=RegSetValueExW@24
|
RegSetValueExW=RegSetValueExW@24
|
||||||
;RegSetValueW=RegSetValueW@20
|
RegSetValueW=RegSetValueW@20
|
||||||
RegUnLoadKeyA=RegUnLoadKeyA@8
|
RegUnLoadKeyA=RegUnLoadKeyA@8
|
||||||
;RegUnLoadKeyW=RegUnLoadKeyW@8
|
;RegUnLoadKeyW=RegUnLoadKeyW@8
|
||||||
;RegisterEventSourceA=RegisterEventSourceA@8
|
;RegisterEventSourceA=RegisterEventSourceA@8
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: reg.c,v 1.8 2000/09/05 23:00:27 ekohl Exp $
|
/* $Id: reg.c,v 1.9 2000/09/06 19:58:47 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -28,7 +28,7 @@ static HANDLE DefaultHandleTable[MAX_DEFAULT_HANDLES];
|
||||||
/* PROTOTYPES ****************************************************************/
|
/* PROTOTYPES ****************************************************************/
|
||||||
|
|
||||||
static NTSTATUS MapDefaultKey (PHKEY ParentKey, HKEY Key);
|
static NTSTATUS MapDefaultKey (PHKEY ParentKey, HKEY Key);
|
||||||
static VOID CloseDefaultHandles(VOID);
|
static VOID CloseDefaultKeys(VOID);
|
||||||
|
|
||||||
static NTSTATUS OpenLocalMachineKey (PHANDLE KeyHandle);
|
static NTSTATUS OpenLocalMachineKey (PHANDLE KeyHandle);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ RegCleanup(VOID)
|
||||||
{
|
{
|
||||||
DPRINT1("RegCleanup()\n");
|
DPRINT1("RegCleanup()\n");
|
||||||
|
|
||||||
CloseDefaultHandles();
|
CloseDefaultKeys();
|
||||||
RtlDeleteCriticalSection(&HandleTableCS);
|
RtlDeleteCriticalSection(&HandleTableCS);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ DPRINT1("Status %x\n", Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static VOID CloseDefaultHandles(VOID)
|
static VOID CloseDefaultKeys (VOID)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ static VOID CloseDefaultHandles(VOID)
|
||||||
{
|
{
|
||||||
if (DefaultHandleTable[i] != NULL)
|
if (DefaultHandleTable[i] != NULL)
|
||||||
{
|
{
|
||||||
// NtClose (DefaultHandleTable[i]);
|
NtClose (DefaultHandleTable[i]);
|
||||||
DefaultHandleTable[i] = NULL;
|
DefaultHandleTable[i] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,9 @@ OpenLocalMachineKey (PHANDLE KeyHandle)
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return (NtOpenKey (KeyHandle, 0x200000, &Attributes));
|
return (NtOpenKey (KeyHandle,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
&Attributes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,11 +171,22 @@ RegCloseKey(
|
||||||
HKEY hKey
|
HKEY hKey
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!hKey)
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* don't close null handle or a pseudo handle */
|
||||||
|
if ((!hKey) || (((ULONG)hKey & 0xF0000000) == 0x80000000))
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
|
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
Status = NtClose (hKey);
|
||||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
LONG ErrorCode = RtlNtStatusToDosError(Status);
|
||||||
|
|
||||||
|
SetLastError (ErrorCode);
|
||||||
|
return ErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -290,8 +303,10 @@ RegCreateKeyExW(
|
||||||
Status = MapDefaultKey (&ParentKey, hKey);
|
Status = MapDefaultKey (&ParentKey, hKey);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastError (RtlNtStatusToDosError(Status));
|
LONG ErrorCode = RtlNtStatusToDosError(Status);
|
||||||
return (RtlNtStatusToDosError(Status));
|
|
||||||
|
SetLastError (ErrorCode);
|
||||||
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("ParentKey %x\n", (ULONG)ParentKey);
|
DPRINT1("ParentKey %x\n", (ULONG)ParentKey);
|
||||||
|
@ -315,8 +330,10 @@ RegCreateKeyExW(
|
||||||
DPRINT1("Status %x\n", Status);
|
DPRINT1("Status %x\n", Status);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastError (RtlNtStatusToDosError(Status));
|
LONG ErrorCode = RtlNtStatusToDosError(Status);
|
||||||
return (RtlNtStatusToDosError(Status));
|
|
||||||
|
SetLastError (ErrorCode);
|
||||||
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
DPRINT1("Returned handle %x\n", (ULONG)*phkResult);
|
DPRINT1("Returned handle %x\n", (ULONG)*phkResult);
|
||||||
|
|
||||||
|
@ -369,6 +386,21 @@ RegDeleteValueA(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* RegDeleteValueW
|
||||||
|
*/
|
||||||
|
LONG
|
||||||
|
STDCALL
|
||||||
|
RegDeleteValueW(
|
||||||
|
HKEY hKey,
|
||||||
|
LPCWSTR lpValueName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* RegEnumKeyA
|
* RegEnumKeyA
|
||||||
*/
|
*/
|
||||||
|
@ -831,6 +863,62 @@ RegSetValueExA(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* RegSetValueExW
|
||||||
|
*/
|
||||||
|
LONG
|
||||||
|
STDCALL
|
||||||
|
RegSetValueExW(
|
||||||
|
HKEY hKey,
|
||||||
|
LPCWSTR lpValueName,
|
||||||
|
DWORD Reserved,
|
||||||
|
DWORD dwType,
|
||||||
|
CONST BYTE *lpData,
|
||||||
|
DWORD cbData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UNICODE_STRING ValueName;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
RtlInitUnicodeString (&ValueName,
|
||||||
|
lpValueName);
|
||||||
|
|
||||||
|
Status = NtSetValueKey (hKey,
|
||||||
|
&ValueName,
|
||||||
|
0,
|
||||||
|
dwType,
|
||||||
|
(PVOID)lpData,
|
||||||
|
(ULONG)cbData);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
LONG ErrorCode = RtlNtStatusToDosError(Status);
|
||||||
|
|
||||||
|
SetLastError (ErrorCode);
|
||||||
|
return ErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* RegSetValueW
|
||||||
|
*/
|
||||||
|
LONG
|
||||||
|
STDCALL
|
||||||
|
RegSetValueW(
|
||||||
|
HKEY hKey,
|
||||||
|
LPCWSTR lpSubKey,
|
||||||
|
DWORD dwType,
|
||||||
|
LPCWSTR lpData,
|
||||||
|
DWORD cbData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* RegUnLoadKeyA
|
* RegUnLoadKeyA
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: registry.c,v 1.27 2000/09/05 23:03:09 ekohl Exp $
|
/* $Id: registry.c,v 1.28 2000/09/06 19:59:54 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -408,7 +408,6 @@ NtCreateKey (
|
||||||
Status = CmiBuildKeyPath(&KeyNameBuf, ObjectAttributes);
|
Status = CmiBuildKeyPath(&KeyNameBuf, ObjectAttributes);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
CHECKPOINT1;
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,8 +428,11 @@ CHECKPOINT1;
|
||||||
FALSE,
|
FALSE,
|
||||||
KeyHandle);
|
KeyHandle);
|
||||||
ExFreePool(KeyNameBuf);
|
ExFreePool(KeyNameBuf);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
CHECKPOINT1;
|
{
|
||||||
|
*Disposition = REG_OPENED_EXISTING_KEY;
|
||||||
|
}
|
||||||
|
DPRINT1("KeyHandle (opened) %x\n", *KeyHandle);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +449,6 @@ CHECKPOINT1;
|
||||||
{
|
{
|
||||||
ExFreePool(KeyNameBuf);
|
ExFreePool(KeyNameBuf);
|
||||||
|
|
||||||
CHECKPOINT1;
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,7 +459,6 @@ CHECKPOINT1;
|
||||||
CmiKeyType);
|
CmiKeyType);
|
||||||
if (NewKey == NULL)
|
if (NewKey == NULL)
|
||||||
{
|
{
|
||||||
CHECKPOINT1;
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
NewKey->Flags = 0;
|
NewKey->Flags = 0;
|
||||||
|
@ -467,12 +467,17 @@ CHECKPOINT1;
|
||||||
NewKey->RegistryFile = FileToUse;
|
NewKey->RegistryFile = FileToUse;
|
||||||
CmiAddKeyToList(NewKey);
|
CmiAddKeyToList(NewKey);
|
||||||
Status = ObCreateHandle(PsGetCurrentProcess(),
|
Status = ObCreateHandle(PsGetCurrentProcess(),
|
||||||
CurKey,
|
NewKey,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
FALSE,
|
FALSE,
|
||||||
KeyHandle);
|
KeyHandle);
|
||||||
|
|
||||||
CHECKPOINT1;
|
DPRINT1("Status %x KeyHandle (created) %x\n", Status, *KeyHandle);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
*Disposition = REG_CREATED_NEW_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
#else
|
#else
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
@ -745,11 +750,12 @@ NtOpenKey (
|
||||||
KeyHandle);
|
KeyHandle);
|
||||||
ExFreePool(KeyNameBuf);
|
ExFreePool(KeyNameBuf);
|
||||||
|
|
||||||
|
DPRINT1("Status %x KeyHandle (opened) %x\n", Status, *KeyHandle);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the key in the registry file */
|
/* Open the key in the registry file */
|
||||||
CHECKPOINT1;
|
|
||||||
FileToUse = CmiSystemFile;
|
FileToUse = CmiSystemFile;
|
||||||
Status = CmiFindKey(FileToUse,
|
Status = CmiFindKey(FileToUse,
|
||||||
KeyNameBuf,
|
KeyNameBuf,
|
||||||
|
@ -757,10 +763,8 @@ CHECKPOINT1;
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
0,
|
0,
|
||||||
NULL);
|
NULL);
|
||||||
CHECKPOINT1;
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
CHECKPOINT1;
|
|
||||||
FileToUse = CmiVolatileFile;
|
FileToUse = CmiVolatileFile;
|
||||||
Status = CmiFindKey(FileToUse,
|
Status = CmiFindKey(FileToUse,
|
||||||
KeyNameBuf,
|
KeyNameBuf,
|
||||||
|
@ -768,16 +772,13 @@ CHECKPOINT1;
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
0,
|
0,
|
||||||
NULL);
|
NULL);
|
||||||
CHECKPOINT1;
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
CHECKPOINT1;
|
|
||||||
ExFreePool(KeyNameBuf);
|
ExFreePool(KeyNameBuf);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CHECKPOINT1;
|
|
||||||
|
|
||||||
/* Create new key object and put into linked list */
|
/* Create new key object and put into linked list */
|
||||||
NewKey = ObCreateObject(KeyHandle,
|
NewKey = ObCreateObject(KeyHandle,
|
||||||
|
@ -793,12 +794,15 @@ CHECKPOINT1;
|
||||||
NewKey->RegistryFile = FileToUse;
|
NewKey->RegistryFile = FileToUse;
|
||||||
NewKey->KeyBlock = KeyBlock;
|
NewKey->KeyBlock = KeyBlock;
|
||||||
CmiAddKeyToList(NewKey);
|
CmiAddKeyToList(NewKey);
|
||||||
|
DPRINT1("KeyHandle (created) %x\n", *KeyHandle);
|
||||||
|
|
||||||
Status = ObCreateHandle(PsGetCurrentProcess(),
|
Status = ObCreateHandle(PsGetCurrentProcess(),
|
||||||
CurKey,
|
NewKey,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
FALSE,
|
FALSE,
|
||||||
KeyHandle);
|
KeyHandle);
|
||||||
|
|
||||||
|
DPRINT1("Status %x KeyHandle (created) %x\n", Status, *KeyHandle);
|
||||||
return Status;
|
return Status;
|
||||||
#else
|
#else
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
@ -1097,7 +1101,7 @@ NtSetValueKey (
|
||||||
|
|
||||||
/* 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_QUERY_VALUE,
|
KEY_SET_VALUE,
|
||||||
CmiKeyType,
|
CmiKeyType,
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID *)&KeyObject,
|
(PVOID *)&KeyObject,
|
||||||
|
@ -1106,7 +1110,6 @@ NtSetValueKey (
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get pointer to KeyBlock */
|
/* Get pointer to KeyBlock */
|
||||||
KeyBlock = KeyObject->KeyBlock;
|
KeyBlock = KeyObject->KeyBlock;
|
||||||
RegistryFile = KeyObject->RegistryFile;
|
RegistryFile = KeyObject->RegistryFile;
|
||||||
|
@ -1116,6 +1119,7 @@ NtSetValueKey (
|
||||||
&ValueBlock);
|
&ValueBlock);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
ObDereferenceObject (KeyObject);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
if (ValueBlock == NULL)
|
if (ValueBlock == NULL)
|
||||||
|
@ -1135,6 +1139,7 @@ NtSetValueKey (
|
||||||
Data,
|
Data,
|
||||||
DataSize);
|
DataSize);
|
||||||
}
|
}
|
||||||
|
ObDereferenceObject (KeyObject);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
#else
|
#else
|
||||||
|
@ -1515,7 +1520,7 @@ DbgPrint ("KeyName %wZ\n", ObjectAttributes->ObjectName);
|
||||||
Status = ObReferenceObjectByHandle(ObjectAttributes->RootDirectory,
|
Status = ObReferenceObjectByHandle(ObjectAttributes->RootDirectory,
|
||||||
KEY_READ,
|
KEY_READ,
|
||||||
NULL,
|
NULL,
|
||||||
UserMode,
|
KernelMode,
|
||||||
(PVOID *)&ObjectBody,
|
(PVOID *)&ObjectBody,
|
||||||
NULL);
|
NULL);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -1760,13 +1765,11 @@ CmiCreateKey(IN PREGISTRY_FILE RegistryFile,
|
||||||
|
|
||||||
/* FIXME: Should handle search by Class/TitleIndex */
|
/* FIXME: Should handle search by Class/TitleIndex */
|
||||||
|
|
||||||
CHECKPOINT;
|
|
||||||
/* Loop through each key level and find or build the needed subkey */
|
/* Loop through each key level and find or build the needed subkey */
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
/* FIXME: this access of RootKeyBlock should be guarded by spinlock */
|
/* FIXME: this access of RootKeyBlock should be guarded by spinlock */
|
||||||
CurKeyBlock = CmiGetKeyBlock(RegistryFile,
|
CurKeyBlock = CmiGetKeyBlock(RegistryFile,
|
||||||
RegistryFile->HeaderBlock->RootKeyBlock);
|
RegistryFile->HeaderBlock->RootKeyBlock);
|
||||||
CHECKPOINT;
|
|
||||||
Remainder = KeyNameBuf;
|
Remainder = KeyNameBuf;
|
||||||
while (NT_SUCCESS(Status) &&
|
while (NT_SUCCESS(Status) &&
|
||||||
(NextSlash = wcschr(Remainder, L'\\')) != NULL)
|
(NextSlash = wcschr(Remainder, L'\\')) != NULL)
|
||||||
|
@ -1867,12 +1870,8 @@ CmiFindKey(IN PREGISTRY_FILE RegistryFile,
|
||||||
PWSTR Remainder, NextSlash;
|
PWSTR Remainder, NextSlash;
|
||||||
PKEY_BLOCK CurKeyBlock, SubKeyBlock;
|
PKEY_BLOCK CurKeyBlock, SubKeyBlock;
|
||||||
|
|
||||||
DbgPrint("KeyNameBuf %S\n", KeyNameBuf);
|
|
||||||
|
|
||||||
CHECKPOINT1;
|
|
||||||
if (RegistryFile == NULL)
|
if (RegistryFile == NULL)
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
CHECKPOINT1;
|
|
||||||
|
|
||||||
/* FIXME: Should handle search by Class/TitleIndex */
|
/* FIXME: Should handle search by Class/TitleIndex */
|
||||||
|
|
||||||
|
@ -1888,7 +1887,6 @@ CHECKPOINT1;
|
||||||
/* Copy just the current subkey name to a buffer */
|
/* Copy just the current subkey name to a buffer */
|
||||||
wcsncpy(CurKeyName, Remainder, NextSlash - Remainder);
|
wcsncpy(CurKeyName, Remainder, NextSlash - Remainder);
|
||||||
CurKeyName[NextSlash - Remainder] = 0;
|
CurKeyName[NextSlash - Remainder] = 0;
|
||||||
DbgPrint("CurKeyName %S\n", CurKeyName);
|
|
||||||
|
|
||||||
/* Verify existance of CurKeyName */
|
/* Verify existance of CurKeyName */
|
||||||
Status = CmiScanForSubKey(RegistryFile,
|
Status = CmiScanForSubKey(RegistryFile,
|
||||||
|
@ -1902,7 +1900,6 @@ DbgPrint("CurKeyName %S\n", CurKeyName);
|
||||||
}
|
}
|
||||||
if (SubKeyBlock == NULL)
|
if (SubKeyBlock == NULL)
|
||||||
{
|
{
|
||||||
CHECKPOINT1;
|
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1913,7 +1910,6 @@ CHECKPOINT1;
|
||||||
}
|
}
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint("CurKeyName %S\n", CurKeyName);
|
|
||||||
Status = CmiScanForSubKey(RegistryFile,
|
Status = CmiScanForSubKey(RegistryFile,
|
||||||
CurKeyBlock,
|
CurKeyBlock,
|
||||||
&SubKeyBlock,
|
&SubKeyBlock,
|
||||||
|
@ -1923,7 +1919,6 @@ DbgPrint("CurKeyName %S\n", CurKeyName);
|
||||||
{
|
{
|
||||||
if (SubKeyBlock == NULL)
|
if (SubKeyBlock == NULL)
|
||||||
{
|
{
|
||||||
CHECKPOINT1;
|
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1933,7 +1928,6 @@ CHECKPOINT1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CmiReleaseBlock(RegistryFile, CurKeyBlock);
|
CmiReleaseBlock(RegistryFile, CurKeyBlock);
|
||||||
CHECKPOINT1;
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -2079,27 +2073,21 @@ CmiScanForSubKey(IN PREGISTRY_FILE RegistryFile,
|
||||||
PHASH_TABLE_BLOCK HashBlock;
|
PHASH_TABLE_BLOCK HashBlock;
|
||||||
PKEY_BLOCK CurSubKeyBlock;
|
PKEY_BLOCK CurSubKeyBlock;
|
||||||
|
|
||||||
CHECKPOINT1;
|
|
||||||
HashBlock = CmiGetHashTableBlock(RegistryFile, KeyBlock->HashTableOffset);
|
HashBlock = CmiGetHashTableBlock(RegistryFile, KeyBlock->HashTableOffset);
|
||||||
*SubKeyBlock = NULL;
|
*SubKeyBlock = NULL;
|
||||||
if (HashBlock == 0)
|
if (HashBlock == 0)
|
||||||
{
|
{
|
||||||
CHECKPOINT1;
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
CHECKPOINT1;
|
|
||||||
for (Idx = 0; Idx < HashBlock->HashTableSize; Idx++)
|
for (Idx = 0; Idx < HashBlock->HashTableSize; Idx++)
|
||||||
{
|
{
|
||||||
DbgPrint ("KeyName %S HashValue %x\n", KeyName, HashBlock->Table[Idx].HashValue);
|
|
||||||
if (HashBlock->Table[Idx].KeyOffset != 0 &&
|
if (HashBlock->Table[Idx].KeyOffset != 0 &&
|
||||||
!wcsncmp(KeyName, (PWSTR) &HashBlock->Table[Idx].HashValue, 2))
|
!wcsncmp(KeyName, (PWSTR) &HashBlock->Table[Idx].HashValue, 2))
|
||||||
// !wcsncmp(KeyName, (PWSTR) &HashBlock->Table[Idx].HashValue, 4))
|
|
||||||
{
|
{
|
||||||
CurSubKeyBlock = CmiGetKeyBlock(RegistryFile,
|
CurSubKeyBlock = CmiGetKeyBlock(RegistryFile,
|
||||||
HashBlock->Table[Idx].KeyOffset);
|
HashBlock->Table[Idx].KeyOffset);
|
||||||
if (!wcscmp(KeyName, CurSubKeyBlock->Name))
|
if (!wcscmp(KeyName, CurSubKeyBlock->Name))
|
||||||
{
|
{
|
||||||
CHECKPOINT1;
|
|
||||||
*SubKeyBlock = CurSubKeyBlock;
|
*SubKeyBlock = CurSubKeyBlock;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2283,8 +2271,8 @@ CmiAddValueToKey(IN PREGISTRY_FILE RegistryFile,
|
||||||
ValueListBlock->Values[KeyBlock->NumberOfValues] =
|
ValueListBlock->Values[KeyBlock->NumberOfValues] =
|
||||||
CmiGetBlockOffset(RegistryFile, ValueBlock);
|
CmiGetBlockOffset(RegistryFile, ValueBlock);
|
||||||
KeyBlock->NumberOfValues++;
|
KeyBlock->NumberOfValues++;
|
||||||
CmiReleaseBlock(RegistryFile, ValueBlock);
|
|
||||||
CmiReleaseBlock(RegistryFile, ValueListBlock);
|
CmiReleaseBlock(RegistryFile, ValueListBlock);
|
||||||
|
CmiReleaseBlock(RegistryFile, ValueBlock);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2579,7 +2567,7 @@ CmiAllocateValueBlock(PREGISTRY_FILE RegistryFile,
|
||||||
/* Handle volatile files first */
|
/* Handle volatile files first */
|
||||||
if (RegistryFile->Filename == NULL)
|
if (RegistryFile->Filename == NULL)
|
||||||
{
|
{
|
||||||
NewValueSize = sizeof(VALUE_BLOCK) + wcslen(ValueNameBuf);
|
NewValueSize = sizeof(VALUE_BLOCK) + wcslen(ValueNameBuf)* sizeof(WCHAR);
|
||||||
NewValueBlock = ExAllocatePool(NonPagedPool, NewValueSize);
|
NewValueBlock = ExAllocatePool(NonPagedPool, NewValueSize);
|
||||||
if (NewValueBlock == NULL)
|
if (NewValueBlock == NULL)
|
||||||
{
|
{
|
||||||
|
@ -2664,6 +2652,7 @@ CmiDestroyValueBlock(PREGISTRY_FILE RegistryFile,
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
CHECKPOINT1;
|
||||||
Status = CmiDestroyBlock(RegistryFile,
|
Status = CmiDestroyBlock(RegistryFile,
|
||||||
CmiGetBlock(RegistryFile,
|
CmiGetBlock(RegistryFile,
|
||||||
ValueBlock->DataOffset));
|
ValueBlock->DataOffset));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue