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

Dmitry Timoshkov dmitry at baikal.ru
Wed Jan 26 10:18:50 CST 2022


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

diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c
index 445c05a02e1..16ce80a3dbf 100644
--- a/dlls/ntdll/tests/reg.c
+++ b/dlls/ntdll/tests/reg.c
@@ -456,6 +456,26 @@ todo_wine
     ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtOpenKey failed: 0x%08x\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%08x\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 );
+    todo_wine
+    ok( status == STATUS_SUCCESS || broken(status == STATUS_OBJECT_NAME_NOT_FOUND) /* win10 */,
+        "NtOpenKey failed: 0x%08x\n", status );
+    pNtClose( key );
+    pRtlFreeUnicodeString( &str );
+
     if (!pNtOpenKeyEx)
     {
         win_skip("NtOpenKeyEx not available\n");
@@ -630,13 +650,33 @@ static void test_NtCreateKey(void)
     status = pNtCreateKey( &subkey, am, &attr, 0, 0, 0, 0 );
     ok( status == STATUS_SUCCESS,
         "NtCreateKey failed: 0x%08x\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%08x\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%08x\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%08x\n", status );
     if (!status) pNtClose( subkey );
     pRtlFreeUnicodeString( &str );
 
-- 
2.34.1




More information about the wine-devel mailing list