mirror of
https://github.com/reactos/reactos.git
synced 2025-05-01 03:29:37 +00:00
Fix formatting. No code changes!
svn path=/trunk/; revision=37598
This commit is contained in:
parent
a1afe48a57
commit
4abc5d743f
1 changed files with 2097 additions and 2004 deletions
|
@ -207,6 +207,7 @@ CloseDefaultKeys (VOID)
|
|||
ULONG i;
|
||||
|
||||
RtlEnterCriticalSection(&HandleTableCS);
|
||||
|
||||
for (i = 0; i < MAX_DEFAULT_HANDLES; i++)
|
||||
{
|
||||
if (DefaultHandleTable[i] != NULL)
|
||||
|
@ -215,6 +216,7 @@ CloseDefaultKeys (VOID)
|
|||
DefaultHandleTable[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
RtlLeaveCriticalSection(&HandleTableCS);
|
||||
}
|
||||
|
||||
|
@ -257,6 +259,7 @@ OpenLocalMachineKey (PHANDLE KeyHandle)
|
|||
&Attributes);
|
||||
|
||||
TRACE("NtOpenKey(%wZ) => %08x\n", &KeyName, Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -847,17 +850,20 @@ RegConnectRegistryW (LPCWSTR lpMachineName,
|
|||
|
||||
TRACE("(%s,%p,%p): stub\n",debugstr_w(lpMachineName),hKey,phkResult);
|
||||
|
||||
if (!lpMachineName || !*lpMachineName) {
|
||||
if (!lpMachineName || !*lpMachineName)
|
||||
{
|
||||
/* Use the local machine name */
|
||||
ret = RegOpenKeyW( hKey, NULL, phkResult );
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
WCHAR compName[MAX_COMPUTERNAME_LENGTH + 1];
|
||||
DWORD len = sizeof(compName) / sizeof(WCHAR);
|
||||
|
||||
/* MSDN says lpMachineName must start with \\ : not so */
|
||||
if( lpMachineName[0] == '\\' && lpMachineName[1] == '\\')
|
||||
lpMachineName += 2;
|
||||
|
||||
if (GetComputerNameW(compName, &len))
|
||||
{
|
||||
if (!_wcsicmp(lpMachineName, compName))
|
||||
|
@ -871,6 +877,7 @@ RegConnectRegistryW (LPCWSTR lpMachineName,
|
|||
else
|
||||
ret = GetLastError();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -928,6 +935,7 @@ CreateNestedKey(PHKEY KeyHandle,
|
|||
Status = STATUS_UNSUCCESSFUL;
|
||||
break;
|
||||
}
|
||||
|
||||
*Ptr = (WCHAR)0;
|
||||
LocalKeyName.Length = wcslen(LocalKeyName.Buffer) * sizeof(WCHAR);
|
||||
|
||||
|
@ -969,6 +977,7 @@ CreateNestedKey(PHKEY KeyHandle,
|
|||
(PULONG)lpdwDisposition);
|
||||
break;
|
||||
}
|
||||
|
||||
Status = NtCreateKey(&LocalKeyHandle,
|
||||
KEY_CREATE_SUB_KEY,
|
||||
&LocalObjectAttributes,
|
||||
|
@ -1021,6 +1030,7 @@ RegCreateKeyExA (HKEY hKey,
|
|||
{
|
||||
return RtlNtStatusToDosError(Status);
|
||||
}
|
||||
|
||||
TRACE("ParentKey %x\n", (ULONG)ParentKey);
|
||||
|
||||
if (lpClass != NULL)
|
||||
|
@ -1094,6 +1104,7 @@ RegCreateKeyExW (HKEY hKey,
|
|||
{
|
||||
return RtlNtStatusToDosError(Status);
|
||||
}
|
||||
|
||||
TRACE("ParentKey %x\n", (ULONG)ParentKey);
|
||||
|
||||
RtlInitUnicodeString(&ClassString,
|
||||
|
@ -1287,6 +1298,7 @@ Cleanup:
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegDeleteKeyExA
|
||||
*
|
||||
|
@ -1297,13 +1309,13 @@ WINAPI
|
|||
RegDeleteKeyExA(HKEY hKey,
|
||||
LPCSTR lpSubKey,
|
||||
REGSAM samDesired,
|
||||
DWORD Reserved
|
||||
)
|
||||
DWORD Reserved)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegDeleteKeyExW
|
||||
*
|
||||
|
@ -1314,13 +1326,13 @@ WINAPI
|
|||
RegDeleteKeyExW(HKEY hKey,
|
||||
LPCWSTR lpSubKey,
|
||||
REGSAM samDesired,
|
||||
DWORD Reserved
|
||||
)
|
||||
DWORD Reserved)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegDeleteKeyValueW
|
||||
*
|
||||
|
@ -1711,6 +1723,7 @@ Cleanup:
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegDeleteTreeW
|
||||
*
|
||||
|
@ -1718,7 +1731,8 @@ Cleanup:
|
|||
*/
|
||||
LSTATUS
|
||||
WINAPI
|
||||
RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
|
||||
RegDeleteTreeW(HKEY hKey,
|
||||
LPCWSTR lpszSubKey)
|
||||
{
|
||||
LONG ret;
|
||||
DWORD dwMaxSubkeyLen, dwMaxValueLen;
|
||||
|
@ -1858,13 +1872,16 @@ RegEnableReflectionKey(IN HKEY hBase)
|
|||
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* RegpApplyRestrictions [internal]
|
||||
*
|
||||
* Helper function for RegGetValueA/W.
|
||||
*/
|
||||
static VOID
|
||||
RegpApplyRestrictions( DWORD dwFlags, DWORD dwType, DWORD cbData,
|
||||
RegpApplyRestrictions(DWORD dwFlags,
|
||||
DWORD dwType,
|
||||
DWORD cbData,
|
||||
PLONG ret)
|
||||
{
|
||||
/* Check if the type is restricted by the passed flags */
|
||||
|
@ -1933,8 +1950,13 @@ RegpApplyRestrictions( DWORD dwFlags, DWORD dwType, DWORD cbData,
|
|||
* An exception is the case where RRF_RT_ANY is specified, because then
|
||||
* RRF_NOEXPAND is allowed.
|
||||
*/
|
||||
LSTATUS WINAPI RegGetValueW( HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue,
|
||||
DWORD dwFlags, LPDWORD pdwType, PVOID pvData,
|
||||
LSTATUS WINAPI
|
||||
RegGetValueW(HKEY hKey,
|
||||
LPCWSTR pszSubKey,
|
||||
LPCWSTR pszValue,
|
||||
DWORD dwFlags,
|
||||
LPDWORD pdwType,
|
||||
PVOID pvData,
|
||||
LPDWORD pcbData)
|
||||
{
|
||||
DWORD dwType, cbData = pcbData ? *pcbData : 0;
|
||||
|
@ -1965,7 +1987,8 @@ LSTATUS WINAPI RegGetValueW( HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue,
|
|||
if ((ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) &&
|
||||
dwType == REG_EXPAND_SZ && !(dwFlags & RRF_NOEXPAND))
|
||||
{
|
||||
do {
|
||||
do
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, pvBuf);
|
||||
|
||||
pvBuf = HeapAlloc(GetProcessHeap(), 0, cbData);
|
||||
|
@ -1989,7 +2012,8 @@ LSTATUS WINAPI RegGetValueW( HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue,
|
|||
/* Both the type or the value itself could have been modified in
|
||||
* between so we have to keep retrying until the buffer is large
|
||||
* enough or we no longer have to expand the value. */
|
||||
} while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA);
|
||||
}
|
||||
while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA);
|
||||
|
||||
if (ret == ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -2017,8 +2041,11 @@ LSTATUS WINAPI RegGetValueW( HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue,
|
|||
if (pvData && ret != ERROR_SUCCESS && (dwFlags & RRF_ZEROONFAILURE))
|
||||
ZeroMemory(pvData, *pcbData);
|
||||
|
||||
if (pdwType) *pdwType = dwType;
|
||||
if (pcbData) *pcbData = cbData;
|
||||
if (pdwType)
|
||||
*pdwType = dwType;
|
||||
|
||||
if (pcbData)
|
||||
*pcbData = cbData;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -2029,8 +2056,13 @@ LSTATUS WINAPI RegGetValueW( HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue,
|
|||
*
|
||||
* See RegGetValueW.
|
||||
*/
|
||||
LSTATUS WINAPI RegGetValueA( HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue,
|
||||
DWORD dwFlags, LPDWORD pdwType, PVOID pvData,
|
||||
LSTATUS WINAPI
|
||||
RegGetValueA(HKEY hKey,
|
||||
LPCSTR pszSubKey,
|
||||
LPCSTR pszValue,
|
||||
DWORD dwFlags,
|
||||
LPDWORD pdwType,
|
||||
PVOID pvData,
|
||||
LPDWORD pcbData)
|
||||
{
|
||||
DWORD dwType, cbData = pcbData ? *pcbData : 0;
|
||||
|
@ -2710,14 +2742,21 @@ Cleanup:
|
|||
return ErrorCode;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegEnumValueA
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
LONG STDCALL
|
||||
RegEnumValueA( HKEY hKey, DWORD index, LPSTR value, LPDWORD val_count,
|
||||
LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count )
|
||||
RegEnumValueA(HKEY hKey,
|
||||
DWORD index,
|
||||
LPSTR value,
|
||||
LPDWORD val_count,
|
||||
LPDWORD reserved,
|
||||
LPDWORD type,
|
||||
LPBYTE data,
|
||||
LPDWORD count)
|
||||
{
|
||||
HANDLE KeyHandle;
|
||||
NTSTATUS status;
|
||||
|
@ -2730,7 +2769,9 @@ RegEnumValueA( HKEY hKey, DWORD index, LPSTR value, LPDWORD val_count,
|
|||
// hkey, index, value, val_count, reserved, type, data, count );
|
||||
|
||||
/* NT only checks count, not val_count */
|
||||
if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
|
||||
if ((data && !count) || reserved)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
status = MapDefaultKey(&KeyHandle, hKey);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
|
@ -2824,6 +2865,7 @@ RegEnumValueA( HKEY hKey, DWORD index, LPSTR value, LPDWORD val_count,
|
|||
return RtlNtStatusToDosError(status);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* RegEnumValueW [ADVAPI32.@]
|
||||
* @implemented
|
||||
|
@ -2843,8 +2885,14 @@ RegEnumValueA( HKEY hKey, DWORD index, LPSTR value, LPDWORD val_count,
|
|||
* Failure: nonzero error code from Winerror.h
|
||||
*/
|
||||
LONG STDCALL
|
||||
RegEnumValueW( HKEY hKey, DWORD index, LPWSTR value, PDWORD val_count,
|
||||
PDWORD reserved, PDWORD type, LPBYTE data, PDWORD count )
|
||||
RegEnumValueW(HKEY hKey,
|
||||
DWORD index,
|
||||
LPWSTR value,
|
||||
PDWORD val_count,
|
||||
PDWORD reserved,
|
||||
PDWORD type,
|
||||
LPBYTE data,
|
||||
PDWORD count)
|
||||
{
|
||||
HANDLE KeyHandle;
|
||||
NTSTATUS status;
|
||||
|
@ -2932,6 +2980,7 @@ RegEnumValueW( HKEY hKey, DWORD index, LPWSTR value, PDWORD val_count,
|
|||
return RtlNtStatusToDosError(status);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegFlushKey
|
||||
*
|
||||
|
@ -2994,6 +3043,7 @@ RegGetKeySecurity(HKEY hKey,
|
|||
TRACE("MapDefaultKey() failed (Status %lx)\n", Status);
|
||||
return RtlNtStatusToDosError(Status);
|
||||
}
|
||||
|
||||
#if 0
|
||||
Status = NtQuerySecurityObject(KeyHandle,
|
||||
SecurityInformation,
|
||||
|
@ -3210,7 +3260,8 @@ RegOpenKeyA (HKEY hKey,
|
|||
LPCSTR lpSubKey,
|
||||
PHKEY phkResult)
|
||||
{
|
||||
TRACE("RegOpenKeyA hKey 0x%x lpSubKey %s phkResult %p\n", hKey, lpSubKey, phkResult);
|
||||
TRACE("RegOpenKeyA hKey 0x%x lpSubKey %s phkResult %p\n",
|
||||
hKey, lpSubKey, phkResult);
|
||||
|
||||
if (!hKey && lpSubKey && phkResult)
|
||||
{
|
||||
|
@ -3223,7 +3274,11 @@ RegOpenKeyA (HKEY hKey,
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
return RegOpenKeyExA( hKey, lpSubKey, 0, MAXIMUM_ALLOWED, phkResult);
|
||||
return RegOpenKeyExA(hKey,
|
||||
lpSubKey,
|
||||
0,
|
||||
MAXIMUM_ALLOWED,
|
||||
phkResult);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3241,7 +3296,8 @@ RegOpenKeyW (HKEY hKey,
|
|||
LPCWSTR lpSubKey,
|
||||
PHKEY phkResult)
|
||||
{
|
||||
TRACE("RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n", hKey, lpSubKey, phkResult);
|
||||
TRACE("RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n",
|
||||
hKey, lpSubKey, phkResult);
|
||||
|
||||
if (!hKey && lpSubKey && phkResult)
|
||||
{
|
||||
|
@ -3253,7 +3309,12 @@ RegOpenKeyW (HKEY hKey,
|
|||
*phkResult = hKey;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
return RegOpenKeyExW(hKey, lpSubKey, 0, MAXIMUM_ALLOWED, phkResult);
|
||||
|
||||
return RegOpenKeyExW(hKey,
|
||||
lpSubKey,
|
||||
0,
|
||||
MAXIMUM_ALLOWED,
|
||||
phkResult);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3278,20 +3339,24 @@ RegOpenKeyExA (HKEY hKey,
|
|||
TRACE("RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
|
||||
hKey, lpSubKey, ulOptions, samDesired, phkResult);
|
||||
|
||||
Status = MapDefaultKey (&KeyHandle, hKey);
|
||||
Status = MapDefaultKey(&KeyHandle,
|
||||
hKey);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return RtlNtStatusToDosError(Status);
|
||||
}
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz (&SubKeyString, (LPSTR)lpSubKey);
|
||||
RtlCreateUnicodeStringFromAsciiz(&SubKeyString,
|
||||
(LPSTR)lpSubKey);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&SubKeyString,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
KeyHandle,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenKey ((PHANDLE)phkResult, samDesired, &ObjectAttributes);
|
||||
Status = NtOpenKey((PHANDLE)phkResult,
|
||||
samDesired,
|
||||
&ObjectAttributes);
|
||||
RtlFreeUnicodeString(&SubKeyString);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -3342,8 +3407,9 @@ RegOpenKeyExW (HKEY hKey,
|
|||
KeyHandle,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenKey ((PHANDLE)phkResult, samDesired, &ObjectAttributes);
|
||||
|
||||
Status = NtOpenKey((PHANDLE)phkResult,
|
||||
samDesired,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ErrorCode = RtlNtStatusToDosError(Status);
|
||||
|
@ -3475,7 +3541,6 @@ ReadTokenSid:
|
|||
/*
|
||||
* Open the key
|
||||
*/
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&UserClassesKeyRoot,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
|
@ -3684,6 +3749,7 @@ RegQueryInfoKeyW (HKEY hKey,
|
|||
{
|
||||
*lpcbMaxValueLen = FullInfo->MaxValueDataLen;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (lpcbSecurityDescriptor != NULL)
|
||||
{
|
||||
|
@ -3885,6 +3951,118 @@ RegQueryReflectionKey(IN HKEY hBase,
|
|||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegQueryValueExA
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
LONG STDCALL
|
||||
RegQueryValueExA(HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData)
|
||||
{
|
||||
UNICODE_STRING ValueName;
|
||||
UNICODE_STRING ValueData;
|
||||
ANSI_STRING AnsiString;
|
||||
LONG ErrorCode;
|
||||
DWORD Length;
|
||||
DWORD Type;
|
||||
|
||||
TRACE("hKey 0x%X lpValueName %s lpData 0x%X lpcbData %d\n",
|
||||
hKey, lpValueName, lpData, lpcbData ? *lpcbData : 0);
|
||||
|
||||
if (lpData != NULL && lpcbData == NULL)
|
||||
{
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (lpData)
|
||||
{
|
||||
ValueData.Length = 0;
|
||||
ValueData.MaximumLength = (*lpcbData + 1) * sizeof(WCHAR);
|
||||
ValueData.Buffer = RtlAllocateHeap(ProcessHeap,
|
||||
0,
|
||||
ValueData.MaximumLength);
|
||||
if (!ValueData.Buffer)
|
||||
{
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ValueData.Buffer = NULL;
|
||||
ValueData.Length = 0;
|
||||
ValueData.MaximumLength = 0;
|
||||
|
||||
if (lpcbData)
|
||||
*lpcbData = 0;
|
||||
}
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(&ValueName,
|
||||
(LPSTR)lpValueName);
|
||||
|
||||
Length = (lpcbData == NULL) ? 0 : *lpcbData * sizeof(WCHAR);
|
||||
ErrorCode = RegQueryValueExW(hKey,
|
||||
ValueName.Buffer,
|
||||
lpReserved,
|
||||
&Type,
|
||||
(lpData == NULL) ? NULL : (LPBYTE)ValueData.Buffer,
|
||||
&Length);
|
||||
TRACE("ErrorCode %lu\n", ErrorCode);
|
||||
RtlFreeUnicodeString(&ValueName);
|
||||
|
||||
if (ErrorCode == ERROR_SUCCESS ||
|
||||
ErrorCode == ERROR_MORE_DATA)
|
||||
{
|
||||
if (lpType != NULL)
|
||||
{
|
||||
*lpType = Type;
|
||||
}
|
||||
|
||||
if ((Type == REG_SZ) || (Type == REG_MULTI_SZ) || (Type == REG_EXPAND_SZ))
|
||||
{
|
||||
if (ErrorCode == ERROR_SUCCESS && ValueData.Buffer != NULL)
|
||||
{
|
||||
RtlInitAnsiString(&AnsiString, NULL);
|
||||
AnsiString.Buffer = (LPSTR)lpData;
|
||||
AnsiString.MaximumLength = *lpcbData;
|
||||
ValueData.Length = Length;
|
||||
ValueData.MaximumLength = ValueData.Length + sizeof(WCHAR);
|
||||
RtlUnicodeStringToAnsiString(&AnsiString, &ValueData, FALSE);
|
||||
}
|
||||
|
||||
Length = Length / sizeof(WCHAR);
|
||||
}
|
||||
else if (ErrorCode == ERROR_SUCCESS && ValueData.Buffer != NULL)
|
||||
{
|
||||
if (*lpcbData < Length)
|
||||
{
|
||||
ErrorCode = ERROR_MORE_DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlMoveMemory(lpData, ValueData.Buffer, Length);
|
||||
}
|
||||
}
|
||||
|
||||
if (lpcbData != NULL)
|
||||
{
|
||||
*lpcbData = Length;
|
||||
}
|
||||
}
|
||||
|
||||
if (ValueData.Buffer != NULL)
|
||||
{
|
||||
RtlFreeHeap(ProcessHeap, 0, ValueData.Buffer);
|
||||
}
|
||||
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegQueryValueExW
|
||||
*
|
||||
|
@ -3971,117 +4149,6 @@ RegQueryValueExW(HKEY hkeyorg,
|
|||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegQueryValueExA
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
LONG STDCALL
|
||||
RegQueryValueExA (HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData)
|
||||
{
|
||||
UNICODE_STRING ValueName;
|
||||
UNICODE_STRING ValueData;
|
||||
ANSI_STRING AnsiString;
|
||||
LONG ErrorCode;
|
||||
DWORD Length;
|
||||
DWORD Type;
|
||||
|
||||
TRACE("hKey 0x%X lpValueName %s lpData 0x%X lpcbData %d\n",
|
||||
hKey, lpValueName, lpData, lpcbData ? *lpcbData : 0);
|
||||
|
||||
if (lpData != NULL && lpcbData == NULL)
|
||||
{
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (lpData)
|
||||
{
|
||||
ValueData.Length = 0;
|
||||
ValueData.MaximumLength = (*lpcbData + 1) * sizeof(WCHAR);
|
||||
ValueData.Buffer = RtlAllocateHeap (ProcessHeap,
|
||||
0,
|
||||
ValueData.MaximumLength);
|
||||
if (!ValueData.Buffer)
|
||||
{
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ValueData.Buffer = NULL;
|
||||
ValueData.Length = 0;
|
||||
ValueData.MaximumLength = 0;
|
||||
|
||||
if (lpcbData)
|
||||
*lpcbData = 0;
|
||||
}
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz (&ValueName,
|
||||
(LPSTR)lpValueName);
|
||||
|
||||
Length = (lpcbData == NULL) ? 0 : *lpcbData * sizeof(WCHAR);
|
||||
ErrorCode = RegQueryValueExW (hKey,
|
||||
ValueName.Buffer,
|
||||
lpReserved,
|
||||
&Type,
|
||||
(lpData == NULL) ? NULL : (LPBYTE)ValueData.Buffer,
|
||||
&Length);
|
||||
TRACE("ErrorCode %lu\n", ErrorCode);
|
||||
RtlFreeUnicodeString(&ValueName);
|
||||
|
||||
if (ErrorCode == ERROR_SUCCESS ||
|
||||
ErrorCode == ERROR_MORE_DATA)
|
||||
{
|
||||
if (lpType != NULL)
|
||||
{
|
||||
*lpType = Type;
|
||||
}
|
||||
|
||||
if ((Type == REG_SZ) || (Type == REG_MULTI_SZ) || (Type == REG_EXPAND_SZ))
|
||||
{
|
||||
if (ErrorCode == ERROR_SUCCESS && ValueData.Buffer != NULL)
|
||||
{
|
||||
RtlInitAnsiString(&AnsiString, NULL);
|
||||
AnsiString.Buffer = (LPSTR)lpData;
|
||||
AnsiString.MaximumLength = *lpcbData;
|
||||
ValueData.Length = Length;
|
||||
ValueData.MaximumLength = ValueData.Length + sizeof(WCHAR);
|
||||
RtlUnicodeStringToAnsiString(&AnsiString, &ValueData, FALSE);
|
||||
}
|
||||
Length = Length / sizeof(WCHAR);
|
||||
}
|
||||
else if (ErrorCode == ERROR_SUCCESS && ValueData.Buffer != NULL)
|
||||
{
|
||||
if (*lpcbData < Length)
|
||||
{
|
||||
ErrorCode = ERROR_MORE_DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlMoveMemory(lpData, ValueData.Buffer, Length);
|
||||
}
|
||||
}
|
||||
|
||||
if (lpcbData != NULL)
|
||||
{
|
||||
*lpcbData = Length;
|
||||
}
|
||||
}
|
||||
|
||||
if (ValueData.Buffer != NULL)
|
||||
{
|
||||
RtlFreeHeap(ProcessHeap, 0, ValueData.Buffer);
|
||||
}
|
||||
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* RegQueryValueA
|
||||
*
|
||||
|
@ -4224,6 +4291,7 @@ RegQueryValueW (HKEY hKey,
|
|||
ErrorCode = RtlNtStatusToDosError(Status);
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
CloseRealKey = TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -4339,6 +4407,7 @@ RegReplaceKeyW (HKEY hKey,
|
|||
ErrorCode = RtlNtStatusToDosError(Status);
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
CloseRealKey = TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -4357,6 +4426,7 @@ RegReplaceKeyW (HKEY hKey,
|
|||
{
|
||||
NtClose(RealKeyHandle);
|
||||
}
|
||||
|
||||
ErrorCode = ERROR_INVALID_PARAMETER;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
@ -4380,6 +4450,7 @@ RegReplaceKeyW (HKEY hKey,
|
|||
{
|
||||
NtClose(RealKeyHandle);
|
||||
}
|
||||
|
||||
ErrorCode = ERROR_INVALID_PARAMETER;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
@ -4843,10 +4914,14 @@ RegSetValueA (HKEY hKeyOriginal,
|
|||
|
||||
if (lpSubKey && lpSubKey[0]) /* need to create the subkey */
|
||||
{
|
||||
if ((ret = RegCreateKeyA( hKey, lpSubKey, &subkey )) != ERROR_SUCCESS) goto Cleanup;
|
||||
ret = RegCreateKeyA(hKey, lpSubKey, &subkey);
|
||||
if (ret != ERROR_SUCCESS)
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
ret = RegSetValueExA( subkey, NULL, 0, REG_SZ, (const BYTE*)lpData, strlen(lpData)+1 );
|
||||
if (subkey != hKey) RegCloseKey( subkey );
|
||||
if (subkey != hKey)
|
||||
RegCloseKey(subkey);
|
||||
|
||||
Cleanup:
|
||||
ClosePredefKey(hKey);
|
||||
|
@ -4874,9 +4949,11 @@ RegSetValueW (HKEY hKeyOriginal,
|
|||
|
||||
TRACE("(%p,%s,%d,%s,%d)\n", hKeyOriginal, debugstr_w(lpSubKey), dwType, debugstr_w(lpData), cbData );
|
||||
|
||||
if (dwType != REG_SZ || !lpData) return ERROR_INVALID_PARAMETER;
|
||||
if (dwType != REG_SZ || !lpData)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
Status = MapDefaultKey(&hKey, hKeyOriginal);
|
||||
Status = MapDefaultKey(&hKey,
|
||||
hKeyOriginal);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return RtlNtStatusToDosError(Status);
|
||||
|
@ -4885,12 +4962,15 @@ RegSetValueW (HKEY hKeyOriginal,
|
|||
|
||||
if (lpSubKey && lpSubKey[0]) /* need to create the subkey */
|
||||
{
|
||||
if ((ret = RegCreateKeyW( hKey, lpSubKey, &subkey )) != ERROR_SUCCESS) goto Cleanup;
|
||||
ret = RegCreateKeyW(hKey, lpSubKey, &subkey);
|
||||
if (ret != ERROR_SUCCESS)
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
ret = RegSetValueExW( subkey, NULL, 0, REG_SZ, (const BYTE*)lpData,
|
||||
(wcslen( lpData ) + 1) * sizeof(WCHAR) );
|
||||
if (subkey != hKey) RegCloseKey( subkey );
|
||||
if (subkey != hKey)
|
||||
RegCloseKey(subkey);
|
||||
|
||||
Cleanup:
|
||||
ClosePredefKey(hKey);
|
||||
|
@ -4969,6 +5049,7 @@ RegUnLoadKeyW (HKEY hKey,
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* load_string [Internal]
|
||||
*
|
||||
|
@ -5003,7 +5084,8 @@ static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMa
|
|||
|
||||
/* Else copy over the string, respecting the buffer size. */
|
||||
cMaxChars = (*pString < cMaxChars) ? *pString : (cMaxChars - 1);
|
||||
if (cMaxChars >= 0) {
|
||||
if (cMaxChars >= 0)
|
||||
{
|
||||
memcpy(pwszBuffer, pString+1, cMaxChars * sizeof(WCHAR));
|
||||
pwszBuffer[cMaxChars] = L'\0';
|
||||
}
|
||||
|
@ -5034,7 +5116,8 @@ RegLoadMUIStringW(IN HKEY hKey,
|
|||
if (!hKey || !pszOutBuf)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
if (pszDirectory && *pszDirectory) {
|
||||
if (pszDirectory && *pszDirectory)
|
||||
{
|
||||
FIXME("BaseDir parameter not yet supported!\n");
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
@ -5042,12 +5125,14 @@ RegLoadMUIStringW(IN HKEY hKey,
|
|||
/* Check for value existence and correctness of it's type, allocate a buffer and load it. */
|
||||
result = RegQueryValueExW(hKey, pszValue, NULL, &dwValueType, NULL, &cbData);
|
||||
if (result != ERROR_SUCCESS) goto cleanup;
|
||||
if (!(dwValueType == REG_SZ || dwValueType == REG_EXPAND_SZ) || !cbData) {
|
||||
if (!(dwValueType == REG_SZ || dwValueType == REG_EXPAND_SZ) || !cbData)
|
||||
{
|
||||
result = ERROR_FILE_NOT_FOUND;
|
||||
goto cleanup;
|
||||
}
|
||||
pwszTempBuffer = HeapAlloc(GetProcessHeap(), 0, cbData);
|
||||
if (!pwszTempBuffer) {
|
||||
if (!pwszTempBuffer)
|
||||
{
|
||||
result = ERROR_NOT_ENOUGH_MEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -5055,16 +5140,20 @@ RegLoadMUIStringW(IN HKEY hKey,
|
|||
if (result != ERROR_SUCCESS) goto cleanup;
|
||||
|
||||
/* Expand environment variables, if appropriate, or copy the original string over. */
|
||||
if (dwValueType == REG_EXPAND_SZ) {
|
||||
if (dwValueType == REG_EXPAND_SZ)
|
||||
{
|
||||
cbData = ExpandEnvironmentStringsW(pwszTempBuffer, NULL, 0) * sizeof(WCHAR);
|
||||
if (!cbData) goto cleanup;
|
||||
pwszExpandedBuffer = HeapAlloc(GetProcessHeap(), 0, cbData);
|
||||
if (!pwszExpandedBuffer) {
|
||||
if (!pwszExpandedBuffer)
|
||||
{
|
||||
result = ERROR_NOT_ENOUGH_MEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
ExpandEnvironmentStringsW(pwszTempBuffer, pwszExpandedBuffer, cbData);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
pwszExpandedBuffer = HeapAlloc(GetProcessHeap(), 0, cbData);
|
||||
memcpy(pwszExpandedBuffer, pwszTempBuffer, cbData);
|
||||
}
|
||||
|
@ -5072,15 +5161,19 @@ RegLoadMUIStringW(IN HKEY hKey,
|
|||
/* If the value references a resource based string, parse the value and load the string.
|
||||
* Else just copy over the original value. */
|
||||
result = ERROR_SUCCESS;
|
||||
if (*pwszExpandedBuffer != L'@') { /* '@' is the prefix for resource based string entries. */
|
||||
if (*pwszExpandedBuffer != L'@') /* '@' is the prefix for resource based string entries. */
|
||||
{
|
||||
lstrcpynW(pszOutBuf, pwszExpandedBuffer, cbOutBuf / sizeof(WCHAR));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
WCHAR *pComma = wcsrchr(pwszExpandedBuffer, L',');
|
||||
UINT uiStringId;
|
||||
HMODULE hModule;
|
||||
|
||||
/* Format of the expanded value is 'path_to_dll,-resId' */
|
||||
if (!pComma || pComma[1] != L'-') {
|
||||
if (!pComma || pComma[1] != L'-')
|
||||
{
|
||||
result = ERROR_BADKEY;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -5132,7 +5225,8 @@ RegLoadMUIStringA(IN HKEY hKey,
|
|||
result = RegLoadMUIStringW(hKey, valueW.Buffer, pwszBuffer, cbData, NULL, Flags,
|
||||
baseDirW.Buffer);
|
||||
|
||||
if (result == ERROR_SUCCESS) {
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
cbData = WideCharToMultiByte(CP_ACP, 0, pwszBuffer, -1, pszOutBuf, cbOutBuf, NULL, NULL);
|
||||
if (pcbData)
|
||||
*pcbData = cbData;
|
||||
|
@ -5146,5 +5240,4 @@ cleanup:
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue