[PATCH] ntdll/tests: Add more tests for NtOpenKey/NtCreateKey.

Dmitry Timoshkov dmitry at baikal.ru
Thu Jul 7 02:15:50 CDT 2022


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/ntdll/tests/reg.c | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c
index 5e141b1370d..c4a1fb43d5d 100644
--- a/dlls/ntdll/tests/reg.c
+++ b/dlls/ntdll/tests/reg.c
@@ -468,6 +468,25 @@ static void test_NtOpenKey(void)
     ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtOpenKey failed: 0x%08lx\n", status );
     pRtlFreeUnicodeString( &str );
 
+    pRtlCreateUnicodeStringFromAsciiz( &str, "\\REGISTRY\\Machine\\Software\\Classes123" );
+    str.Buffer[str.Length/sizeof(WCHAR) - 1] = 0;
+    str.Buffer[str.Length/sizeof(WCHAR) - 2] = 0;
+    str.Buffer[str.Length/sizeof(WCHAR) - 3] = 0;
+    str.Length += sizeof(WCHAR); /* include terminating \0 in the length */
+    status = pNtOpenKey( &key, KEY_READ, &attr );
+    ok( status == STATUS_SUCCESS || broken(status == STATUS_OBJECT_NAME_NOT_FOUND) /* win8 */,
+        "NtOpenKey failed: 0x%08lx\n", status );
+    if (!status) pNtClose( key );
+    pRtlFreeUnicodeString( &str );
+
+    pRtlCreateUnicodeStringFromAsciiz( &str, "\\REGISTRY\\Machine\\Software\\Classes123" );
+    str.Buffer[str.Length/sizeof(WCHAR) - 3] = 0;
+    status = pNtOpenKey( &key, KEY_READ, &attr );
+    ok( status == STATUS_SUCCESS || broken(status == STATUS_OBJECT_NAME_NOT_FOUND) /* win10 */,
+        "NtOpenKey failed: 0x%08lx\n", status );
+    pNtClose( key );
+    pRtlFreeUnicodeString( &str );
+
     InitializeObjectAttributes(&attr, &winetestpath, 0, 0, 0);
     status = pNtOpenKey(&key, KEY_WRITE|KEY_READ, &attr);
     ok(status == STATUS_SUCCESS, "NtOpenKey failed: 0x%08lx\n", status);
@@ -686,13 +705,33 @@ static void test_NtCreateKey(void)
     status = pNtCreateKey( &subkey, am, &attr, 0, 0, 0, 0 );
     ok( status == STATUS_SUCCESS,
         "NtCreateKey failed: 0x%08lx\n", status );
-    if (!status) pNtClose( subkey );
+    pNtClose( subkey );
     pRtlFreeUnicodeString( &str );
 
     pRtlCreateUnicodeStringFromAsciiz( &str, "\\REGISTRY\\MACHINE\\SOFTWARE\\CLASSES" );
     status = pNtCreateKey( &subkey, am, &attr, 0, 0, 0, 0 );
     ok( status == STATUS_SUCCESS,
         "NtCreateKey failed: 0x%08lx\n", status );
+    pNtClose( subkey );
+    pRtlFreeUnicodeString( &str );
+
+    pRtlCreateUnicodeStringFromAsciiz( &str, "\\REGISTRY\\Machine\\Software\\Classes123" );
+    str.Buffer[str.Length/sizeof(WCHAR) - 1] = 0;
+    str.Buffer[str.Length/sizeof(WCHAR) - 2] = 0;
+    str.Buffer[str.Length/sizeof(WCHAR) - 3] = 0;
+    str.Length += sizeof(WCHAR); /* include terminating \0 in the length */
+    status = pNtCreateKey( &subkey, am, &attr, 0, 0, 0, 0 );
+    ok( status == STATUS_SUCCESS || broken(status == STATUS_OBJECT_PATH_NOT_FOUND) /* win8 */,
+        "NtCreateKey failed: 0x%08lx\n", status );
+    if (!status) pNtClose( subkey );
+    pRtlFreeUnicodeString( &str );
+
+    pRtlCreateUnicodeStringFromAsciiz( &str, "\\REGISTRY\\Machine\\Software\\Classes123" );
+    str.Buffer[str.Length/sizeof(WCHAR) - 3] = 0;
+    str.Length += sizeof(WCHAR); /* include terminating \0 in the length */
+    status = pNtCreateKey( &subkey, am, &attr, 0, 0, 0, 0 );
+    ok( status == STATUS_SUCCESS || broken(status == STATUS_OBJECT_PATH_NOT_FOUND) /* win8 */,
+        "NtCreateKey failed: 0x%08lx\n", status );
     if (!status) pNtClose( subkey );
     pRtlFreeUnicodeString( &str );
 
-- 
2.36.1




More information about the wine-devel mailing list