Author: jgardou
Date: Wed Oct 1 17:48:26 2014
New Revision: 64443
URL:
http://svn.reactos.org/svn/reactos?rev=64443&view=rev
Log:
[ADVAPI32]
- Implement RegQueryValueEx for HKCR subkeys
CORE-8582
Modified:
trunk/reactos/dll/win32/advapi32/reg/hkcr.c
trunk/reactos/dll/win32/advapi32/reg/reg.c
trunk/reactos/dll/win32/advapi32/reg/reg.h
Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/hkc…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] Wed Oct 1 17:48:26 2014
@@ -268,6 +268,7 @@
return ErrorCode;
}
+/* HKCR version of RegDeleteKeyExW */
LONG
WINAPI
DeleteHKCRKey(
@@ -329,3 +330,68 @@
return ErrorCode;
}
+
+/* HKCR version of RegQueryValueExW */
+LONG
+WINAPI
+QueryHKCRValue(
+ _In_ HKEY hKey,
+ _In_ LPCWSTR Name,
+ _In_ LPDWORD Reserved,
+ _In_ LPDWORD Type,
+ _In_ LPBYTE Data,
+ _In_ LPDWORD Count)
+{
+ HKEY QueriedKey;
+ LONG ErrorCode;
+
+ ASSERT(IsHKCRKey(hKey));
+
+ /* Remove the HKCR flag while we're working */
+ hKey = (HKEY)(((ULONG_PTR)hKey) & ~0x2);
+
+ ErrorCode = GetPreferredHKCRKey(hKey, &QueriedKey);
+
+ if (ErrorCode == ERROR_FILE_NOT_FOUND)
+ {
+ /* The key doesn't exist on HKCU side, no chance for a value in it */
+ return RegQueryValueExW(hKey, Name, Reserved, Type, Data, Count);
+ }
+
+ if (ErrorCode != ERROR_SUCCESS)
+ {
+ /* Somehow we failed for another reason (maybe deleted key or whatever) */
+ return ErrorCode;
+ }
+
+ ErrorCode = RegQueryValueExW(QueriedKey, Name, Reserved, Type, Data, Count);
+
+ /* Close it if we must */
+ if (QueriedKey != hKey)
+ {
+ /* The original key is on the machine view */
+ RegCloseKey(QueriedKey);
+ }
+
+ /* Anything else than ERROR_FILE_NOT_FOUND means that we found it, even if it is with
failures. */
+ if (ErrorCode != ERROR_FILE_NOT_FOUND)
+ return ErrorCode;
+
+ /* If we're here, we must open from HKLM key. */
+ ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey);
+ if (ErrorCode != ERROR_SUCCESS)
+ {
+ /* Maybe the key doesn't exist in the HKLM view */
+ return ErrorCode;
+ }
+
+ ErrorCode = RegQueryValueExW(QueriedKey, Name, Reserved, Type, Data, Count);
+
+ /* Close it if we must */
+ if (QueriedKey != hKey)
+ {
+ RegCloseKey(QueriedKey);
+ }
+
+ return ErrorCode;
+}
Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] Wed Oct 1 17:48:26 2014
@@ -4082,12 +4082,13 @@
*/
LONG
WINAPI
-RegQueryValueExW(HKEY hkeyorg,
- LPCWSTR name,
- LPDWORD reserved,
- LPDWORD type,
- LPBYTE data,
- LPDWORD count)
+RegQueryValueExW(
+ _In_ HKEY hkeyorg,
+ _In_ LPCWSTR name,
+ _In_ LPDWORD reserved,
+ _In_ LPDWORD type,
+ _In_ LPBYTE data,
+ _In_ LPDWORD count)
{
HANDLE hkey;
NTSTATUS status;
@@ -4107,6 +4108,13 @@
if (!NT_SUCCESS(status))
{
return RtlNtStatusToDosError(status);
+ }
+
+ if (IsHKCRKey(hkey))
+ {
+ LONG ErrorCode = QueryHKCRValue(hkey, name, reserved, type, data, count);
+ ClosePredefKey(hkey);
+ return ErrorCode;
}
RtlInitUnicodeString( &name_str, name );
Modified: trunk/reactos/dll/win32/advapi32/reg/reg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/reg/reg.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/reg/reg.h [iso-8859-1] Wed Oct 1 17:48:26 2014
@@ -39,3 +39,13 @@
_In_ REGSAM RegSam,
_In_ DWORD Reserved);
+LONG
+WINAPI
+QueryHKCRValue(
+ _In_ HKEY hKey,
+ _In_ LPCWSTR Name,
+ _In_ LPDWORD Reserved,
+ _In_ LPDWORD Type,
+ _In_ LPBYTE Data,
+ _In_ LPDWORD Count);
+