From: Dmitry Timoshkov Subject: [PATCH v2 2/2] ntdll/tests: Add more tests for NtOpenKey/NtCreateKey. Message-Id: <20220126191850.f4a5bac4658277351c8a363e@baikal.ru> Date: Wed, 26 Jan 2022 19:18:50 +0300 Signed-off-by: Dmitry Timoshkov --- 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