Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/om.c | 387 ++++++++++++++++-------------------------- 1 file changed, 149 insertions(+), 238 deletions(-)
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c index c17b6ffa8db..5d7e4007853 100644 --- a/dlls/ntdll/tests/om.c +++ b/dlls/ntdll/tests/om.c @@ -25,7 +25,6 @@ #include "winnt.h" #include "stdlib.h"
-static HANDLE (WINAPI *pCreateWaitableTimerA)(SECURITY_ATTRIBUTES*, BOOL, LPCSTR); static BOOLEAN (WINAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING, LPCSTR); static VOID (WINAPI *pRtlInitUnicodeString)( PUNICODE_STRING, LPCWSTR ); static VOID (WINAPI *pRtlFreeUnicodeString)(PUNICODE_STRING); @@ -98,8 +97,7 @@ static void test_case_sensitive (void) ok(status == STATUS_SUCCESS, "Failed to create Mutant(%08x)\n", status);
status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, FALSE, FALSE); - ok(status == STATUS_OBJECT_NAME_COLLISION || status == STATUS_OBJECT_TYPE_MISMATCH, - "NtCreateEvent should have failed with STATUS_OBJECT_NAME_COLLISION or STATUS_OBJECT_TYPE_MISMATCH got (%08x)\n", status); + ok(status == STATUS_OBJECT_NAME_COLLISION || status == STATUS_OBJECT_TYPE_MISMATCH /* Vista+ */, "got %#x\n", status);
pRtlInitUnicodeString(&str, buffer2); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); @@ -117,8 +115,7 @@ static void test_case_sensitive (void) pRtlInitUnicodeString(&str, buffer4); InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL); status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE); - ok(status == STATUS_OBJECT_NAME_COLLISION || status == STATUS_OBJECT_TYPE_MISMATCH, - "NtCreateMutant should have failed with STATUS_OBJECT_NAME_COLLISION or STATUS_OBJECT_TYPE_MISMATCH got (%08x)\n", status); + ok(status == STATUS_OBJECT_NAME_COLLISION || status == STATUS_OBJECT_TYPE_MISMATCH /* Vista+ */, "got %#x\n", status);
status = pNtCreateEvent(&h, GENERIC_ALL, &attr, FALSE, FALSE); ok(status == STATUS_OBJECT_NAME_COLLISION, @@ -247,19 +244,10 @@ static HANDLE get_base_dir(void) sprintf( name, "\BaseNamedObjects\Session\%u", NtCurrentTeb()->Peb->SessionId ); pRtlCreateUnicodeStringFromAsciiz(&str, name ); status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr); + ok(!status, "got %#x\n", status); + ok(is_correct_dir( dir, objname ), "wrong dir\n"); pRtlFreeUnicodeString(&str); - if (!status && is_correct_dir( dir, objname )) goto done; - if (!status) pNtClose( dir );
- pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects"); - status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr); - pRtlFreeUnicodeString(&str); - if (!status && is_correct_dir( dir, objname )) goto done; - if (!status) pNtClose( dir ); - - dir = 0; - -done: pNtClose( h ); return dir; } @@ -289,15 +277,10 @@ static void test_name_collisions(void)
pRtlCreateUnicodeStringFromAsciiz(&str, "\??\PIPE\om.c-mutant"); status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE); - ok(status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_OBJECT_PATH_NOT_FOUND, - "NtCreateMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08x)\n", status); + todo_wine ok(status == STATUS_OBJECT_PATH_NOT_FOUND, "got %#x\n", status); pRtlFreeUnicodeString(&str);
- if (!(dir = get_base_dir())) - { - win_skip( "couldn't find the BaseNamedObjects dir\n" ); - return; - } + dir = get_base_dir(); pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-test"); InitializeObjectAttributes(&attr, &str, OBJ_OPENIF, dir, NULL); h = CreateMutexA(NULL, FALSE, "om.c-test"); @@ -339,12 +322,12 @@ static void test_name_collisions(void) pNtClose(h1); pNtClose(h2);
- h = pCreateWaitableTimerA(NULL, TRUE, "om.c-test"); + h = CreateWaitableTimerA(NULL, TRUE, "om.c-test"); ok(h != 0, "CreateWaitableTimerA failed got ret=%p (%d)\n", h, GetLastError()); status = pNtCreateTimer(&h1, GENERIC_ALL, &attr, NotificationTimer); ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL, "NtCreateTimer should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08x)\n", status); - h2 = pCreateWaitableTimerA(NULL, TRUE, "om.c-test"); + h2 = CreateWaitableTimerA(NULL, TRUE, "om.c-test"); winerr = GetLastError(); ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS, "CreateWaitableTimerA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%d)\n", h2, winerr); @@ -468,12 +451,7 @@ static void test_name_limits(void) size.QuadPart = 4096; pRtlCreateUnicodeStringFromAsciiz( &target, "\DosDevices" );
- if (!(attr.RootDirectory = get_base_dir())) - { - win_skip( "couldn't find the BaseNamedObjects dir\n" ); - return; - } - + attr.RootDirectory = get_base_dir(); str.Length = 0; status = pNtCreateMutant( &ret, GENERIC_ALL, &attr2, FALSE ); ok( status == STATUS_SUCCESS, "%u: NtCreateMutant failed %x\n", str.Length, status ); @@ -481,7 +459,7 @@ static void test_name_limits(void) status = pNtOpenMutant( &ret2, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenMutant failed %x\n", str.Length, status ); status = pNtOpenMutant( &ret2, GENERIC_ALL, &attr3 ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE /* < 7 */, "%u: NtOpenMutant failed %x\n", str.Length, status ); pNtClose( ret ); status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr2, 1, 2 ); @@ -490,7 +468,7 @@ static void test_name_limits(void) status = pNtOpenSemaphore( &ret2, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenSemaphore failed %x\n", str.Length, status ); status = pNtOpenSemaphore( &ret2, GENERIC_ALL, &attr3 ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE /* < 7 */, "%u: NtOpenSemaphore failed %x\n", str.Length, status ); pNtClose( ret ); status = pNtCreateEvent( &ret, GENERIC_ALL, &attr2, 1, 0 ); @@ -499,7 +477,7 @@ static void test_name_limits(void) status = pNtOpenEvent( &ret2, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenEvent failed %x\n", str.Length, status ); status = pNtOpenEvent( &ret2, GENERIC_ALL, &attr3 ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE /* < 7 */, "%u: NtOpenEvent failed %x\n", str.Length, status ); pNtClose( ret ); status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr2, 0 ); @@ -508,7 +486,7 @@ static void test_name_limits(void) status = pNtOpenKeyedEvent( &ret2, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenKeyedEvent failed %x\n", str.Length, status ); status = pNtOpenKeyedEvent( &ret2, GENERIC_ALL, &attr3 ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE /* < 7 */, "%u: NtOpenKeyedEvent failed %x\n", str.Length, status ); pNtClose( ret ); status = pNtCreateTimer( &ret, GENERIC_ALL, &attr2, NotificationTimer ); @@ -517,7 +495,7 @@ static void test_name_limits(void) status = pNtOpenTimer( &ret2, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenTimer failed %x\n", str.Length, status ); status = pNtOpenTimer( &ret2, GENERIC_ALL, &attr3 ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE /* < 7 */, "%u: NtOpenTimer failed %x\n", str.Length, status ); pNtClose( ret ); status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr2, 0 ); @@ -526,7 +504,7 @@ static void test_name_limits(void) status = pNtOpenIoCompletion( &ret2, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenCompletion failed %x\n", str.Length, status ); status = pNtOpenIoCompletion( &ret2, GENERIC_ALL, &attr3 ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE /* < 7 */, "%u: NtOpenCompletion failed %x\n", str.Length, status ); pNtClose( ret ); status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 ); @@ -535,7 +513,7 @@ static void test_name_limits(void) status = pNtOpenJobObject( &ret2, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenJobObject failed %x\n", str.Length, status ); status = pNtOpenJobObject( &ret2, GENERIC_ALL, &attr3 ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE /* < 7 */, "%u: NtOpenJobObject failed %x\n", str.Length, status ); pNtClose( ret ); status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr2 ); @@ -564,7 +542,7 @@ static void test_name_limits(void) status = pNtOpenSection( &ret2, SECTION_MAP_WRITE, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenSection failed %x\n", str.Length, status ); status = pNtOpenSection( &ret2, SECTION_MAP_WRITE, &attr3 ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE /* < 7 */, "%u: NtOpenSection failed %x\n", str.Length, status ); pNtClose( ret );
@@ -868,7 +846,7 @@ static void test_name_limits(void) attr2.ObjectName = attr3.ObjectName = NULL; status = pNtCreateKey( &ret, GENERIC_ALL, &attr2, 0, NULL, 0, NULL ); todo_wine - ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE /* vista wow64 */, "NULL: NtCreateKey failed %x\n", status ); status = pNtCreateKey( &ret, GENERIC_ALL, &attr3, 0, NULL, 0, NULL ); todo_wine @@ -876,7 +854,7 @@ static void test_name_limits(void) status = pNtCreateKey( &ret, GENERIC_ALL, NULL, 0, NULL, 0, NULL ); ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateKey failed %x\n", status ); status = pNtOpenKey( &ret, GENERIC_ALL, &attr2 ); - ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE, + ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE /* vista wow64 */, "NULL: NtOpenKey failed %x\n", status ); status = pNtOpenKey( &ret, GENERIC_ALL, &attr3 ); ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenKey failed %x\n", status ); @@ -894,15 +872,14 @@ static void test_directory(void) UNICODE_STRING str; OBJECT_ATTRIBUTES attr; HANDLE dir, dir1, h, h2; - BOOL is_nt4; + WCHAR buffer[256]; + ULONG len, full_len;
/* No name and/or no attributes */ status = pNtCreateDirectoryObject(NULL, DIRECTORY_QUERY, &attr); - ok(status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_PARAMETER, - "NtCreateDirectoryObject should have failed with STATUS_ACCESS_VIOLATION got(%08x)\n", status); + ok(status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_PARAMETER /* wow64 */, "got %#x\n", status); status = pNtOpenDirectoryObject(NULL, DIRECTORY_QUERY, &attr); - ok(status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_PARAMETER, - "NtOpenDirectoryObject should have failed with STATUS_ACCESS_VIOLATION got(%08x)\n", status); + ok(status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_PARAMETER /* wow64 */, "got %#x\n", status);
status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, NULL); ok(status == STATUS_SUCCESS, "Failed to create Directory without attributes(%08x)\n", status); @@ -951,87 +928,76 @@ static void test_directory(void) pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\Local"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtOpenSymbolicLinkObject(&dir, SYMBOLIC_LINK_QUERY, &attr); - is_nt4 = (status == STATUS_OBJECT_NAME_NOT_FOUND); /* nt4 doesn't have Local\ symlink */ - if (!is_nt4) - { - WCHAR buffer[256]; - ULONG len, full_len; - - ok(status == STATUS_SUCCESS, "Failed to open SymbolicLink(%08x)\n", status); - pRtlFreeUnicodeString(&str); - InitializeObjectAttributes(&attr, &str, 0, dir, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "one more level"); - status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtCreateDirectoryObject got %08x\n", status ); - pRtlFreeUnicodeString(&str); - - pRtlCreateUnicodeStringFromAsciiz( &str, "\BaseNamedObjects\Local\om.c-test" ); - InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); - status = pNtCreateDirectoryObject( &dir1, DIRECTORY_QUERY, &attr ); - ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString( &str ); - pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-test" ); - InitializeObjectAttributes( &attr, &str, 0, dir, NULL ); - status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH, "Failed to open directory %08x\n", status ); - if (!status) pNtClose(h); - pRtlFreeUnicodeString( &str ); - - pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-event" ); - InitializeObjectAttributes( &attr, &str, 0, dir1, NULL ); - status = pNtCreateEvent( &h, GENERIC_ALL, &attr, 1, 0 ); - ok( status == STATUS_SUCCESS, "NtCreateEvent failed %x\n", status ); - status = pNtOpenEvent( &h2, GENERIC_ALL, &attr ); - ok( status == STATUS_SUCCESS, "NtOpenEvent failed %x\n", status ); - pNtClose( h2 ); - pRtlFreeUnicodeString( &str ); - pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-test\om.c-event" ); - InitializeObjectAttributes( &attr, &str, 0, dir, NULL ); - status = pNtOpenEvent( &h2, GENERIC_ALL, &attr ); - ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtOpenEvent failed %x\n", status ); - pRtlFreeUnicodeString( &str ); - pRtlCreateUnicodeStringFromAsciiz( &str, "\BasedNamedObjects\Local\om.c-test\om.c-event" ); - InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); - status = pNtOpenEvent( &h2, GENERIC_ALL, &attr ); - ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "NtOpenEvent failed %x\n", status ); - pRtlFreeUnicodeString( &str ); - pNtClose( h ); - pNtClose( dir1 ); - - str.Buffer = buffer; - str.MaximumLength = sizeof(buffer); - len = 0xdeadbeef; - memset( buffer, 0xaa, sizeof(buffer) ); - status = pNtQuerySymbolicLinkObject( dir, &str, &len ); - ok( status == STATUS_SUCCESS, "NtQuerySymbolicLinkObject failed %08x\n", status ); - if (status != STATUS_SUCCESS) - goto error; - full_len = str.Length + sizeof(WCHAR); - ok( len == full_len, "bad length %u/%u\n", len, full_len ); - if (len == full_len) - ok( buffer[len / sizeof(WCHAR) - 1] == 0, "no terminating null\n" ); - - str.MaximumLength = str.Length; - len = 0xdeadbeef; - status = pNtQuerySymbolicLinkObject( dir, &str, &len ); - ok( status == STATUS_BUFFER_TOO_SMALL, "NtQuerySymbolicLinkObject failed %08x\n", status ); - ok( len == full_len, "bad length %u/%u\n", len, full_len ); - - str.MaximumLength = 0; - len = 0xdeadbeef; - status = pNtQuerySymbolicLinkObject( dir, &str, &len ); - ok( status == STATUS_BUFFER_TOO_SMALL, "NtQuerySymbolicLinkObject failed %08x\n", status ); - ok( len == full_len, "bad length %u/%u\n", len, full_len ); - - str.MaximumLength = str.Length + sizeof(WCHAR); - len = 0xdeadbeef; - status = pNtQuerySymbolicLinkObject( dir, &str, &len ); - ok( status == STATUS_SUCCESS, "NtQuerySymbolicLinkObject failed %08x\n", status ); - ok( len == full_len, "bad length %u/%u\n", len, full_len ); - -error: - pNtClose(dir); - } + + ok(status == STATUS_SUCCESS, "Failed to open SymbolicLink(%08x)\n", status); + pRtlFreeUnicodeString(&str); + InitializeObjectAttributes(&attr, &str, 0, dir, NULL); + pRtlCreateUnicodeStringFromAsciiz(&str, "one more level"); + status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); + ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtCreateDirectoryObject got %08x\n", status ); + pRtlFreeUnicodeString(&str); + + pRtlCreateUnicodeStringFromAsciiz( &str, "\BaseNamedObjects\Local\om.c-test" ); + InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); + status = pNtCreateDirectoryObject( &dir1, DIRECTORY_QUERY, &attr ); + ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); + pRtlFreeUnicodeString( &str ); + pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-test" ); + InitializeObjectAttributes( &attr, &str, 0, dir, NULL ); + status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); + ok( status == STATUS_OBJECT_TYPE_MISMATCH, "Failed to open directory %08x\n", status ); + pRtlFreeUnicodeString( &str ); + + pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-event" ); + InitializeObjectAttributes( &attr, &str, 0, dir1, NULL ); + status = pNtCreateEvent( &h, GENERIC_ALL, &attr, 1, 0 ); + ok( status == STATUS_SUCCESS, "NtCreateEvent failed %x\n", status ); + status = pNtOpenEvent( &h2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS, "NtOpenEvent failed %x\n", status ); + pNtClose( h2 ); + pRtlFreeUnicodeString( &str ); + pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-test\om.c-event" ); + InitializeObjectAttributes( &attr, &str, 0, dir, NULL ); + status = pNtOpenEvent( &h2, GENERIC_ALL, &attr ); + ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtOpenEvent failed %x\n", status ); + pRtlFreeUnicodeString( &str ); + pRtlCreateUnicodeStringFromAsciiz( &str, "\BasedNamedObjects\Local\om.c-test\om.c-event" ); + InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); + status = pNtOpenEvent( &h2, GENERIC_ALL, &attr ); + ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "NtOpenEvent failed %x\n", status ); + pRtlFreeUnicodeString( &str ); + pNtClose( h ); + pNtClose( dir1 ); + + str.Buffer = buffer; + str.MaximumLength = sizeof(buffer); + len = 0xdeadbeef; + memset( buffer, 0xaa, sizeof(buffer) ); + status = pNtQuerySymbolicLinkObject( dir, &str, &len ); + ok( status == STATUS_SUCCESS, "NtQuerySymbolicLinkObject failed %08x\n", status ); + full_len = str.Length + sizeof(WCHAR); + ok( len == full_len, "bad length %u/%u\n", len, full_len ); + ok( buffer[len / sizeof(WCHAR) - 1] == 0, "no terminating null\n" ); + + str.MaximumLength = str.Length; + len = 0xdeadbeef; + status = pNtQuerySymbolicLinkObject( dir, &str, &len ); + ok( status == STATUS_BUFFER_TOO_SMALL, "NtQuerySymbolicLinkObject failed %08x\n", status ); + ok( len == full_len, "bad length %u/%u\n", len, full_len ); + + str.MaximumLength = 0; + len = 0xdeadbeef; + status = pNtQuerySymbolicLinkObject( dir, &str, &len ); + ok( status == STATUS_BUFFER_TOO_SMALL, "NtQuerySymbolicLinkObject failed %08x\n", status ); + ok( len == full_len, "bad length %u/%u\n", len, full_len ); + + str.MaximumLength = str.Length + sizeof(WCHAR); + len = 0xdeadbeef; + status = pNtQuerySymbolicLinkObject( dir, &str, &len ); + ok( status == STATUS_SUCCESS, "NtQuerySymbolicLinkObject failed %08x\n", status ); + ok( len == full_len, "bad length %u/%u\n", len, full_len ); + + pNtClose(dir);
pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); @@ -1091,26 +1057,23 @@ error:
pNtClose(dir);
- if (!is_nt4) - { - InitializeObjectAttributes(&attr, &str, 0, 0, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\Global\om.c-test"); - status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); - ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString(&str); - pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\Local\om.c-test\one more level"); - status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); - ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString(&str); - pNtClose(h); - InitializeObjectAttributes(&attr, &str, 0, dir, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "one more level"); - status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); - ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString(&str); - pNtClose(h); - pNtClose(dir); - } + InitializeObjectAttributes(&attr, &str, 0, 0, NULL); + pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\Global\om.c-test"); + status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); + ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); + pRtlFreeUnicodeString(&str); + pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\Local\om.c-test\one more level"); + status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); + ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); + pRtlFreeUnicodeString(&str); + pNtClose(h); + InitializeObjectAttributes(&attr, &str, 0, dir, NULL); + pRtlCreateUnicodeStringFromAsciiz(&str, "one more level"); + status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); + ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); + pRtlFreeUnicodeString(&str); + pNtClose(h); + pNtClose(dir);
/* Create other objects using RootDirectory */
@@ -1160,11 +1123,9 @@ static void test_symboliclink(void) InitializeObjectAttributes(&attr, NULL, 0, 0, NULL); pRtlCreateUnicodeStringFromAsciiz(&target, "\DosDevices"); status = pNtCreateSymbolicLinkObject( NULL, SYMBOLIC_LINK_QUERY, &attr, &target ); - ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_PARAMETER, - "NtCreateSymbolicLinkObject got %08x\n", status ); + ok(status == STATUS_ACCESS_VIOLATION, "got %#x\n", status); status = pNtOpenSymbolicLinkObject( NULL, SYMBOLIC_LINK_QUERY, &attr ); - ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_PARAMETER, - "NtOpenSymbolicLinkObject got %08x\n", status ); + ok(status == STATUS_ACCESS_VIOLATION, "got %#x\n", status);
status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL, NULL); ok(status == STATUS_ACCESS_VIOLATION, @@ -1178,14 +1139,10 @@ static void test_symboliclink(void) ok(status == STATUS_SUCCESS || status == STATUS_ACCESS_VIOLATION, /* nt4 */ "NtCreateSymbolicLinkObject failed(%08x)\n", status); pRtlFreeUnicodeString(&target); - if (!status) pNtClose(h);
InitializeObjectAttributes(&attr, NULL, 0, 0, NULL); status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target); - ok(status == STATUS_INVALID_PARAMETER || - broken(status == STATUS_SUCCESS), /* nt4 */ - "NtCreateSymbolicLinkObject should have failed with STATUS_INVALID_PARAMETER got(%08x)\n", status); - if (!status) pNtClose(h); + ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status); status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr); ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenSymbolicLinkObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08x)\n", status); @@ -1242,21 +1199,14 @@ static void test_symboliclink(void)
pRtlCreateUnicodeStringFromAsciiz( &str, "\BaseNamedObjects\om.c-test\" ); status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target ); - ok( status == STATUS_OBJECT_NAME_INVALID || status == STATUS_OBJECT_PATH_NOT_FOUND, - "NtCreateSymbolicLinkObject got %08x\n", status ); + ok( status == STATUS_OBJECT_NAME_INVALID, "got %#x\n", status ); status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr ); - ok( status == STATUS_OBJECT_NAME_INVALID || status == STATUS_OBJECT_PATH_NOT_FOUND, - "NtOpenSymbolicLinkObject got %08x\n", status ); + ok( status == STATUS_OBJECT_NAME_INVALID, "got %#x\n", status ); pRtlFreeUnicodeString( &str ); pRtlFreeUnicodeString(&target);
/* Compound test */ - if (!(dir = get_base_dir())) - { - win_skip( "couldn't find the BaseNamedObjects dir\n" ); - return; - } - + dir = get_base_dir(); InitializeObjectAttributes(&attr, &str, 0, dir, NULL); pRtlCreateUnicodeStringFromAsciiz(&str, "test-link"); pRtlCreateUnicodeStringFromAsciiz(&target, "\DosDevices"); @@ -1285,7 +1235,7 @@ static void _test_file_info(unsigned line, HANDLE handle) NTSTATUS status;
status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), 0xdeadbeef); - ok_(__FILE__,line)(status == STATUS_INVALID_INFO_CLASS || status == STATUS_NOT_IMPLEMENTED, + ok_(__FILE__,line)(status == STATUS_INVALID_INFO_CLASS || status == STATUS_NOT_IMPLEMENTED /* Vista+ */, "expected STATUS_NOT_IMPLEMENTED, got %x\n", status);
status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), FileAccessInformation); @@ -1293,7 +1243,7 @@ static void _test_file_info(unsigned line, HANDLE handle)
status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), FileIoCompletionNotificationInformation); - ok_(__FILE__,line)(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS), + ok_(__FILE__,line)(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */, "FileIoCompletionNotificationInformation returned %x\n", status); }
@@ -1305,7 +1255,7 @@ static void _test_no_file_info(unsigned line, HANDLE handle) NTSTATUS status;
status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), 0xdeadbeef); - ok_(__FILE__,line)(status == STATUS_INVALID_INFO_CLASS || status == STATUS_NOT_IMPLEMENTED, + ok_(__FILE__,line)(status == STATUS_INVALID_INFO_CLASS || status == STATUS_NOT_IMPLEMENTED /* Vista+ */, "expected STATUS_NOT_IMPLEMENTED, got %x\n", status);
status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), FileAccessInformation); @@ -1314,7 +1264,7 @@ static void _test_no_file_info(unsigned line, HANDLE handle)
status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), FileIoCompletionNotificationInformation); - ok_(__FILE__,line)(status == STATUS_OBJECT_TYPE_MISMATCH || broken(status == STATUS_INVALID_INFO_CLASS), + ok_(__FILE__,line)(status == STATUS_OBJECT_TYPE_MISMATCH || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */, "FileIoCompletionNotificationInformation returned %x\n", status); }
@@ -1432,24 +1382,19 @@ static void test_query_object(void) ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len ); str = (UNICODE_STRING *)buffer; expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR); - ok( len == expected_len || broken(len == expected_len - sizeof(WCHAR)), /* NT4 */ - "unexpected len %u\n", len ); + ok( len == expected_len, "unexpected len %u\n", len ); trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
len = 0; status = pNtQueryObject( handle, ObjectNameInformation, buffer, 0, &len ); - ok( status == STATUS_INFO_LENGTH_MISMATCH || broken(status == STATUS_INSUFFICIENT_RESOURCES), - "NtQueryObject failed %x\n", status ); - ok( len == expected_len || broken(!len || len == sizeof(UNICODE_STRING)), + ok( status == STATUS_INFO_LENGTH_MISMATCH, "got %#x\n", status ); + ok( len == expected_len || broken(!len /* XP */ || len == sizeof(UNICODE_STRING) /* 2003 */), "unexpected len %u\n", len );
len = 0; status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(UNICODE_STRING), &len ); - ok( status == STATUS_BUFFER_OVERFLOW || broken(status == STATUS_INSUFFICIENT_RESOURCES - || status == STATUS_INFO_LENGTH_MISMATCH), - "NtQueryObject failed %x\n", status ); - ok( len == expected_len || broken(!len), - "unexpected len %u\n", len ); + ok( status == STATUS_BUFFER_OVERFLOW, "got %#x\n", status); + ok( len == expected_len, "unexpected len %u\n", len );
test_object_type( handle, "File" );
@@ -1498,8 +1443,7 @@ static void test_query_object(void) ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len ); str = (UNICODE_STRING *)buffer; expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR); - ok( len == expected_len || broken(len == expected_len - sizeof(WCHAR)), /* NT4 */ - "unexpected len %u\n", len ); + ok( len == expected_len, "unexpected len %u\n", len ); ok( len > sizeof(UNICODE_STRING) + sizeof("\test_mailslot") * sizeof(WCHAR), "name too short %s\n", wine_dbgstr_w(str->Buffer) ); trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len ); @@ -1521,8 +1465,7 @@ static void test_query_object(void) str = (UNICODE_STRING *)buffer; expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR); todo_wine - ok( len == expected_len || broken(len == expected_len - sizeof(WCHAR)), /* NT4 */ - "unexpected len %u\n", len ); + ok( len == expected_len, "unexpected len %u\n", len ); todo_wine ok( len > sizeof(UNICODE_STRING) + sizeof("\test_pipe") * sizeof(WCHAR), "name too short %s\n", wine_dbgstr_w(str->Buffer) ); @@ -1542,29 +1485,25 @@ static void test_query_object(void) pNtClose( handle );
pRtlCreateUnicodeStringFromAsciiz( &path, "\REGISTRY\Machine\Software\Classes" ); - status = pNtCreateKey( &handle, KEY_ALL_ACCESS, &attr, 0, 0, 0, 0 ); - ok( status == STATUS_SUCCESS || status == STATUS_ACCESS_DENIED, - "NtCreateKey failed status %x\n", status ); + status = pNtCreateKey( &handle, KEY_READ, &attr, 0, 0, 0, 0 ); + ok( status == STATUS_SUCCESS, "NtCreateKey failed status %x\n", status ); pRtlFreeUnicodeString( &path ); - if (status == STATUS_SUCCESS) - { - len = 0; - status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len ); - ok( status == STATUS_SUCCESS , "NtQueryObject returned %x\n", status ); - str = (UNICODE_STRING *)buffer; - todo_wine - ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len ); - str = (UNICODE_STRING *)buffer; - expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR); - todo_wine - ok( len == expected_len || broken(len == expected_len - sizeof(WCHAR)), /* NT4 */ - "unexpected len %u\n", len ); - todo_wine - ok( len > sizeof(UNICODE_STRING) + sizeof("\Classes") * sizeof(WCHAR), - "name too short %s\n", wine_dbgstr_w(str->Buffer) ); - trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len ); - pNtClose( handle ); - } + + len = 0; + status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len ); + ok( status == STATUS_SUCCESS , "NtQueryObject returned %x\n", status ); + str = (UNICODE_STRING *)buffer; + todo_wine + ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len ); + str = (UNICODE_STRING *)buffer; + expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR); + ok( len == expected_len || len == expected_len - sizeof(WCHAR) /* wow64 */, "unexpected len %u\n", len ); + todo_wine + ok( len > sizeof(UNICODE_STRING) + sizeof("\Classes") * sizeof(WCHAR), + "name too short %s\n", wine_dbgstr_w(str->Buffer) ); + trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len ); + pNtClose( handle ); + pRtlFreeUnicodeString( &session );
test_object_type( GetCurrentProcess(), "Process" ); @@ -1853,7 +1792,7 @@ static void test_keyed_events(void) ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtPulseEvent %x\n", status );
status = pNtCreateEvent( &event, GENERIC_ALL, &attr, FALSE, FALSE ); - ok( status == STATUS_OBJECT_NAME_COLLISION || status == STATUS_OBJECT_TYPE_MISMATCH, + ok( status == STATUS_OBJECT_NAME_COLLISION || status == STATUS_OBJECT_TYPE_MISMATCH /* 7+ */, "CreateEvent %x\n", status );
NtClose( handle ); @@ -1911,34 +1850,15 @@ static void test_null_device(void) num_bytes = 0xdeadbeef; SetLastError(0xdeadbeef); ret = WriteFile(null, buf, sizeof(buf), &num_bytes, &ov); - if (ret || GetLastError() != ERROR_IO_PENDING) - { - ok(ret, "WriteFile failed with error %u\n", GetLastError()); - } - else - { - num_bytes = 0xdeadbeef; - ret = GetOverlappedResult(null, &ov, &num_bytes, TRUE); - ok(ret, "GetOverlappedResult failed with error %u\n", GetLastError()); - } + ok(ret, "got error %u\n", GetLastError()); ok(num_bytes == sizeof(buf), "expected num_bytes = %u, got %u\n", (DWORD)sizeof(buf), num_bytes);
num_bytes = 0xdeadbeef; SetLastError(0xdeadbeef); ret = ReadFile(null, buf, sizeof(buf), &num_bytes, &ov); - if (ret || GetLastError() != ERROR_IO_PENDING) - { - ok(!ret, "ReadFile unexpectedly succeeded\n"); - } - else - { - num_bytes = 0xdeadbeef; - ret = GetOverlappedResult(null, &ov, &num_bytes, TRUE); - ok(!ret, "GetOverlappedResult unexpectedly succeeded\n"); - } - ok(GetLastError() == ERROR_HANDLE_EOF, - "expected ERROR_HANDLE_EOF, got %u\n", GetLastError()); + ok(!ret, "expected failure\n"); + ok(GetLastError() == ERROR_HANDLE_EOF, "got error %u\n", GetLastError());
pNtClose(null);
@@ -2151,15 +2071,6 @@ static void test_wait_on_address(void) START_TEST(om) { HMODULE hntdll = GetModuleHandleA("ntdll.dll"); - HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); - - if (!hntdll) - { - skip("not running on NT, skipping test\n"); - return; - } - - pCreateWaitableTimerA = (void *)GetProcAddress(hkernel32, "CreateWaitableTimerA");
pRtlCreateUnicodeStringFromAsciiz = (void *)GetProcAddress(hntdll, "RtlCreateUnicodeStringFromAsciiz"); pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/om.c | 53 ++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c index 5d7e4007853..313fb1160a7 100644 --- a/dlls/ntdll/tests/om.c +++ b/dlls/ntdll/tests/om.c @@ -199,18 +199,25 @@ static void test_namespace_pipe(void) #define DIRECTORY_QUERY (0x0001) #define SYMBOLIC_LINK_QUERY 0x0001
-#define DIR_TEST_CREATE_OPEN(n,e) \ - do { \ - HANDLE h; \ - pRtlCreateUnicodeStringFromAsciiz(&str, n); \ - status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); \ - ok( status == e, "NtCreateDirectoryObject(%s) got %08x\n", n, status ); \ - if (!status) pNtClose( h ); \ - status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); \ - ok( status == e, "NtOpenDirectoryObject(%s) got %08x\n", n, status ); \ - if (!status) pNtClose( h ); \ - pRtlFreeUnicodeString(&str); \ - } while(0) +#define check_create_open_dir(parent, name, status) check_create_open_dir_(__LINE__, parent, name, status) +static void check_create_open_dir_( int line, HANDLE parent, const char *name, NTSTATUS expect ) +{ + OBJECT_ATTRIBUTES attr; + UNICODE_STRING str; + NTSTATUS status; + HANDLE h; + + pRtlCreateUnicodeStringFromAsciiz( &str, name ); + InitializeObjectAttributes( &attr, &str, 0, parent, NULL ); + status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); + ok_(__FILE__, line)( status == expect, "NtCreateDirectoryObject(%s) got %08x\n", debugstr_a(name), status ); + if (!status) pNtClose( h ); + + status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); + ok_(__FILE__, line)( status == expect, "NtOpenDirectoryObject(%s) got %08x\n", debugstr_a(name), status ); + if (!status) pNtClose( h ); + pRtlFreeUnicodeString( &str ); +}
static BOOL is_correct_dir( HANDLE dir, const char *name ) { @@ -906,11 +913,11 @@ static void test_directory(void) pRtlFreeUnicodeString(&str); pNtClose(dir);
- DIR_TEST_CREATE_OPEN( "BaseNamedObjects", STATUS_OBJECT_PATH_SYNTAX_BAD ); - DIR_TEST_CREATE_OPEN( "\BaseNamedObjects\", STATUS_OBJECT_NAME_INVALID ); - DIR_TEST_CREATE_OPEN( "\\BaseNamedObjects", STATUS_OBJECT_NAME_INVALID ); - DIR_TEST_CREATE_OPEN( "\BaseNamedObjects\\om.c-test", STATUS_OBJECT_NAME_INVALID ); - DIR_TEST_CREATE_OPEN( "\BaseNamedObjects\om.c-test\", STATUS_OBJECT_PATH_NOT_FOUND ); + check_create_open_dir( NULL, "BaseNamedObjects", STATUS_OBJECT_PATH_SYNTAX_BAD ); + check_create_open_dir( NULL, "\BaseNamedObjects\", STATUS_OBJECT_NAME_INVALID ); + check_create_open_dir( NULL, "\\BaseNamedObjects", STATUS_OBJECT_NAME_INVALID ); + check_create_open_dir( NULL, "\BaseNamedObjects\\om.c-test", STATUS_OBJECT_NAME_INVALID ); + check_create_open_dir( NULL, "\BaseNamedObjects\om.c-test\", STATUS_OBJECT_PATH_NOT_FOUND );
pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\om.c-test"); status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); @@ -1009,13 +1016,13 @@ static void test_directory(void) status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenDirectoryObject got %08x\n", status );
- InitializeObjectAttributes(&attr, &str, 0, dir, NULL); - DIR_TEST_CREATE_OPEN( "", STATUS_SUCCESS ); - DIR_TEST_CREATE_OPEN( "\", STATUS_OBJECT_PATH_SYNTAX_BAD ); - DIR_TEST_CREATE_OPEN( "\om.c-test", STATUS_OBJECT_PATH_SYNTAX_BAD ); - DIR_TEST_CREATE_OPEN( "\om.c-test\", STATUS_OBJECT_PATH_SYNTAX_BAD ); - DIR_TEST_CREATE_OPEN( "om.c-test\", STATUS_OBJECT_PATH_NOT_FOUND ); + check_create_open_dir( dir, "", STATUS_SUCCESS ); + check_create_open_dir( dir, "\", STATUS_OBJECT_PATH_SYNTAX_BAD ); + check_create_open_dir( dir, "\om.c-test", STATUS_OBJECT_PATH_SYNTAX_BAD ); + check_create_open_dir( dir, "\om.c-test\", STATUS_OBJECT_PATH_SYNTAX_BAD ); + check_create_open_dir( dir, "om.c-test\", STATUS_OBJECT_PATH_NOT_FOUND );
+ InitializeObjectAttributes(&attr, &str, 0, dir, NULL); pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-test"); status = pNtCreateDirectoryObject( &dir1, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/om.c | 308 ++++++++++++++++-------------------------- 1 file changed, 119 insertions(+), 189 deletions(-)
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c index 313fb1160a7..03d97b2143b 100644 --- a/dlls/ntdll/tests/om.c +++ b/dlls/ntdll/tests/om.c @@ -25,9 +25,7 @@ #include "winnt.h" #include "stdlib.h"
-static BOOLEAN (WINAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING, LPCSTR); static VOID (WINAPI *pRtlInitUnicodeString)( PUNICODE_STRING, LPCWSTR ); -static VOID (WINAPI *pRtlFreeUnicodeString)(PUNICODE_STRING); static NTSTATUS (WINAPI *pNtCreateEvent) ( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES, BOOLEAN, BOOLEAN); static NTSTATUS (WINAPI *pNtOpenEvent) ( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES); static NTSTATUS (WINAPI *pNtPulseEvent) ( HANDLE, PLONG ); @@ -82,16 +80,12 @@ static void (WINAPI *pRtlWakeAddressSingle)( const void * );
static void test_case_sensitive (void) { - static const WCHAR buffer1[] = {'\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\','t','e','s','t',0}; - static const WCHAR buffer2[] = {'\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\','T','e','s','t',0}; - static const WCHAR buffer3[] = {'\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\','T','E','s','t',0}; - static const WCHAR buffer4[] = {'\','B','A','S','E','N','a','m','e','d','O','b','j','e','c','t','s','\','t','e','s','t',0}; NTSTATUS status; OBJECT_ATTRIBUTES attr; UNICODE_STRING str; HANDLE Event, Mutant, h;
- pRtlInitUnicodeString(&str, buffer1); + pRtlInitUnicodeString(&str, L"\BaseNamedObjects\test"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE); ok(status == STATUS_SUCCESS, "Failed to create Mutant(%08x)\n", status); @@ -99,12 +93,12 @@ static void test_case_sensitive (void) status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, FALSE, FALSE); ok(status == STATUS_OBJECT_NAME_COLLISION || status == STATUS_OBJECT_TYPE_MISMATCH /* Vista+ */, "got %#x\n", status);
- pRtlInitUnicodeString(&str, buffer2); + pRtlInitUnicodeString(&str, L"\BaseNamedObjects\Test"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, FALSE, FALSE); ok(status == STATUS_SUCCESS, "Failed to create Event(%08x)\n", status);
- pRtlInitUnicodeString(&str, buffer3); + pRtlInitUnicodeString(&str, L"\BaseNamedObjects\TEst"); InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL); status = pNtOpenMutant(&h, GENERIC_ALL, &attr); ok(status == STATUS_OBJECT_TYPE_MISMATCH, @@ -112,7 +106,7 @@ static void test_case_sensitive (void)
pNtClose(Mutant);
- pRtlInitUnicodeString(&str, buffer4); + pRtlInitUnicodeString(&str, L"\BASENamedObjects\test"); InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL); status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE); ok(status == STATUS_OBJECT_NAME_COLLISION || status == STATUS_OBJECT_TYPE_MISMATCH /* Vista+ */, "got %#x\n", status); @@ -131,10 +125,6 @@ static void test_case_sensitive (void)
static void test_namespace_pipe(void) { - static const WCHAR buffer1[] = {'\','?','?','\','P','I','P','E','\','t','e','s','t','\','p','i','p','e',0}; - static const WCHAR buffer2[] = {'\','?','?','\','P','I','P','E','\','T','E','S','T','\','P','I','P','E',0}; - static const WCHAR buffer3[] = {'\','?','?','\','p','i','p','e','\','t','e','s','t','\','p','i','p','e',0}; - static const WCHAR buffer4[] = {'\','?','?','\','p','i','p','e','\','t','e','s','t',0}; OBJECT_ATTRIBUTES attr; UNICODE_STRING str; IO_STATUS_BLOCK iosb; @@ -144,7 +134,7 @@ static void test_namespace_pipe(void)
timeout.QuadPart = -10000;
- pRtlInitUnicodeString(&str, buffer1); + pRtlInitUnicodeString(&str, L"\??\PIPE\test\pipe"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtCreateNamedPipeFile(&pipe, GENERIC_READ|GENERIC_WRITE, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_CREATE, FILE_PIPE_FULL_DUPLEX, FALSE, FALSE, FALSE, 1, 256, 256, &timeout); @@ -155,7 +145,7 @@ static void test_namespace_pipe(void) ok(status == STATUS_INSTANCE_NOT_AVAILABLE, "NtCreateNamedPipeFile should have failed with STATUS_INSTANCE_NOT_AVAILABLE got(%08x)\n", status);
- pRtlInitUnicodeString(&str, buffer2); + pRtlInitUnicodeString(&str, L"\??\PIPE\TEST\PIPE"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtCreateNamedPipeFile(&pipe, GENERIC_READ|GENERIC_WRITE, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_CREATE, FILE_PIPE_FULL_DUPLEX, FALSE, FALSE, FALSE, 1, 256, 256, &timeout); @@ -167,7 +157,7 @@ static void test_namespace_pipe(void) ok(h != INVALID_HANDLE_VALUE, "Failed to open NamedPipe (%u)\n", GetLastError()); pNtClose(h);
- pRtlInitUnicodeString(&str, buffer3); + pRtlInitUnicodeString(&str, L"\??\pipe\test\pipe"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtOpenFile(&h, GENERIC_READ, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, 0); ok(status == STATUS_OBJECT_PATH_NOT_FOUND || @@ -176,7 +166,7 @@ static void test_namespace_pipe(void) status == STATUS_OBJECT_NAME_NOT_FOUND, /* win8 */ "NtOpenFile should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08x)\n", status);
- pRtlInitUnicodeString(&str, buffer4); + pRtlInitUnicodeString(&str, L"\??\pipe\test"); InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL); status = pNtOpenFile(&h, GENERIC_READ, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, 0); ok(status == STATUS_OBJECT_NAME_NOT_FOUND || @@ -200,36 +190,34 @@ static void test_namespace_pipe(void) #define SYMBOLIC_LINK_QUERY 0x0001
#define check_create_open_dir(parent, name, status) check_create_open_dir_(__LINE__, parent, name, status) -static void check_create_open_dir_( int line, HANDLE parent, const char *name, NTSTATUS expect ) +static void check_create_open_dir_( int line, HANDLE parent, const WCHAR *name, NTSTATUS expect ) { OBJECT_ATTRIBUTES attr; UNICODE_STRING str; NTSTATUS status; HANDLE h;
- pRtlCreateUnicodeStringFromAsciiz( &str, name ); + RtlInitUnicodeString( &str, name ); InitializeObjectAttributes( &attr, &str, 0, parent, NULL ); status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); - ok_(__FILE__, line)( status == expect, "NtCreateDirectoryObject(%s) got %08x\n", debugstr_a(name), status ); + ok_(__FILE__, line)( status == expect, "NtCreateDirectoryObject(%s) got %08x\n", debugstr_w(name), status ); if (!status) pNtClose( h );
status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); - ok_(__FILE__, line)( status == expect, "NtOpenDirectoryObject(%s) got %08x\n", debugstr_a(name), status ); + ok_(__FILE__, line)( status == expect, "NtOpenDirectoryObject(%s) got %08x\n", debugstr_w(name), status ); if (!status) pNtClose( h ); - pRtlFreeUnicodeString( &str ); }
-static BOOL is_correct_dir( HANDLE dir, const char *name ) +static BOOL is_correct_dir( HANDLE dir, const WCHAR *name ) { NTSTATUS status; UNICODE_STRING str; OBJECT_ATTRIBUTES attr; HANDLE h = 0;
- pRtlCreateUnicodeStringFromAsciiz(&str, name); + RtlInitUnicodeString( &str, name ); InitializeObjectAttributes(&attr, &str, OBJ_OPENIF, dir, NULL); status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE); - pRtlFreeUnicodeString(&str); if (h) pNtClose( h ); return (status == STATUS_OBJECT_NAME_EXISTS); } @@ -237,23 +225,22 @@ static BOOL is_correct_dir( HANDLE dir, const char *name ) /* return a handle to the BaseNamedObjects dir where kernel32 objects get created */ static HANDLE get_base_dir(void) { - static const char objname[] = "om.c_get_base_dir_obj"; + static const WCHAR objname[] = L"om.c_get_base_dir_obj"; NTSTATUS status; UNICODE_STRING str; OBJECT_ATTRIBUTES attr; HANDLE dir, h; - char name[40]; + WCHAR name[40];
- h = CreateMutexA(NULL, FALSE, objname); + h = CreateMutexW( NULL, FALSE, objname ); ok(h != 0, "CreateMutexA failed got ret=%p (%d)\n", h, GetLastError()); InitializeObjectAttributes(&attr, &str, OBJ_OPENIF, 0, NULL);
- sprintf( name, "\BaseNamedObjects\Session\%u", NtCurrentTeb()->Peb->SessionId ); - pRtlCreateUnicodeStringFromAsciiz(&str, name ); + swprintf( name, ARRAY_SIZE(name), L"\BaseNamedObjects\Session\%u", NtCurrentTeb()->Peb->SessionId ); + RtlInitUnicodeString( &str, name ); status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr); ok(!status, "got %#x\n", status); ok(is_correct_dir( dir, objname ), "wrong dir\n"); - pRtlFreeUnicodeString(&str);
pNtClose( h ); return dir; @@ -269,7 +256,7 @@ static void test_name_collisions(void) LARGE_INTEGER size;
InitializeObjectAttributes(&attr, &str, 0, 0, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "\"); + RtlInitUnicodeString(&str, L"\"); status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_OBJECT_NAME_COLLISION, "NtCreateDirectoryObject got %08x\n", status ); InitializeObjectAttributes(&attr, &str, OBJ_OPENIF, 0, NULL); @@ -280,15 +267,13 @@ static void test_name_collisions(void) status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE); ok(status == STATUS_OBJECT_TYPE_MISMATCH, "NtCreateMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08x)\n", status); - pRtlFreeUnicodeString(&str);
- pRtlCreateUnicodeStringFromAsciiz(&str, "\??\PIPE\om.c-mutant"); + RtlInitUnicodeString(&str, L"\??\PIPE\om.c-mutant"); status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE); todo_wine ok(status == STATUS_OBJECT_PATH_NOT_FOUND, "got %#x\n", status); - pRtlFreeUnicodeString(&str);
dir = get_base_dir(); - pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-test"); + RtlInitUnicodeString(&str, L"om.c-test"); InitializeObjectAttributes(&attr, &str, OBJ_OPENIF, dir, NULL); h = CreateMutexA(NULL, FALSE, "om.c-test"); ok(h != 0, "CreateMutexA failed got ret=%p (%d)\n", h, GetLastError()); @@ -357,7 +342,6 @@ static void test_name_collisions(void) pNtClose(h1); pNtClose(h2);
- pRtlFreeUnicodeString(&str); pNtClose(dir); }
@@ -369,7 +353,7 @@ static void test_all_kernel_objects( UINT line, OBJECT_ATTRIBUTES *attr, NTSTATUS status, status2; HANDLE ret, ret2;
- pRtlCreateUnicodeStringFromAsciiz( &target, "\DosDevices" ); + RtlInitUnicodeString( &target, L"\DosDevices" ); size.QuadPart = 4096;
status = pNtCreateMutant( &ret, GENERIC_ALL, attr, FALSE ); @@ -432,15 +416,13 @@ static void test_all_kernel_objects( UINT line, OBJECT_ATTRIBUTES *attr, ok( status2 == open_expect, "%u: NtOpenSection failed %x\n", line, status2 ); if (!status) pNtClose( ret ); if (!status2) pNtClose( ret2 ); - pRtlFreeUnicodeString( &target ); }
static void test_name_limits(void) { - static const WCHAR localW[] = {'\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\','L','o','c','a','l',0}; - static const WCHAR pipeW[] = {'\','D','e','v','i','c','e','\','N','a','m','e','d','P','i','p','e','\'}; - static const WCHAR mailslotW[] = {'\','D','e','v','i','c','e','\','M','a','i','l','S','l','o','t','\'}; - static const WCHAR registryW[] = {'\','R','E','G','I','S','T','R','Y','\','M','a','c','h','i','n','e','\','S','O','F','T','W','A','R','E','\','M','i','c','r','o','s','o','f','t','\'}; + static const WCHAR pipeW[] = L"\Device\NamedPipe\"; + static const WCHAR mailslotW[] = L"\Device\MailSlot\"; + static const WCHAR registryW[] = L"\REGISTRY\Machine\SOFTWARE\Microsoft\"; OBJECT_ATTRIBUTES attr, attr2, attr3; IO_STATUS_BLOCK iosb; LARGE_INTEGER size, timeout; @@ -456,7 +438,7 @@ static void test_name_limits(void) str.MaximumLength = 65534; for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i] = 'a'; size.QuadPart = 4096; - pRtlCreateUnicodeStringFromAsciiz( &target, "\DosDevices" ); + RtlInitUnicodeString( &target, L"\DosDevices" );
attr.RootDirectory = get_base_dir(); str.Length = 0; @@ -579,7 +561,7 @@ static void test_name_limits(void) test_all_kernel_objects( __LINE__, &attr3, STATUS_SUCCESS, STATUS_OBJECT_PATH_SYNTAX_BAD );
attr3.ObjectName = &str2; - pRtlInitUnicodeString( &str2, localW ); + pRtlInitUnicodeString( &str2, L"\BaseNamedObjects\Local" ); status = pNtOpenSymbolicLinkObject( &ret, SYMBOLIC_LINK_QUERY, &attr3 ); ok( status == STATUS_SUCCESS, "can't open BaseNamedObjects\Local %x\n", status ); attr3.ObjectName = &str; @@ -641,8 +623,8 @@ static void test_name_limits(void) attr2.ObjectName = attr3.ObjectName = &str;
/* named pipes */ - memcpy( str.Buffer, pipeW, sizeof(pipeW) ); - for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + ARRAY_SIZE(pipeW)] = 'a'; + wcscpy( str.Buffer, pipeW ); + for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + wcslen( pipeW )] = 'a'; str.Length = 0; attr.RootDirectory = 0; attr.Attributes = OBJ_CASE_INSENSITIVE; @@ -694,8 +676,8 @@ static void test_name_limits(void) attr2.ObjectName = attr3.ObjectName = &str;
/* mailslots */ - memcpy( str.Buffer, mailslotW, sizeof(mailslotW) ); - for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + ARRAY_SIZE(mailslotW)] = 'a'; + wcscpy( str.Buffer, mailslotW ); + for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + wcslen( mailslotW )] = 'a'; str.Length = 0; status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateMailslotFile failed %x\n", str.Length, status ); @@ -735,8 +717,8 @@ static void test_name_limits(void) attr2.ObjectName = attr3.ObjectName = &str;
/* registry keys */ - memcpy( str.Buffer, registryW, sizeof(registryW) ); - for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + ARRAY_SIZE(registryW)] = 'a'; + wcscpy( str.Buffer, registryW ); + for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + wcslen(registryW)] = 'a'; str.Length = 0; status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); todo_wine @@ -745,7 +727,7 @@ static void test_name_limits(void) ok( status == STATUS_INVALID_HANDLE, "%u: NtCreateKey failed %x\n", str.Length, status ); status = pNtOpenKey( &ret, GENERIC_ALL, &attr2 ); ok( status == STATUS_INVALID_HANDLE, "%u: NtOpenKey failed %x\n", str.Length, status ); - str.Length = sizeof(registryW) + 250 * sizeof(WCHAR) + 1; + str.Length = (wcslen( registryW ) + 250) * sizeof(WCHAR) + 1; status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); ok( status == STATUS_OBJECT_NAME_INVALID || status == STATUS_INVALID_PARAMETER || @@ -756,7 +738,7 @@ static void test_name_limits(void) pNtDeleteKey( ret ); pNtClose( ret ); } - str.Length = sizeof(registryW) + 256 * sizeof(WCHAR); + str.Length = (wcslen( registryW ) + 256) * sizeof(WCHAR); status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); ok( status == STATUS_SUCCESS || status == STATUS_ACCESS_DENIED, "%u: NtCreateKey failed %x\n", str.Length, status ); @@ -773,7 +755,7 @@ static void test_name_limits(void) pNtDeleteKey( ret ); pNtClose( ret );
- str.Length = sizeof(registryW) + 256 * sizeof(WCHAR); + str.Length = (wcslen( registryW ) + 256) * sizeof(WCHAR); for (attr.Length = 0; attr.Length <= 2 * sizeof(attr); attr.Length++) { if (attr.Length == sizeof(attr)) @@ -796,7 +778,7 @@ static void test_name_limits(void) } attr.Length = sizeof(attr); } - str.Length = sizeof(registryW) + 256 * sizeof(WCHAR) + 1; + str.Length = (wcslen( registryW ) + 256) * sizeof(WCHAR) + 1; status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); ok( status == STATUS_OBJECT_NAME_INVALID || status == STATUS_INVALID_PARAMETER || @@ -869,8 +851,7 @@ static void test_name_limits(void) ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenKey failed %x\n", status ); attr2.ObjectName = attr3.ObjectName = &str;
- pRtlFreeUnicodeString( &str ); - pRtlFreeUnicodeString( &target ); + HeapFree( GetProcessHeap(), 0, str.Buffer ); }
static void test_directory(void) @@ -904,27 +885,25 @@ static void test_directory(void) /* Bad name */ InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
- pRtlCreateUnicodeStringFromAsciiz(&str, ""); + RtlInitUnicodeString(&str, L""); status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); pNtClose(h); status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenDirectoryObject got %08x\n", status ); - pRtlFreeUnicodeString(&str); pNtClose(dir);
- check_create_open_dir( NULL, "BaseNamedObjects", STATUS_OBJECT_PATH_SYNTAX_BAD ); - check_create_open_dir( NULL, "\BaseNamedObjects\", STATUS_OBJECT_NAME_INVALID ); - check_create_open_dir( NULL, "\\BaseNamedObjects", STATUS_OBJECT_NAME_INVALID ); - check_create_open_dir( NULL, "\BaseNamedObjects\\om.c-test", STATUS_OBJECT_NAME_INVALID ); - check_create_open_dir( NULL, "\BaseNamedObjects\om.c-test\", STATUS_OBJECT_PATH_NOT_FOUND ); + check_create_open_dir( NULL, L"BaseNamedObjects", STATUS_OBJECT_PATH_SYNTAX_BAD ); + check_create_open_dir( NULL, L"\BaseNamedObjects\", STATUS_OBJECT_NAME_INVALID ); + check_create_open_dir( NULL, L"\\BaseNamedObjects", STATUS_OBJECT_NAME_INVALID ); + check_create_open_dir( NULL, L"\BaseNamedObjects\\om.c-test", STATUS_OBJECT_NAME_INVALID ); + check_create_open_dir( NULL, L"\BaseNamedObjects\om.c-test\", STATUS_OBJECT_PATH_NOT_FOUND );
- pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\om.c-test"); + RtlInitUnicodeString(&str, L"\BaseNamedObjects\om.c-test"); status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); status = pNtOpenDirectoryObject( &dir1, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status ); - pRtlFreeUnicodeString(&str); pNtClose(h); pNtClose(dir1);
@@ -932,47 +911,40 @@ static void test_directory(void) /* Use of root directory */
/* Can't use symlinks as a directory */ - pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\Local"); + RtlInitUnicodeString(&str, L"\BaseNamedObjects\Local"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtOpenSymbolicLinkObject(&dir, SYMBOLIC_LINK_QUERY, &attr);
ok(status == STATUS_SUCCESS, "Failed to open SymbolicLink(%08x)\n", status); - pRtlFreeUnicodeString(&str); InitializeObjectAttributes(&attr, &str, 0, dir, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "one more level"); + RtlInitUnicodeString(&str, L"one more level"); status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtCreateDirectoryObject got %08x\n", status ); - pRtlFreeUnicodeString(&str);
- pRtlCreateUnicodeStringFromAsciiz( &str, "\BaseNamedObjects\Local\om.c-test" ); + RtlInitUnicodeString( &str, L"\BaseNamedObjects\Local\om.c-test" ); InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); status = pNtCreateDirectoryObject( &dir1, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString( &str ); - pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-test" ); + RtlInitUnicodeString( &str, L"om.c-test" ); InitializeObjectAttributes( &attr, &str, 0, dir, NULL ); status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "Failed to open directory %08x\n", status ); - pRtlFreeUnicodeString( &str );
- pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-event" ); + RtlInitUnicodeString( &str, L"om.c-event" ); InitializeObjectAttributes( &attr, &str, 0, dir1, NULL ); status = pNtCreateEvent( &h, GENERIC_ALL, &attr, 1, 0 ); ok( status == STATUS_SUCCESS, "NtCreateEvent failed %x\n", status ); status = pNtOpenEvent( &h2, GENERIC_ALL, &attr ); ok( status == STATUS_SUCCESS, "NtOpenEvent failed %x\n", status ); pNtClose( h2 ); - pRtlFreeUnicodeString( &str ); - pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-test\om.c-event" ); + RtlInitUnicodeString( &str, L"om.c-test\om.c-event" ); InitializeObjectAttributes( &attr, &str, 0, dir, NULL ); status = pNtOpenEvent( &h2, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtOpenEvent failed %x\n", status ); - pRtlFreeUnicodeString( &str ); - pRtlCreateUnicodeStringFromAsciiz( &str, "\BasedNamedObjects\Local\om.c-test\om.c-event" ); + RtlInitUnicodeString( &str, L"\BasedNamedObjects\Local\om.c-test\om.c-event" ); InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); status = pNtOpenEvent( &h2, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "NtOpenEvent failed %x\n", status ); - pRtlFreeUnicodeString( &str ); pNtClose( h ); pNtClose( dir1 );
@@ -1006,113 +978,99 @@ static void test_directory(void)
pNtClose(dir);
- pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects"); + RtlInitUnicodeString(&str, L"\BaseNamedObjects"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtOpenDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status ); - pRtlFreeUnicodeString(&str);
InitializeObjectAttributes(&attr, NULL, 0, dir, NULL); status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenDirectoryObject got %08x\n", status );
- check_create_open_dir( dir, "", STATUS_SUCCESS ); - check_create_open_dir( dir, "\", STATUS_OBJECT_PATH_SYNTAX_BAD ); - check_create_open_dir( dir, "\om.c-test", STATUS_OBJECT_PATH_SYNTAX_BAD ); - check_create_open_dir( dir, "\om.c-test\", STATUS_OBJECT_PATH_SYNTAX_BAD ); - check_create_open_dir( dir, "om.c-test\", STATUS_OBJECT_PATH_NOT_FOUND ); + check_create_open_dir( dir, L"", STATUS_SUCCESS ); + check_create_open_dir( dir, L"\", STATUS_OBJECT_PATH_SYNTAX_BAD ); + check_create_open_dir( dir, L"\om.c-test", STATUS_OBJECT_PATH_SYNTAX_BAD ); + check_create_open_dir( dir, L"\om.c-test\", STATUS_OBJECT_PATH_SYNTAX_BAD ); + check_create_open_dir( dir, L"om.c-test\", STATUS_OBJECT_PATH_NOT_FOUND );
InitializeObjectAttributes(&attr, &str, 0, dir, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-test"); + RtlInitUnicodeString(&str, L"om.c-test"); status = pNtCreateDirectoryObject( &dir1, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status ); - pRtlFreeUnicodeString(&str);
pNtClose(h); pNtClose(dir1); pNtClose(dir);
/* Nested directories */ - pRtlCreateUnicodeStringFromAsciiz(&str, "\"); + RtlInitUnicodeString(&str, L"\"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtOpenDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status ); InitializeObjectAttributes(&attr, &str, 0, dir, NULL); status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenDirectoryObject got %08x\n", status ); - pRtlFreeUnicodeString(&str); pNtClose(dir);
InitializeObjectAttributes(&attr, &str, 0, 0, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\om.c-test"); + RtlInitUnicodeString(&str, L"\BaseNamedObjects\om.c-test"); status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString(&str); - pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\om.c-test\one more level"); + RtlInitUnicodeString(&str, L"\BaseNamedObjects\om.c-test\one more level"); status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString(&str); pNtClose(h); InitializeObjectAttributes(&attr, &str, 0, dir, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "one more level"); + RtlInitUnicodeString(&str, L"one more level"); status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString(&str); pNtClose(h);
pNtClose(dir);
InitializeObjectAttributes(&attr, &str, 0, 0, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\Global\om.c-test"); + RtlInitUnicodeString(&str, L"\BaseNamedObjects\Global\om.c-test"); status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString(&str); - pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects\Local\om.c-test\one more level"); + RtlInitUnicodeString(&str, L"\BaseNamedObjects\Local\om.c-test\one more level"); status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString(&str); pNtClose(h); InitializeObjectAttributes(&attr, &str, 0, dir, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "one more level"); + RtlInitUnicodeString(&str, L"one more level"); status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); - pRtlFreeUnicodeString(&str); pNtClose(h); pNtClose(dir);
/* Create other objects using RootDirectory */
InitializeObjectAttributes(&attr, &str, 0, 0, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "\BaseNamedObjects"); + RtlInitUnicodeString(&str, L"\BaseNamedObjects"); status = pNtOpenDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status ); - pRtlFreeUnicodeString(&str); InitializeObjectAttributes(&attr, &str, 0, dir, NULL);
/* Test invalid paths */ - pRtlCreateUnicodeStringFromAsciiz(&str, "\om.c-mutant"); + RtlInitUnicodeString(&str, L"\om.c-mutant"); status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE); ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtCreateMutant should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08x)\n", status); - pRtlFreeUnicodeString(&str); - pRtlCreateUnicodeStringFromAsciiz(&str, "\om.c-mutant\"); + RtlInitUnicodeString(&str, L"\om.c-mutant\"); status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE); ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtCreateMutant should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08x)\n", status); - pRtlFreeUnicodeString(&str);
- pRtlCreateUnicodeStringFromAsciiz(&str, "om.c\-mutant"); + RtlInitUnicodeString(&str, L"om.c\-mutant"); status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE); ok(status == STATUS_OBJECT_PATH_NOT_FOUND, "NtCreateMutant should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08x)\n", status); - pRtlFreeUnicodeString(&str);
- pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-mutant"); + RtlInitUnicodeString(&str, L"om.c-mutant"); status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE); ok(status == STATUS_SUCCESS, "Failed to create Mutant(%08x)\n", status); - pRtlFreeUnicodeString(&str); pNtClose(h);
pNtClose(dir); @@ -1128,7 +1086,7 @@ static void test_symboliclink(void)
/* No name and/or no attributes */ InitializeObjectAttributes(&attr, NULL, 0, 0, NULL); - pRtlCreateUnicodeStringFromAsciiz(&target, "\DosDevices"); + RtlInitUnicodeString(&target, L"\DosDevices"); status = pNtCreateSymbolicLinkObject( NULL, SYMBOLIC_LINK_QUERY, &attr, &target ); ok(status == STATUS_ACCESS_VIOLATION, "got %#x\n", status); status = pNtOpenSymbolicLinkObject( NULL, SYMBOLIC_LINK_QUERY, &attr ); @@ -1145,9 +1103,9 @@ static void test_symboliclink(void) status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL, &target); ok(status == STATUS_SUCCESS || status == STATUS_ACCESS_VIOLATION, /* nt4 */ "NtCreateSymbolicLinkObject failed(%08x)\n", status); - pRtlFreeUnicodeString(&target);
InitializeObjectAttributes(&attr, NULL, 0, 0, NULL); + memset(&target, 0, sizeof(target)); status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target); ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status); status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr); @@ -1155,79 +1113,67 @@ static void test_symboliclink(void) "NtOpenSymbolicLinkObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08x)\n", status);
/* Bad name */ - pRtlCreateUnicodeStringFromAsciiz(&target, "anywhere"); + RtlInitUnicodeString(&target, L"anywhere"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
- pRtlCreateUnicodeStringFromAsciiz(&str, ""); + RtlInitUnicodeString(&str, L""); status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target); ok(status == STATUS_SUCCESS, "Failed to create SymbolicLink(%08x)\n", status); status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr); ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenSymbolicLinkObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08x)\n", status); pNtClose(link); - pRtlFreeUnicodeString(&str);
- pRtlCreateUnicodeStringFromAsciiz(&str, "\"); + RtlInitUnicodeString(&str, L"\"); status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr, &target); todo_wine ok(status == STATUS_OBJECT_TYPE_MISMATCH, "NtCreateSymbolicLinkObject should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08x)\n", status); - pRtlFreeUnicodeString(&str); - pRtlFreeUnicodeString(&target);
- pRtlCreateUnicodeStringFromAsciiz( &target, "->Somewhere"); + RtlInitUnicodeString( &target, L"->Somewhere");
- pRtlCreateUnicodeStringFromAsciiz( &str, "BaseNamedObjects" ); + RtlInitUnicodeString( &str, L"BaseNamedObjects" ); status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtCreateSymbolicLinkObject got %08x\n", status ); status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenSymbolicLinkObject got %08x\n", status ); - pRtlFreeUnicodeString( &str );
- pRtlCreateUnicodeStringFromAsciiz( &str, "\BaseNamedObjects\" ); + RtlInitUnicodeString( &str, L"\BaseNamedObjects\" ); status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target ); ok( status == STATUS_OBJECT_NAME_INVALID, "NtCreateSymbolicLinkObject got %08x\n", status ); status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr ); ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenSymbolicLinkObject got %08x\n", status ); - pRtlFreeUnicodeString( &str );
- pRtlCreateUnicodeStringFromAsciiz( &str, "\\BaseNamedObjects" ); + RtlInitUnicodeString( &str, L"\\BaseNamedObjects" ); status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target ); ok( status == STATUS_OBJECT_NAME_INVALID, "NtCreateSymbolicLinkObject got %08x\n", status ); status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr ); ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenSymbolicLinkObject got %08x\n", status ); - pRtlFreeUnicodeString( &str );
- pRtlCreateUnicodeStringFromAsciiz( &str, "\BaseNamedObjects\\om.c-test" ); + RtlInitUnicodeString( &str, L"\BaseNamedObjects\\om.c-test" ); status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target ); ok( status == STATUS_OBJECT_NAME_INVALID, "NtCreateSymbolicLinkObject got %08x\n", status ); status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr ); ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenSymbolicLinkObject got %08x\n", status ); - pRtlFreeUnicodeString( &str );
- pRtlCreateUnicodeStringFromAsciiz( &str, "\BaseNamedObjects\om.c-test\" ); + RtlInitUnicodeString( &str, L"\BaseNamedObjects\om.c-test\" ); status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target ); ok( status == STATUS_OBJECT_NAME_INVALID, "got %#x\n", status ); status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr ); ok( status == STATUS_OBJECT_NAME_INVALID, "got %#x\n", status ); - pRtlFreeUnicodeString( &str ); - pRtlFreeUnicodeString(&target);
/* Compound test */ dir = get_base_dir(); InitializeObjectAttributes(&attr, &str, 0, dir, NULL); - pRtlCreateUnicodeStringFromAsciiz(&str, "test-link"); - pRtlCreateUnicodeStringFromAsciiz(&target, "\DosDevices"); + RtlInitUnicodeString(&str, L"test-link"); + RtlInitUnicodeString(&target, L"\DosDevices"); status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target); ok(status == STATUS_SUCCESS, "Failed to create SymbolicLink(%08x)\n", status); - pRtlFreeUnicodeString(&str); - pRtlFreeUnicodeString(&target);
- pRtlCreateUnicodeStringFromAsciiz(&str, "test-link\NUL"); + RtlInitUnicodeString(&str, L"test-link\NUL"); status = pNtOpenFile(&h, GENERIC_READ, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, 0); ok(status == STATUS_SUCCESS, "Failed to open NUL device(%08x)\n", status); status = pNtOpenFile(&h, GENERIC_READ, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_DIRECTORY_FILE); ok(status == STATUS_SUCCESS, "Failed to open NUL device(%08x)\n", status); - pRtlFreeUnicodeString(&str);
pNtClose(h); pNtClose(link); @@ -1276,14 +1222,14 @@ static void _test_no_file_info(unsigned line, HANDLE handle) }
#define test_object_type(a,b) _test_object_type(__LINE__,a,b) -static void _test_object_type(unsigned line, HANDLE handle, const char *expected_name) +static void _test_object_type( unsigned line, HANDLE handle, const WCHAR *expected_name ) { char buffer[1024]; UNICODE_STRING *str = (UNICODE_STRING *)buffer, expect; ULONG len = 0; NTSTATUS status;
- pRtlCreateUnicodeStringFromAsciiz( &expect, expected_name ); + RtlInitUnicodeString( &expect, expected_name );
memset( buffer, 0, sizeof(buffer) ); status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len ); @@ -1292,27 +1238,22 @@ static void _test_object_type(unsigned line, HANDLE handle, const char *expected ok_(__FILE__,line)( len >= sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR), "unexpected len %u\n", len ); ok_(__FILE__,line)( str->Length == expect.Length && !memcmp( str->Buffer, expect.Buffer, expect.Length ), "wrong/bad type name %s (%p)\n", wine_dbgstr_w(str->Buffer), str->Buffer ); - - pRtlFreeUnicodeString( &expect ); }
static void test_query_object(void) { - static const WCHAR name[] = {'\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s', - '\','t','e','s','t','_','e','v','e','n','t'}; - static const WCHAR type_event[] = {'E','v','e','n','t'}; + static const WCHAR name[] = L"\BaseNamedObjects\test_event"; HANDLE handle, client; char buffer[1024]; NTSTATUS status; ULONG len, expected_len; OBJECT_ATTRIBUTES attr; - UNICODE_STRING path, session, *str; + UNICODE_STRING path, *str; char dir[MAX_PATH], tmp_path[MAX_PATH], file1[MAX_PATH + 16]; + WCHAR expect[100]; LARGE_INTEGER size; BOOL ret;
- sprintf( tmp_path, "\Sessions\%u", NtCurrentTeb()->Peb->SessionId ); - pRtlCreateUnicodeStringFromAsciiz( &session, tmp_path ); InitializeObjectAttributes( &attr, &path, 0, 0, 0 );
handle = CreateEventA( NULL, FALSE, FALSE, "test_event" ); @@ -1320,22 +1261,22 @@ static void test_query_object(void) len = 0; status = pNtQueryObject( handle, ObjectNameInformation, buffer, 0, &len ); ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); - ok( len >= sizeof(UNICODE_STRING) + sizeof(name) + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( len >= sizeof(UNICODE_STRING) + sizeof(name), "unexpected len %u\n", len );
len = 0; status = pNtQueryObject( handle, ObjectTypeInformation, buffer, 0, &len ); ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); - ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(L"Event"), "unexpected len %u\n", len );
len = 0; status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(UNICODE_STRING), &len ); ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); - ok( len >= sizeof(UNICODE_STRING) + sizeof(name) + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( len >= sizeof(UNICODE_STRING) + sizeof(name), "unexpected len %u\n", len );
len = 0; status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(OBJECT_TYPE_INFORMATION), &len ); ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); - ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(L"Event"), "unexpected len %u\n", len );
len = 0; status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len ); @@ -1343,28 +1284,27 @@ static void test_query_object(void) ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len ); str = (UNICODE_STRING *)buffer; ok( sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR) == len, "unexpected len %u\n", len ); - ok( str->Length >= sizeof(name), "unexpected len %u\n", str->Length ); + ok( str->Length >= sizeof(name) - sizeof(WCHAR), "unexpected len %u\n", str->Length ); ok( len > sizeof(UNICODE_STRING) + sizeof("\test_event") * sizeof(WCHAR), "name too short %s\n", wine_dbgstr_w(str->Buffer) ); /* check for \Sessions prefix in the name */ - ok( (str->Length > session.Length && - !memcmp( str->Buffer, session.Buffer, session.Length ) && - !memcmp( str->Buffer + session.Length / sizeof(WCHAR), name, sizeof(name) )) || - broken( !memcmp( str->Buffer, name, sizeof(name) )), /* winxp */ + swprintf( expect, ARRAY_SIZE(expect), L"\Sessions\%u%s", NtCurrentTeb()->Peb->SessionId, name ); + ok( (str->Length == wcslen( expect ) * sizeof(WCHAR) && !wcscmp( str->Buffer, expect )) || + broken( !wcscmp( str->Buffer, name )), /* winxp */ "wrong name %s\n", wine_dbgstr_w(str->Buffer) ); trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
len -= sizeof(WCHAR); status = pNtQueryObject( handle, ObjectNameInformation, buffer, len, &len ); ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); - ok( len >= sizeof(UNICODE_STRING) + sizeof(name) + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( len >= sizeof(UNICODE_STRING) + sizeof(name), "unexpected len %u\n", len );
- test_object_type( handle, "Event" ); + test_object_type( handle, L"Event" );
len -= sizeof(WCHAR); status = pNtQueryObject( handle, ObjectTypeInformation, buffer, len, &len ); ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); - ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(L"Event"), "unexpected len %u\n", len );
test_no_file_info( handle ); pNtClose( handle ); @@ -1403,14 +1343,14 @@ static void test_query_object(void) ok( status == STATUS_BUFFER_OVERFLOW, "got %#x\n", status); ok( len == expected_len, "unexpected len %u\n", len );
- test_object_type( handle, "File" ); + test_object_type( handle, L"File" );
pNtClose( handle );
GetTempPathA(MAX_PATH, tmp_path); GetTempFileNameA(tmp_path, "foo", 0, file1); handle = CreateFileA(file1, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0); - test_object_type(handle, "File"); + test_object_type(handle, L"File"); DeleteFileA( file1 ); test_file_info( handle ); pNtClose( handle ); @@ -1418,7 +1358,7 @@ static void test_query_object(void) status = pNtCreateIoCompletion( &handle, IO_COMPLETION_ALL_ACCESS, NULL, 0 ); ok( status == STATUS_SUCCESS, "NtCreateIoCompletion failed %x\n", status);
- test_object_type( handle, "IoCompletion" ); + test_object_type( handle, L"IoCompletion" ); test_no_file_info( handle );
pNtClose( handle ); @@ -1426,7 +1366,7 @@ static void test_query_object(void) status = pNtCreateDirectoryObject( &handle, DIRECTORY_QUERY, NULL ); ok(status == STATUS_SUCCESS, "Failed to create Directory %08x\n", status);
- test_object_type( handle, "Directory" ); + test_object_type( handle, L"Directory" ); test_no_file_info( handle );
pNtClose( handle ); @@ -1436,7 +1376,7 @@ static void test_query_object(void) status = pNtCreateSection( &handle, SECTION_MAP_WRITE, NULL, &size, PAGE_READWRITE, SEC_COMMIT, 0 ); ok( status == STATUS_SUCCESS , "NtCreateSection returned %x\n", status );
- test_object_type( handle, "Section" ); + test_object_type( handle, L"Section" ); test_no_file_info( handle );
pNtClose( handle ); @@ -1455,7 +1395,7 @@ static void test_query_object(void) "name too short %s\n", wine_dbgstr_w(str->Buffer) ); trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
- test_object_type( handle, "File" ); + test_object_type( handle, L"File" ); test_file_info( handle );
pNtClose( handle ); @@ -1478,23 +1418,22 @@ static void test_query_object(void) "name too short %s\n", wine_dbgstr_w(str->Buffer) ); trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
- test_object_type( handle, "File" ); + test_object_type( handle, L"File" ); test_file_info( handle );
client = CreateFileA( "\\.\pipe\test_pipe", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 ); ok( client != INVALID_HANDLE_VALUE, "CreateFile failed (%d)\n", GetLastError() );
- test_object_type( client, "File" ); + test_object_type( client, L"File" ); test_file_info( client );
pNtClose( client ); pNtClose( handle );
- pRtlCreateUnicodeStringFromAsciiz( &path, "\REGISTRY\Machine\Software\Classes" ); + RtlInitUnicodeString( &path, L"\REGISTRY\Machine\Software\Classes" ); status = pNtCreateKey( &handle, KEY_READ, &attr, 0, 0, 0, 0 ); ok( status == STATUS_SUCCESS, "NtCreateKey failed status %x\n", status ); - pRtlFreeUnicodeString( &path );
len = 0; status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len ); @@ -1511,18 +1450,16 @@ static void test_query_object(void) trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len ); pNtClose( handle );
- pRtlFreeUnicodeString( &session ); - - test_object_type( GetCurrentProcess(), "Process" ); + test_object_type( GetCurrentProcess(), L"Process" ); test_no_file_info( GetCurrentProcess() );
- test_object_type( GetCurrentThread(), "Thread" ); + test_object_type( GetCurrentThread(), L"Thread" ); test_no_file_info( GetCurrentThread() );
ret = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &handle); ok(ret, "OpenProcessToken failed: %u\n", GetLastError());
- test_object_type( handle, "Token" ); + test_object_type( handle, L"Token" ); test_no_file_info( handle );
pNtClose(handle); @@ -1560,9 +1497,8 @@ static void test_event(void) UNICODE_STRING str; OBJECT_ATTRIBUTES attr; EVENT_BASIC_INFORMATION info; - static const WCHAR eventName[] = {'\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\','t','e','s','t','E','v','e','n','t',0};
- pRtlInitUnicodeString(&str, eventName); + pRtlInitUnicodeString( &str, L"\BaseNamedObjects\testEvent" ); InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, 1, 0); @@ -1619,8 +1555,7 @@ static void test_event(void) pNtClose(Event); }
-static const WCHAR keyed_nameW[] = {'\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s', - '\','W','i','n','e','T','e','s','t','E','v','e','n','t',0}; +static const WCHAR keyed_nameW[] = L"\BaseNamedObjects\WineTestEvent";
static DWORD WINAPI keyed_event_thread( void *arg ) { @@ -1829,7 +1764,7 @@ static void test_null_device(void) memset(&ov, 0, sizeof(ov)); ov.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
- pRtlCreateUnicodeStringFromAsciiz(&str, "\Device\Null"); + RtlInitUnicodeString(&str, L"\Device\Null"); InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL); status = pNtOpenSymbolicLinkObject(&null, SYMBOLIC_LINK_QUERY, &attr); ok(status == STATUS_OBJECT_TYPE_MISMATCH, @@ -1840,7 +1775,7 @@ static void test_null_device(void) ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
- test_object_type(null, "File"); + test_object_type(null, L"File");
SetLastError(0xdeadbeef); ret = WriteFile(null, buf, sizeof(buf), &num_bytes, NULL); @@ -1883,7 +1818,6 @@ static void test_null_device(void) ok(GetLastError() == ERROR_PATH_NOT_FOUND, "expected ERROR_PATH_NOT_FOUND, got %u\n", GetLastError());
- pRtlFreeUnicodeString(&str); CloseHandle(ov.hEvent); }
@@ -1911,8 +1845,6 @@ static DWORD WINAPI mutant_thread( void *arg )
static void test_mutant(void) { - static const WCHAR name[] = {'\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s', - '\','t','e','s','t','_','m','u','t','a','n','t',0}; MUTANT_BASIC_INFORMATION info; OBJECT_ATTRIBUTES attr; UNICODE_STRING str; @@ -1923,7 +1855,7 @@ static void test_mutant(void) ULONG len; LONG prev;
- pRtlInitUnicodeString(&str, name); + pRtlInitUnicodeString(&str, L"\BaseNamedObjects\test_mutant"); InitializeObjectAttributes(&attr, &str, 0, 0, NULL); status = pNtCreateMutant(&mutant, GENERIC_ALL, &attr, TRUE); ok( status == STATUS_SUCCESS, "Failed to create Mutant(%08x)\n", status ); @@ -2079,8 +2011,6 @@ START_TEST(om) { HMODULE hntdll = GetModuleHandleA("ntdll.dll");
- pRtlCreateUnicodeStringFromAsciiz = (void *)GetProcAddress(hntdll, "RtlCreateUnicodeStringFromAsciiz"); - pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString"); pNtCreateEvent = (void *)GetProcAddress(hntdll, "NtCreateEvent"); pNtCreateJobObject = (void *)GetProcAddress(hntdll, "NtCreateJobObject"); pNtOpenJobObject = (void *)GetProcAddress(hntdll, "NtOpenJobObject");
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/om.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c index 03d97b2143b..f68827c7180 100644 --- a/dlls/ntdll/tests/om.c +++ b/dlls/ntdll/tests/om.c @@ -1040,7 +1040,7 @@ static void test_directory(void) pNtClose(h); InitializeObjectAttributes(&attr, &str, 0, dir, NULL); RtlInitUnicodeString(&str, L"one more level"); - status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr ); + status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status ); pNtClose(h); pNtClose(dir); @@ -1157,9 +1157,9 @@ static void test_symboliclink(void)
RtlInitUnicodeString( &str, L"\BaseNamedObjects\om.c-test\" ); status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target ); - ok( status == STATUS_OBJECT_NAME_INVALID, "got %#x\n", status ); + ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "got %#x\n", status ); status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr ); - ok( status == STATUS_OBJECT_NAME_INVALID, "got %#x\n", status ); + ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "got %#x\n", status );
/* Compound test */ dir = get_base_dir();