diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index d5475917536..43b74b2ebf1 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -218,11 +218,12 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT if (io->u.Status == STATUS_SUCCESS) { + static UNICODE_STRING empty_string; OBJECT_ATTRIBUTES unix_attr = *attr; data_size_t len; struct object_attributes *objattr; - unix_attr.ObjectName = NULL; /* we send the unix name instead */ + unix_attr.ObjectName = &empty_string; /* we send the unix name instead */ if ((io->u.Status = alloc_object_attributes( &unix_attr, &objattr, &len ))) { RtlFreeAnsiString( &unix_name ); diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c index 81885ebd0e0..c6eb28d1f77 100644 --- a/dlls/ntdll/reg.c +++ b/dlls/ntdll/reg.c @@ -128,7 +128,7 @@ NTSTATUS WINAPI NtOpenKeyEx( PHANDLE retkey, ACCESS_MASK access, const OBJECT_AT { NTSTATUS ret; - if (!retkey || !attr) return STATUS_ACCESS_VIOLATION; + if (!retkey || !attr || !attr->ObjectName) return STATUS_ACCESS_VIOLATION; if (attr->Length > sizeof(OBJECT_ATTRIBUTES)) return STATUS_INVALID_PARAMETER; TRACE( "(%p,%s,%x,%p)\n", attr->RootDirectory, debugstr_us(attr->ObjectName), access, retkey ); diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index 47b27d3c293..0902c615deb 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -110,6 +110,7 @@ NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_a if (attr->ObjectName->Length & (sizeof(WCHAR) - 1)) return STATUS_OBJECT_NAME_INVALID; len += attr->ObjectName->Length; } + else if (attr->RootDirectory) return STATUS_OBJECT_NAME_INVALID; *ret = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, len ); if (!*ret) return STATUS_NO_MEMORY; @@ -197,8 +198,6 @@ NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle, DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; NTSTATUS ret; - if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG; - SERVER_START_REQ( open_semaphore ) { req->access = access; @@ -307,8 +306,6 @@ NTSTATUS WINAPI NtOpenEvent( DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; NTSTATUS ret; - if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG; - SERVER_START_REQ( open_event ) { req->access = DesiredAccess; @@ -474,8 +471,6 @@ NTSTATUS WINAPI NtOpenMutant(OUT HANDLE* MutantHandle, NTSTATUS status; DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; - if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG; - SERVER_START_REQ( open_mutex ) { req->access = access; @@ -780,8 +775,6 @@ NTSTATUS WINAPI NtOpenTimer(OUT PHANDLE handle, DWORD len = (attr && attr->ObjectName) ? attr->ObjectName->Length : 0; NTSTATUS status; - if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG; - SERVER_START_REQ( open_timer ) { req->access = access; @@ -1090,8 +1083,6 @@ NTSTATUS WINAPI NtOpenKeyedEvent( HANDLE *handle, ACCESS_MASK access, const OBJE DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; NTSTATUS ret; - if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG; - SERVER_START_REQ( open_keyed_event ) { req->access = access; diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c index 8a62cd327c9..646a61f73bb 100644 --- a/dlls/ntdll/tests/om.c +++ b/dlls/ntdll/tests/om.c @@ -34,17 +34,22 @@ static NTSTATUS (WINAPI *pNtOpenEvent) ( PHANDLE, ACCESS_MASK, const POBJECT_A static NTSTATUS (WINAPI *pNtPulseEvent) ( HANDLE, PULONG ); static NTSTATUS (WINAPI *pNtQueryEvent) ( HANDLE, EVENT_INFORMATION_CLASS, PVOID, ULONG, PULONG ); static NTSTATUS (WINAPI *pNtCreateJobObject)( PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES ); +static NTSTATUS (WINAPI *pNtOpenJobObject)( PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES ); static NTSTATUS (WINAPI *pNtCreateKey)( PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, ULONG, const UNICODE_STRING *, ULONG, PULONG ); +static NTSTATUS (WINAPI *pNtOpenKey)( PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES ); static NTSTATUS (WINAPI *pNtDeleteKey)( HANDLE ); static NTSTATUS (WINAPI *pNtCreateMailslotFile)( PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK, ULONG, ULONG, ULONG, PLARGE_INTEGER ); static NTSTATUS (WINAPI *pNtCreateMutant)( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES, BOOLEAN ); static NTSTATUS (WINAPI *pNtOpenMutant) ( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES ); static NTSTATUS (WINAPI *pNtCreateSemaphore)( PHANDLE, ACCESS_MASK,const POBJECT_ATTRIBUTES,LONG,LONG ); +static NTSTATUS (WINAPI *pNtOpenSemaphore)( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES ); static NTSTATUS (WINAPI *pNtCreateTimer) ( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES, TIMER_TYPE ); +static NTSTATUS (WINAPI *pNtOpenTimer)( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES ); static NTSTATUS (WINAPI *pNtCreateSection)( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES, const PLARGE_INTEGER, ULONG, ULONG, HANDLE ); +static NTSTATUS (WINAPI *pNtOpenSection)( PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES ); static NTSTATUS (WINAPI *pNtOpenFile) ( PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK, ULONG, ULONG ); static NTSTATUS (WINAPI *pNtClose) ( HANDLE ); static NTSTATUS (WINAPI *pNtCreateNamedPipeFile)( PHANDLE, ULONG, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK, @@ -61,6 +66,7 @@ static NTSTATUS (WINAPI *pNtOpenKeyedEvent)( HANDLE *, ACCESS_MASK, const OBJECT static NTSTATUS (WINAPI *pNtWaitForKeyedEvent)( HANDLE, const void *, BOOLEAN, const LARGE_INTEGER * ); static NTSTATUS (WINAPI *pNtReleaseKeyedEvent)( HANDLE, const void *, BOOLEAN, const LARGE_INTEGER * ); static NTSTATUS (WINAPI *pNtCreateIoCompletion)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, ULONG); +static NTSTATUS (WINAPI *pNtOpenIoCompletion)( PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES ); #define KEYEDEVENT_WAIT 0x0001 #define KEYEDEVENT_WAKE 0x0002 @@ -367,18 +373,22 @@ static void test_name_limits(void) 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','\\'}; - OBJECT_ATTRIBUTES attr; + OBJECT_ATTRIBUTES attr, attr2, attr3; IO_STATUS_BLOCK iosb; LARGE_INTEGER size, timeout; UNICODE_STRING str, target; NTSTATUS status; - HANDLE ret; + HANDLE ret, ret2; DWORD i; InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); + InitializeObjectAttributes( &attr2, &str, 0, (HANDLE)0xdeadbeef, NULL ); + InitializeObjectAttributes( &attr3, &str, 0, 0, NULL ); str.Buffer = HeapAlloc( GetProcessHeap(), 0, 65536 + sizeof(registryW)); str.MaximumLength = 65534; for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i] = 'a'; + size.QuadPart = 4096; + pRtlCreateUnicodeStringFromAsciiz( &target, "\\DosDevices" ); if (!(attr.RootDirectory = get_base_dir())) { @@ -386,95 +396,411 @@ static void test_name_limits(void) return; } + str.Length = 0; + status = pNtCreateMutant( &ret, GENERIC_ALL, &attr2, FALSE ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateMutant failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + 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 ); + todo_wine + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + "%u: NtOpenMutant failed %x\n", str.Length, status ); + pNtClose( ret ); + status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr2, 1, 2 ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateSemaphore failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + 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 ); + todo_wine + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + "%u: NtOpenSemaphore failed %x\n", str.Length, status ); + pNtClose( ret ); + status = pNtCreateEvent( &ret, GENERIC_ALL, &attr2, 1, 0 ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateEvent failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + 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 ); + todo_wine + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + "%u: NtOpenEvent failed %x\n", str.Length, status ); + pNtClose( ret ); + status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr2, 0 ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateKeyedEvent failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + 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 ); + todo_wine + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + "%u: NtOpenKeyedEvent failed %x\n", str.Length, status ); + pNtClose( ret ); + status = pNtCreateTimer( &ret, GENERIC_ALL, &attr2, NotificationTimer ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateTimer failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + 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 ); + todo_wine + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + "%u: NtOpenTimer failed %x\n", str.Length, status ); + pNtClose( ret ); + status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr2, 0 ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateCompletion failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + 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 ); + todo_wine + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + "%u: NtOpenCompletion failed %x\n", str.Length, status ); + pNtClose( ret ); + status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateJobObject failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + status = pNtOpenJobObject( &ret2, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenJobObject failed %x\n", str.Length, status ); + status = pNtOpenJobObject( &ret2, GENERIC_ALL, &attr3 ); + todo_wine + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + "%u: NtOpenJobObject failed %x\n", str.Length, status ); + pNtClose( ret ); + status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateDirectoryObject failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + status = pNtOpenDirectoryObject( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS || broken(status == STATUS_ACCESS_DENIED), /* winxp */ + "%u: NtOpenDirectoryObject failed %x\n", str.Length, status ); + if (!status) pNtClose( ret2 ); + status = pNtOpenDirectoryObject( &ret2, GENERIC_ALL, &attr3 ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtOpenDirectoryObject failed %x\n", str.Length, status ); + pNtClose( ret2 ); + pNtClose( ret ); + status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr2, &target ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateSymbolicLinkObject failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + status = pNtOpenSymbolicLinkObject( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenSymbolicLinkObject failed %x\n", str.Length, status ); + status = pNtOpenSymbolicLinkObject( &ret2, GENERIC_ALL, &attr3 ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtOpenSymbolicLinkObject failed %x\n", str.Length, status ); + pNtClose( ret2 ); + pNtClose( ret ); + status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr2, &size, PAGE_READWRITE, SEC_COMMIT, 0 ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtCreateSection failed %x\n", str.Length, status ); + attr3.RootDirectory = ret; + 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 ); + todo_wine + ok( status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, + "%u: NtOpenSection failed %x\n", str.Length, status ); + pNtClose( ret ); + str.Length = 67; - status = pNtCreateMutant( &ret, GENERIC_ALL, &attr, FALSE ); + status = pNtCreateMutant( &ret, GENERIC_ALL, &attr2, FALSE ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMutant failed %x\n", str.Length, status ); - status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr, 1, 2 ); + status = pNtOpenMutant( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenMutant failed %x\n", str.Length, status ); + status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr2, 1, 2 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSemaphore failed %x\n", str.Length, status ); - status = pNtCreateEvent( &ret, GENERIC_ALL, &attr, 1, 0 ); + status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSemaphore failed %x\n", str.Length, status ); + status = pNtCreateEvent( &ret, GENERIC_ALL, &attr2, 1, 0 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateEvent failed %x\n", str.Length, status ); - status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr, 0 ); + status = pNtOpenEvent( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenEvent failed %x\n", str.Length, status ); + status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr2, 0 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateKeyedEvent failed %x\n", str.Length, status ); - status = pNtCreateTimer( &ret, GENERIC_ALL, &attr, NotificationTimer ); + status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenKeyedEvent failed %x\n", str.Length, status ); + status = pNtCreateTimer( &ret, GENERIC_ALL, &attr2, NotificationTimer ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateTimer failed %x\n", str.Length, status ); - status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr, 0 ); + status = pNtOpenTimer( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenTimer failed %x\n", str.Length, status ); + status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr2, 0 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateCompletion failed %x\n", str.Length, status ); - status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr ); + status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenCompletion failed %x\n", str.Length, status ); + status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateJobObject failed %x\n", str.Length, status ); - status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr ); + status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenJobObject failed %x\n", str.Length, status ); + status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr2 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateDirectoryObject failed %x\n", str.Length, status ); - pRtlCreateUnicodeStringFromAsciiz( &target, "\\DosDevices" ); - status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr, &target ); + status = pNtOpenDirectoryObject( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenDirectoryObject failed %x\n", str.Length, status ); + status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr2, &target ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSymbolicLinkObject failed %x\n", str.Length, status ); - size.QuadPart = 4096; - status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 ); + status = pNtOpenSymbolicLinkObject( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSymbolicLinkObject failed %x\n", str.Length, status ); + status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr2, &size, PAGE_READWRITE, SEC_COMMIT, 0 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSection failed %x\n", str.Length, status ); + status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSection failed %x\n", str.Length, status ); str.Length = 65532; status = pNtCreateMutant( &ret, GENERIC_ALL, &attr, FALSE ); ok( status == STATUS_SUCCESS, "%u: NtCreateMutant failed %x\n", str.Length, status ); + status = pNtOpenMutant( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS, "%u: NtOpenMutant failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr, 1, 2 ); ok( status == STATUS_SUCCESS, "%u: NtCreateSemaphore failed %x\n", str.Length, status ); + status = pNtOpenSemaphore( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS, "%u: NtOpenSemaphore failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); status = pNtCreateEvent( &ret, GENERIC_ALL, &attr, 1, 0 ); ok( status == STATUS_SUCCESS, "%u: NtCreateEvent failed %x\n", str.Length, status ); + status = pNtOpenEvent( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS, "%u: NtOpenEvent failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr, 0 ); ok( status == STATUS_SUCCESS, "%u: NtCreateKeyedEvent failed %x\n", str.Length, status ); + status = pNtOpenKeyedEvent( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS, "%u: NtOpenKeyedEvent failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); status = pNtCreateTimer( &ret, GENERIC_ALL, &attr, NotificationTimer ); ok( status == STATUS_SUCCESS, "%u: NtCreateTimer failed %x\n", str.Length, status ); + status = pNtOpenTimer( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS, "%u: NtOpenTimer failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr, 0 ); ok( status == STATUS_SUCCESS, "%u: NtCreateCompletion failed %x\n", str.Length, status ); + status = pNtOpenIoCompletion( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS, "%u: NtOpenCompletion failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr ); ok( status == STATUS_SUCCESS, "%u: NtCreateJobObject failed %x\n", str.Length, status ); + status = pNtOpenJobObject( &ret2, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtOpenJobObject failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr ); ok( status == STATUS_SUCCESS, "%u: NtCreateDirectoryObject failed %x\n", str.Length, status ); + status = pNtOpenDirectoryObject( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS, "%u: NtOpenDirectoryObject failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr, &target ); ok( status == STATUS_SUCCESS, "%u: NtCreateSymbolicLinkObject failed %x\n", str.Length, status ); + status = pNtOpenSymbolicLinkObject( &ret2, GENERIC_ALL, &attr ); + ok( status == STATUS_SUCCESS, "%u: NtOpenSymbolicLinkObject failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); - size.QuadPart = 4096; status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 ); ok( status == STATUS_SUCCESS, "%u: NtCreateSection failed %x\n", str.Length, status ); + status = pNtOpenSection( &ret2, SECTION_MAP_WRITE, &attr ); + todo_wine + ok( status == STATUS_SUCCESS, "%u: NtOpenSection failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtClose( ret ); str.Length = 65534; status = pNtCreateMutant( &ret, GENERIC_ALL, &attr, FALSE ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMutant failed %x\n", str.Length, status ); + status = pNtOpenMutant( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenMutant failed %x\n", str.Length, status ); status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr, 1, 2 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSemaphore failed %x\n", str.Length, status ); + status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSemaphore failed %x\n", str.Length, status ); status = pNtCreateEvent( &ret, GENERIC_ALL, &attr, 1, 0 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateEvent failed %x\n", str.Length, status ); + status = pNtOpenEvent( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenEvent failed %x\n", str.Length, status ); status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr, 0 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateKeyedEvent failed %x\n", str.Length, status ); + status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenKeyedEvent failed %x\n", str.Length, status ); status = pNtCreateTimer( &ret, GENERIC_ALL, &attr, NotificationTimer ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateTimer failed %x\n", str.Length, status ); + status = pNtOpenTimer( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenTimer failed %x\n", str.Length, status ); status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr, 0 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateCompletion failed %x\n", str.Length, status ); + status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenCompletion failed %x\n", str.Length, status ); status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateJobObject failed %x\n", str.Length, status ); + status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenJobObject failed %x\n", str.Length, status ); status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateDirectoryObject failed %x\n", str.Length, status ); + status = pNtOpenDirectoryObject( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenDirectoryObject failed %x\n", str.Length, status ); status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr, &target ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSymbolicLinkObject failed %x\n", str.Length, status ); - size.QuadPart = 4096; + status = pNtOpenSymbolicLinkObject( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSymbolicLinkObject failed %x\n", str.Length, status ); status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSection failed %x\n", str.Length, status ); + status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSection failed %x\n", str.Length, status ); + + /* null ObjectName, with or without RootDirectory */ + attr3.RootDirectory = 0; + attr2.ObjectName = attr3.ObjectName = NULL; + status = pNtCreateMutant( &ret, GENERIC_ALL, &attr2, FALSE ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateMutant failed %x\n", status ); + status = pNtCreateMutant( &ret, GENERIC_ALL, &attr3, FALSE ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateMutant failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenMutant( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenMutant failed %x\n", status ); + status = pNtOpenMutant( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenMutant failed %x\n", status ); + status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr2, 1, 2 ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateSemaphore failed %x\n", status ); + status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr3, 1, 2 ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateSemaphore failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenSemaphore failed %x\n", status ); + status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenSemaphore failed %x\n", status ); + status = pNtCreateEvent( &ret, GENERIC_ALL, &attr2, 1, 0 ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateEvent failed %x\n", status ); + status = pNtCreateEvent( &ret, GENERIC_ALL, &attr3, 1, 0 ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateEvent failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenEvent( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenEvent failed %x\n", status ); + status = pNtOpenEvent( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenEvent failed %x\n", status ); + status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr2, 0 ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateKeyedEvent failed %x\n", status ); + status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr3, 0 ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateKeyedEvent failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenKeyedEvent failed %x\n", status ); + status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenKeyedEvent failed %x\n", status ); + status = pNtCreateTimer( &ret, GENERIC_ALL, &attr2, NotificationTimer ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateTimer failed %x\n", status ); + status = pNtCreateTimer( &ret, GENERIC_ALL, &attr3, NotificationTimer ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateTimer failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenTimer( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenTimer failed %x\n", status ); + status = pNtOpenTimer( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenTimer failed %x\n", status ); + status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr2, 0 ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateCompletion failed %x\n", status ); + status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr3, 0 ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateCompletion failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenCompletion failed %x\n", status ); + status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr3 ); + todo_wine + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenCompletion failed %x\n", status ); + status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateJobObject failed %x\n", status ); + status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateJobObject failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenJobObject failed %x\n", status ); + status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr3 ); + todo_wine + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenJobObject failed %x\n", status ); + status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr2 ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateDirectoryObject failed %x\n", status ); + status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateDirectoryObject failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenDirectoryObject( &ret, GENERIC_ALL, &attr2 ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenDirectoryObject failed %x\n", status ); + status = pNtOpenDirectoryObject( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenDirectoryObject failed %x\n", status ); + status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr2, &target ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateSymbolicLinkObject failed %x\n", status ); + status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr3, &target ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateSymbolicLinkObject failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenSymbolicLinkObject( &ret, GENERIC_ALL, &attr2 ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenSymbolicLinkObject failed %x\n", status ); + status = pNtOpenSymbolicLinkObject( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenSymbolicLinkObject failed %x\n", status ); + status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr2, &size, PAGE_READWRITE, SEC_COMMIT, 0 ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateSection failed %x\n", status ); + status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr3, &size, PAGE_READWRITE, SEC_COMMIT, 0 ); + ok( status == STATUS_SUCCESS, "NULL: NtCreateSection failed %x\n", status ); + pNtClose( ret ); + status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr2 ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenSection failed %x\n", status ); + status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr3 ); + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenSection failed %x\n", status ); + attr2.ObjectName = attr3.ObjectName = &str; /* named pipes */ memcpy( str.Buffer, pipeW, sizeof(pipeW) ); for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + sizeof(pipeW)/sizeof(WCHAR)] = 'a'; - str.Length = 67; + str.Length = 0; attr.RootDirectory = 0; attr.Attributes = OBJ_CASE_INSENSITIVE; timeout.QuadPart = -10000; status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout ); + todo_wine + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status ); + status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr2, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout ); + ok( status == STATUS_INVALID_HANDLE, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status ); + str.Length = 67; + status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr2, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status ); str.Length = 65532; status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, @@ -485,12 +811,28 @@ static void test_name_limits(void) status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status ); + attr3.RootDirectory = 0; + attr2.ObjectName = attr3.ObjectName = NULL; + status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr2, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout ); + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateNamedPipeFile failed %x\n", status ); + status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr3, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout ); + todo_wine + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtCreateNamedPipeFile failed %x\n", status ); + attr2.ObjectName = attr3.ObjectName = &str; /* mailslots */ memcpy( str.Buffer, mailslotW, sizeof(mailslotW) ); for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + sizeof(mailslotW)/sizeof(WCHAR)] = 'a'; - str.Length = 67; + str.Length = 0; status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL ); + todo_wine + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateMailslotFile failed %x\n", str.Length, status ); + status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr2, &iosb, 0, 0, 0, NULL ); + ok( status == STATUS_INVALID_HANDLE, "%u: NtCreateMailslotFile failed %x\n", str.Length, status ); + str.Length = 67; + status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr2, &iosb, 0, 0, 0, NULL ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMailslotFile failed %x\n", str.Length, status ); str.Length = 65532; status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL ); @@ -499,10 +841,26 @@ static void test_name_limits(void) str.Length = 65534; status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMailslotFile failed %x\n", str.Length, status ); + attr3.RootDirectory = 0; + attr2.ObjectName = attr3.ObjectName = NULL; + status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr2, &iosb, 0, 0, 0, NULL ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateMailslotFile failed %x\n", status ); + status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr3, &iosb, 0, 0, 0, NULL ); + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtCreateMailslotFile failed %x\n", status ); + attr2.ObjectName = attr3.ObjectName = &str; /* registry keys */ memcpy( str.Buffer, registryW, sizeof(registryW) ); for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + sizeof(registryW)/sizeof(WCHAR)] = 'a'; + str.Length = 0; + status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); + todo_wine + ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateKey failed %x\n", str.Length, status ); + status = pNtCreateKey( &ret, GENERIC_ALL, &attr2, 0, NULL, 0, NULL ); + 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; status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); ok( status == STATUS_OBJECT_NAME_INVALID || @@ -520,10 +878,18 @@ static void test_name_limits(void) "%u: NtCreateKey failed %x\n", str.Length, status ); if (!status) { + status = pNtOpenKey( &ret2, KEY_READ, &attr ); + ok( status == STATUS_SUCCESS, "%u: NtOpenKey failed %x\n", str.Length, status ); + pNtClose( ret2 ); + attr3.RootDirectory = ret; + str.Length = 0; + status = pNtOpenKey( &ret2, KEY_READ, &attr3 ); + ok( status == STATUS_SUCCESS, "%u: NtOpenKey failed %x\n", str.Length, status ); + pNtClose( ret2 ); pNtDeleteKey( ret ); pNtClose( ret ); } - str.Length++; + str.Length = sizeof(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 || @@ -534,12 +900,24 @@ static void test_name_limits(void) pNtDeleteKey( ret ); pNtClose( ret ); } + status = pNtOpenKey( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID || + status == STATUS_INVALID_PARAMETER || + broken( status == STATUS_OBJECT_NAME_NOT_FOUND ), /* wow64 */ + "%u: NtOpenKey failed %x\n", str.Length, status ); str.Length++; status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); ok( status == STATUS_INVALID_PARAMETER, "%u: NtCreateKey failed %x\n", str.Length, status ); + status = pNtOpenKey( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_INVALID_PARAMETER, "%u: NtOpenKey failed %x\n", str.Length, status ); str.Length = 2000; status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); ok( status == STATUS_INVALID_PARAMETER, "%u: NtCreateKey failed %x\n", str.Length, status ); + status = pNtOpenKey( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_INVALID_PARAMETER, "%u: NtOpenKey failed %x\n", str.Length, status ); /* some Windows versions change the error past 2050 chars, others past 4066 chars, some don't */ str.Length = 5000; status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); @@ -547,12 +925,39 @@ static void test_name_limits(void) status == STATUS_BUFFER_TOO_SMALL || status == STATUS_INVALID_PARAMETER, "%u: NtCreateKey failed %x\n", str.Length, status ); + status = pNtOpenKey( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_BUFFER_OVERFLOW || + status == STATUS_BUFFER_TOO_SMALL || + status == STATUS_INVALID_PARAMETER, + "%u: NtOpenKey failed %x\n", str.Length, status ); str.Length = 65534; status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL ); ok( status == STATUS_OBJECT_NAME_INVALID || status == STATUS_BUFFER_OVERFLOW || status == STATUS_BUFFER_TOO_SMALL, "%u: NtCreateKey failed %x\n", str.Length, status ); + status = pNtOpenKey( &ret, GENERIC_ALL, &attr ); + todo_wine + ok( status == STATUS_OBJECT_NAME_INVALID || + status == STATUS_BUFFER_OVERFLOW || + status == STATUS_BUFFER_TOO_SMALL, + "%u: NtOpenKey failed %x\n", str.Length, status ); + attr3.RootDirectory = 0; + 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, + "NULL: NtCreateKey failed %x\n", status ); + status = pNtCreateKey( &ret, GENERIC_ALL, &attr3, 0, NULL, 0, NULL ); + todo_wine + 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, + "NULL: NtOpenKey failed %x\n", status ); + status = pNtOpenKey( &ret, GENERIC_ALL, &attr3 ); + ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenKey failed %x\n", status ); + attr2.ObjectName = attr3.ObjectName = &str; pRtlFreeUnicodeString( &str ); pRtlFreeUnicodeString( &target ); @@ -1477,7 +1882,9 @@ START_TEST(om) pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString"); pNtCreateEvent = (void *)GetProcAddress(hntdll, "NtCreateEvent"); pNtCreateJobObject = (void *)GetProcAddress(hntdll, "NtCreateJobObject"); + pNtOpenJobObject = (void *)GetProcAddress(hntdll, "NtOpenJobObject"); pNtCreateKey = (void *)GetProcAddress(hntdll, "NtCreateKey"); + pNtOpenKey = (void *)GetProcAddress(hntdll, "NtOpenKey"); pNtDeleteKey = (void *)GetProcAddress(hntdll, "NtDeleteKey"); pNtCreateMailslotFile = (void *)GetProcAddress(hntdll, "NtCreateMailslotFile"); pNtCreateMutant = (void *)GetProcAddress(hntdll, "NtCreateMutant"); @@ -1495,8 +1902,11 @@ START_TEST(om) pNtCreateSymbolicLinkObject = (void *)GetProcAddress(hntdll, "NtCreateSymbolicLinkObject"); pNtQuerySymbolicLinkObject = (void *)GetProcAddress(hntdll, "NtQuerySymbolicLinkObject"); pNtCreateSemaphore = (void *)GetProcAddress(hntdll, "NtCreateSemaphore"); + pNtOpenSemaphore = (void *)GetProcAddress(hntdll, "NtOpenSemaphore"); pNtCreateTimer = (void *)GetProcAddress(hntdll, "NtCreateTimer"); + pNtOpenTimer = (void *)GetProcAddress(hntdll, "NtOpenTimer"); pNtCreateSection = (void *)GetProcAddress(hntdll, "NtCreateSection"); + pNtOpenSection = (void *)GetProcAddress(hntdll, "NtOpenSection"); pNtQueryObject = (void *)GetProcAddress(hntdll, "NtQueryObject"); pNtReleaseSemaphore = (void *)GetProcAddress(hntdll, "NtReleaseSemaphore"); pNtCreateKeyedEvent = (void *)GetProcAddress(hntdll, "NtCreateKeyedEvent"); @@ -1504,6 +1914,7 @@ START_TEST(om) pNtWaitForKeyedEvent = (void *)GetProcAddress(hntdll, "NtWaitForKeyedEvent"); pNtReleaseKeyedEvent = (void *)GetProcAddress(hntdll, "NtReleaseKeyedEvent"); pNtCreateIoCompletion = (void *)GetProcAddress(hntdll, "NtCreateIoCompletion"); + pNtOpenIoCompletion = (void *)GetProcAddress(hntdll, "NtOpenIoCompletion"); test_case_sensitive(); test_namespace_pipe(); diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index f4ca4870c38..81a08cde88d 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -2498,7 +2498,7 @@ NTSTATUS WINAPI NtCreateSection( HANDLE *handle, ACCESS_MASK access, const OBJEC NTSTATUS WINAPI NtOpenSection( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr ) { NTSTATUS ret; - DWORD len = attr->ObjectName->Length; + DWORD len = (attr && attr->ObjectName) ? attr->ObjectName->Length : 0; if (len > MAX_PATH*sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;