mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
Implemented RegSaveKey[A/W]().
Added missing calls to MapDefaultKey(). svn path=/trunk/; revision=2228
This commit is contained in:
parent
63d1ecea6e
commit
0cb3991a23
1 changed files with 112 additions and 29 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: reg.c,v 1.13 2001/09/01 15:36:43 chorns Exp $
|
/* $Id: reg.c,v 1.14 2001/09/03 23:11:59 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
|
||||||
|
@ -771,8 +771,8 @@ RegEnumKeyExA(
|
||||||
|
|
||||||
if ((lpClass) && (!lpcbClass))
|
if ((lpClass) && (!lpcbClass))
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlInitUnicodeString(&UnicodeStringName, NULL);
|
RtlInitUnicodeString(&UnicodeStringName, NULL);
|
||||||
|
@ -882,10 +882,10 @@ RegEnumKeyExW(
|
||||||
if (KeyInfo == NULL)
|
if (KeyInfo == NULL)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
return ERROR_OUTOFMEMORY;
|
return ERROR_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = NtEnumerateKey(
|
Status = NtEnumerateKey(
|
||||||
KeyHandle,
|
KeyHandle,
|
||||||
(ULONG)dwIndex,
|
(ULONG)dwIndex,
|
||||||
KeyNodeInformation,
|
KeyNodeInformation,
|
||||||
|
@ -897,7 +897,7 @@ RegEnumKeyExW(
|
||||||
|
|
||||||
if (Status == STATUS_BUFFER_OVERFLOW)
|
if (Status == STATUS_BUFFER_OVERFLOW)
|
||||||
{
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
|
||||||
BufferSize = ResultSize;
|
BufferSize = ResultSize;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1043,11 +1043,20 @@ RegEnumValueW(
|
||||||
DWORD dwError = ERROR_SUCCESS;
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
ULONG BufferSize;
|
ULONG BufferSize;
|
||||||
ULONG ResultSize;
|
ULONG ResultSize;
|
||||||
|
HANDLE KeyHandle;
|
||||||
|
|
||||||
BufferSize = sizeof (KEY_VALUE_FULL_INFORMATION) +
|
Status = MapDefaultKey(&KeyHandle, hKey);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
dwError = RtlNtStatusToDosError(Status);
|
||||||
|
SetLastError(dwError);
|
||||||
|
return(dwError);
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferSize = sizeof (KEY_VALUE_FULL_INFORMATION) +
|
||||||
*lpcbValueName * sizeof(WCHAR);
|
*lpcbValueName * sizeof(WCHAR);
|
||||||
if (lpcbData)
|
if (lpcbData)
|
||||||
BufferSize += *lpcbData;
|
BufferSize += *lpcbData;
|
||||||
|
|
||||||
/* We don't know the exact size of the data returned, so call
|
/* We don't know the exact size of the data returned, so call
|
||||||
NtEnumerateValueKey() with a buffer size determined from parameters
|
NtEnumerateValueKey() with a buffer size determined from parameters
|
||||||
|
@ -1065,7 +1074,7 @@ RegEnumValueW(
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = NtEnumerateValueKey(
|
Status = NtEnumerateValueKey(
|
||||||
hKey,
|
KeyHandle,
|
||||||
(ULONG)dwIndex,
|
(ULONG)dwIndex,
|
||||||
KeyValueFullInformation,
|
KeyValueFullInformation,
|
||||||
ValueInfo,
|
ValueInfo,
|
||||||
|
@ -1865,10 +1874,19 @@ RegQueryValueExW(
|
||||||
DWORD dwError = ERROR_SUCCESS;
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
ULONG BufferSize;
|
ULONG BufferSize;
|
||||||
ULONG ResultSize;
|
ULONG ResultSize;
|
||||||
|
HANDLE KeyHandle;
|
||||||
|
|
||||||
DPRINT("hKey 0x%X lpValueName %S lpData 0x%X lpcbData %d\n",
|
DPRINT("hKey 0x%X lpValueName %S lpData 0x%X lpcbData %d\n",
|
||||||
hKey, lpValueName, lpData, lpcbData ? *lpcbData : 0);
|
hKey, lpValueName, lpData, lpcbData ? *lpcbData : 0);
|
||||||
|
|
||||||
|
Status = MapDefaultKey(&KeyHandle, hKey);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
dwError = RtlNtStatusToDosError(Status);
|
||||||
|
SetLastError(dwError);
|
||||||
|
return(dwError);
|
||||||
|
}
|
||||||
|
|
||||||
if ((lpData) && (!lpcbData))
|
if ((lpData) && (!lpcbData))
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
@ -2082,34 +2100,99 @@ RegRestoreKeyW(
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* RegSaveKeyA
|
* RegSaveKeyA
|
||||||
*/
|
*/
|
||||||
LONG
|
LONG STDCALL
|
||||||
STDCALL
|
RegSaveKeyA(HKEY hKey,
|
||||||
RegSaveKeyA(
|
LPCSTR lpFile,
|
||||||
HKEY hKey,
|
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||||
LPCSTR lpFile,
|
|
||||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNICODE_STRING FileName;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
LONG ErrorCode;
|
||||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
||||||
|
RtlCreateUnicodeStringFromAsciiz(&FileName,
|
||||||
|
(LPSTR)lpFile);
|
||||||
|
ErrorCode = RegSaveKeyW(hKey,
|
||||||
|
FileName.Buffer,
|
||||||
|
lpSecurityAttributes);
|
||||||
|
RtlFreeUnicodeString(&FileName);
|
||||||
|
|
||||||
|
return(ErrorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* RegSaveKeyW
|
* RegSaveKeyW
|
||||||
*/
|
*/
|
||||||
LONG
|
LONG STDCALL
|
||||||
STDCALL
|
RegSaveKeyW(HKEY hKey,
|
||||||
RegSaveKeyW(
|
LPCWSTR lpFile,
|
||||||
HKEY hKey,
|
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||||
LPCWSTR lpFile,
|
|
||||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
UNICODE_STRING NtName;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
HANDLE FileHandle;
|
||||||
|
HANDLE KeyHandle;
|
||||||
|
NTSTATUS Status;
|
||||||
|
LONG ErrorCode;
|
||||||
|
|
||||||
|
Status = MapDefaultKey(&KeyHandle,
|
||||||
|
hKey);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ErrorCode = RtlNtStatusToDosError(Status);
|
||||||
|
SetLastError(ErrorCode);
|
||||||
|
return(ErrorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RtlDosPathNameToNtPathName_U((LPWSTR)lpFile,
|
||||||
|
&NtName,
|
||||||
|
NULL,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return(ERROR_INVALID_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lpSecurityAttributes != NULL)
|
||||||
|
SecurityDescriptor = lpSecurityAttributes->lpSecurityDescriptor;
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&NtName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
SecurityDescriptor);
|
||||||
|
|
||||||
|
Status = NtCreateFile(&FileHandle,
|
||||||
|
GENERIC_WRITE | SYNCHRONIZE,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&IoStatusBlock,
|
||||||
|
NULL,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
FILE_SHARE_READ,
|
||||||
|
FILE_CREATE,
|
||||||
|
FILE_OPEN_FOR_BACKUP_INTENT | FILE_SYNCHRONOUS_IO_NONALERT,
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
RtlFreeUnicodeString(&NtName);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ErrorCode = RtlNtStatusToDosError(Status);
|
||||||
|
SetLastError(ErrorCode);
|
||||||
|
return(ErrorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtSaveKey(KeyHandle,
|
||||||
|
FileHandle);
|
||||||
|
NtClose(FileHandle);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ErrorCode = RtlNtStatusToDosError(Status);
|
||||||
|
SetLastError(ErrorCode);
|
||||||
|
return(ErrorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(ERROR_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue