[PATCH] Tests that prove ntdll has no notion of HKCR.

George Stephanos gaf.stephanos at gmail.com
Sat May 11 09:43:40 CDT 2013


As instructed, I added a few lines to the already written tests that
confirm my claim.

Part of the research of the registry merging project was to determine
where the implementation is going to be written: advapi32, ntdll or
the server itself. The server choice was dismissed since HKCR isn't
stored and rather fetched live. These tests prove that advapi32 calls
that reference HKCR are either pointed there to \REGISTRY\MACHINE or
\REGISTRY\USER and hence, that the merge is to be done in advapi32.

http://newtestbot.winehq.org/JobDetails.pl?Key=976
---
 dlls/advapi32/tests/registry.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index b2483a7..8437e4d 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -43,6 +43,7 @@ static DWORD (WINAPI *pRegDeleteTreeA)(HKEY,LPCSTR);
 static DWORD (WINAPI *pRegDeleteKeyExA)(HKEY,LPCSTR,REGSAM,DWORD);
 static BOOL (WINAPI *pIsWow64Process)(HANDLE,PBOOL);
 static NTSTATUS (WINAPI * pNtDeleteKey)(HANDLE);
+static NTSTATUS (WINAPI * pNtQueryKey)(HANDLE,int,PVOID,ULONG,PULONG);
 static NTSTATUS (WINAPI * pRtlFormatCurrentUserKeyPath)(UNICODE_STRING*);
 static NTSTATUS (WINAPI * pRtlFreeUnicodeString)(PUNICODE_STRING);
 
@@ -136,6 +137,7 @@ static void InitFunctionPtrs(void)
     pRtlFormatCurrentUserKeyPath = (void *)GetProcAddress( hntdll, "RtlFormatCurrentUserKeyPath" );
     pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
     pNtDeleteKey = (void *)GetProcAddress( hntdll, "NtDeleteKey" );
+    pNtQueryKey = (void *)GetProcAddress( hntdll, "NtQueryKey" );
 }
 
 /* delete key and all its subkeys */
@@ -2104,6 +2106,7 @@ static void test_classesroot(void)
     DWORD type = REG_SZ;
     static CHAR buffer[8];
     LONG res;
+    void *buf = malloc(300*sizeof(wchar_t));
 
     /* create a key in the user's classes */
     if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Classes\\WineTestCls", &hkey ))
@@ -2132,6 +2135,9 @@ static void test_classesroot(void)
         RegCloseKey( hkey );
         return;
     }
+    pNtQueryKey( hkcr, 3 /*KeyNameInformation*/, buf, 500*sizeof(wchar_t), (ULONG*)&res );
+    ok( wcsncmp((wchar_t*)buf+2, L"\\REGISTRY\\USER", 14) == 0,
+        "key not from \\REGISTRY\\USER\n");
 
     /* set a value in user's classes */
     res = RegSetValueExA(hkey, "val1", 0, REG_SZ, (const BYTE *)"user", sizeof("user"));
@@ -2200,6 +2206,9 @@ static void test_classesroot(void)
         RegCloseKey( hklm );
         return;
     }
+    pNtQueryKey( hkcr, 3 /*KeyNameInformation*/, buf, 500*sizeof(wchar_t), (ULONG*)&res );
+    ok( wcsncmp( (wchar_t*)buf+2, L"\\REGISTRY\\USER", 14) == 0,
+        "key not from \\REGISTRY\\USER\n");
 
     /* set a value in hklm classes */
     res = RegSetValueExA(hklm, "val2", 0, REG_SZ, (const BYTE *)"hklm", sizeof("hklm"));
@@ -2227,6 +2236,9 @@ static void test_classesroot(void)
                          KEY_QUERY_VALUE|KEY_SET_VALUE, &hkcr );
     ok(res == ERROR_SUCCESS,
        "test key not found in hkcr: %d\n", res);
+    pNtQueryKey( hkcr, 3 /*KeyNameInformation*/, buf, 500*sizeof(wchar_t), (ULONG*)&res );
+    ok( wcsncmp( (wchar_t*)buf+2, L"\\REGISTRY\\USER", 14) == 0,
+        "key not from \\REGISTRY\\USER\n");
 
     /* set a value in user's classes */
     res = RegSetValueExA(hkey, "val2", 0, REG_SZ, (const BYTE *)"user", sizeof("user"));
@@ -2267,6 +2279,9 @@ static void test_classesroot(void)
     /* try to open that subkey in hkcr */
     res = RegOpenKeyExA( hkcr, "subkey1", 0, KEY_QUERY_VALUE|KEY_SET_VALUE, &hkcrsub1 );
     ok(res == ERROR_SUCCESS, "test key not found in hkcr: %d\n", res);
+    pNtQueryKey( hkcrsub1, 3 /*KeyNameInformation*/, buf, 500*sizeof(wchar_t), (ULONG*)&res );
+    ok( wcsncmp( (wchar_t*)buf+2, L"\\REGISTRY\\MACHINE", 17) == 0,
+        "key created in hkcr not found in \\REGISTRY\\MACHINE\n");
 
     /* set a value in hklm classes */
     res = RegSetValueExA(hklmsub1, "subval1", 0, REG_SZ, (const BYTE *)"hklm", sizeof("hklm"));
@@ -2326,6 +2341,9 @@ static void test_classesroot(void)
     /* new subkey in hkcr */
     if (RegCreateKeyExA( hkcr, "subkey2", 0, NULL, 0,
                          KEY_QUERY_VALUE|KEY_SET_VALUE, NULL, &hkcrsub2, NULL )) return;
+    pNtQueryKey( hkcrsub2, 3 /*KeyNameInformation*/, buf, 256*sizeof(wchar_t), (ULONG*)&res );
+    ok( wcsncmp( (wchar_t*)buf+2, L"\\REGISTRY\\MACHINE", 17) == 0,
+        "key not found in \\REGISTRY\\MACHINE");
     res = RegSetValueExA(hkcrsub2, "subval1", 0, REG_SZ, (const BYTE *)"hkcr", sizeof("hkcr"));
     ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
 
-- 
1.8.1.msysgit.1




More information about the wine-devel mailing list