mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
Fixed RegQueryValueExA and marked as implemented.
svn path=/trunk/; revision=6312
This commit is contained in:
parent
47419d0b98
commit
3889a8a8dd
1 changed files with 50 additions and 54 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: reg.c,v 1.30 2003/08/30 14:46:29 hbirr Exp $
|
/* $Id: reg.c,v 1.31 2003/10/14 18:18:27 navaraf 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
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#define NDEBUG
|
//#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
/* DEFINES ******************************************************************/
|
/* DEFINES ******************************************************************/
|
||||||
|
@ -2180,7 +2180,7 @@ RegQueryValueExW (HKEY hKey,
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* RegQueryValueExA
|
* RegQueryValueExA
|
||||||
*
|
*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LONG
|
LONG
|
||||||
STDCALL
|
STDCALL
|
||||||
|
@ -2192,69 +2192,65 @@ RegQueryValueExA(
|
||||||
LPBYTE lpData,
|
LPBYTE lpData,
|
||||||
LPDWORD lpcbData)
|
LPDWORD lpcbData)
|
||||||
{
|
{
|
||||||
WCHAR ValueNameBuffer[MAX_PATH+1];
|
|
||||||
UNICODE_STRING ValueName;
|
UNICODE_STRING ValueName;
|
||||||
UNICODE_STRING ValueData;
|
UNICODE_STRING ValueData;
|
||||||
ANSI_STRING AnsiString;
|
ANSI_STRING AnsiString;
|
||||||
LONG ErrorCode;
|
LONG ErrorCode;
|
||||||
DWORD ResultSize;
|
|
||||||
DWORD Type;
|
|
||||||
|
|
||||||
/* FIXME: HKEY_PERFORMANCE_DATA is special, see MS SDK */
|
if ((lpData) && (!lpcbData))
|
||||||
|
{
|
||||||
if ((lpData) && (!lpcbData)) {
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
return ERROR_INVALID_PARAMETER;
|
||||||
return ERROR_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
RtlInitUnicodeString(&ValueData, NULL);
|
|
||||||
if (lpData) {
|
|
||||||
ValueData.MaximumLength = *lpcbData * sizeof(WCHAR);
|
|
||||||
ValueData.Buffer = RtlAllocateHeap(
|
|
||||||
ProcessHeap,
|
|
||||||
0,
|
|
||||||
ValueData.MaximumLength);
|
|
||||||
if (!ValueData.Buffer) {
|
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
RtlInitAnsiString(&AnsiString, (LPSTR)lpValueName);
|
if (lpData)
|
||||||
RtlInitUnicodeString(&ValueName, NULL);
|
{
|
||||||
ValueName.Buffer = &ValueNameBuffer[0];
|
ValueData.Length = ValueData.MaximumLength = *lpcbData * sizeof(WCHAR);
|
||||||
ValueName.MaximumLength = sizeof(ValueNameBuffer);
|
ValueData.Buffer = RtlAllocateHeap(
|
||||||
RtlAnsiStringToUnicodeString(&ValueName, &AnsiString, FALSE);
|
ProcessHeap,
|
||||||
if (lpcbData) {
|
0,
|
||||||
ResultSize = *lpcbData;
|
ValueData.Length);
|
||||||
} else {
|
if (!ValueData.Buffer)
|
||||||
ResultSize = 0;
|
{
|
||||||
}
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
|
return ERROR_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ValueData.Buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlCreateUnicodeStringFromAsciiz(&ValueName, (LPSTR)lpValueName);
|
||||||
|
|
||||||
ErrorCode = RegQueryValueExW(
|
ErrorCode = RegQueryValueExW(
|
||||||
hKey,
|
hKey,
|
||||||
ValueName.Buffer,
|
ValueName.Buffer,
|
||||||
lpReserved,
|
lpReserved,
|
||||||
&Type,
|
lpType,
|
||||||
(LPBYTE)ValueData.Buffer,
|
(LPBYTE)ValueData.Buffer,
|
||||||
&ResultSize);
|
(LPDWORD)&ValueData.Length);
|
||||||
if ((ErrorCode == ERROR_SUCCESS) && (ValueData.Buffer != NULL)) {
|
|
||||||
if (lpType) {
|
if ((ErrorCode == ERROR_SUCCESS) && (ValueData.Buffer != NULL))
|
||||||
*lpType = Type;
|
{
|
||||||
|
if (lpType && ((*lpType == REG_SZ) || (*lpType == REG_MULTI_SZ) || (*lpType == REG_EXPAND_SZ)))
|
||||||
|
{
|
||||||
|
RtlInitAnsiString(&AnsiString, NULL);
|
||||||
|
AnsiString.Buffer = lpData;
|
||||||
|
AnsiString.MaximumLength = *lpcbData;
|
||||||
|
RtlUnicodeStringToAnsiString(&AnsiString, &ValueData, FALSE);
|
||||||
|
*lpcbData = ValueData.Length / sizeof(WCHAR);
|
||||||
|
} else {
|
||||||
|
RtlMoveMemory(lpData, ValueData.Buffer, *lpcbData);
|
||||||
|
*lpcbData = ValueData.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ValueData.Buffer)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(ProcessHeap, 0, ValueData.Buffer);
|
||||||
}
|
}
|
||||||
if ((Type == REG_SZ) || (Type == REG_MULTI_SZ) || (Type == REG_EXPAND_SZ)) {
|
|
||||||
ValueData.Length = ResultSize;
|
|
||||||
RtlInitAnsiString(&AnsiString, NULL);
|
|
||||||
AnsiString.Buffer = lpData;
|
|
||||||
AnsiString.MaximumLength = *lpcbData;
|
|
||||||
RtlUnicodeStringToAnsiString(&AnsiString, &ValueData, FALSE);
|
|
||||||
} else {
|
|
||||||
RtlMoveMemory(lpData, ValueData.Buffer, ResultSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lpcbData) {
|
|
||||||
*lpcbData = ResultSize;
|
|
||||||
}
|
|
||||||
if (ValueData.Buffer) {
|
|
||||||
RtlFreeHeap(ProcessHeap, 0, ValueData.Buffer);
|
|
||||||
}
|
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue