ntdll: Add a helper to validate attributes in open calls, and use a common pattern in all calls.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-01-29 14:57:04 +09:00
parent b3064d748b
commit fe0924625f
7 changed files with 110 additions and 132 deletions

View File

@ -99,6 +99,7 @@ extern int server_get_unix_fd( HANDLE handle, unsigned int access, int *unix_fd,
extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN; extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN;
extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret, extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret,
data_size_t *ret_len ) DECLSPEC_HIDDEN; data_size_t *ret_len ) DECLSPEC_HIDDEN;
extern NTSTATUS validate_open_object_attributes( const OBJECT_ATTRIBUTES *attr ) DECLSPEC_HIDDEN;
/* module handling */ /* module handling */
extern LIST_ENTRY tls_links DECLSPEC_HIDDEN; extern LIST_ENTRY tls_links DECLSPEC_HIDDEN;

View File

@ -429,34 +429,24 @@ NTSTATUS WINAPI NtClose( HANDLE Handle )
* Success: ERROR_SUCCESS. * Success: ERROR_SUCCESS.
* Failure: An NTSTATUS error code. * Failure: An NTSTATUS error code.
*/ */
NTSTATUS WINAPI NtOpenDirectoryObject(PHANDLE DirectoryHandle, ACCESS_MASK DesiredAccess, NTSTATUS WINAPI NtOpenDirectoryObject( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr)
POBJECT_ATTRIBUTES ObjectAttributes)
{ {
NTSTATUS ret; NTSTATUS ret;
if (!DirectoryHandle) return STATUS_ACCESS_VIOLATION; if (!handle) return STATUS_ACCESS_VIOLATION;
if (!ObjectAttributes) return STATUS_INVALID_PARAMETER; if ((ret = validate_open_object_attributes( attr ))) return ret;
TRACE("(%p,0x%08x,%s)\n", DirectoryHandle, DesiredAccess, debugstr_ObjectAttributes(ObjectAttributes));
/* Have to test it here because server won't know difference between TRACE("(%p,0x%08x,%s)\n", handle, access, debugstr_ObjectAttributes(attr));
* ObjectName == NULL and ObjectName == "" */
if (!ObjectAttributes->ObjectName)
{
if (ObjectAttributes->RootDirectory)
return STATUS_OBJECT_NAME_INVALID;
else
return STATUS_OBJECT_PATH_SYNTAX_BAD;
}
SERVER_START_REQ(open_directory) SERVER_START_REQ(open_directory)
{ {
req->access = DesiredAccess; req->access = access;
req->attributes = ObjectAttributes->Attributes; req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( ObjectAttributes->RootDirectory ); req->rootdir = wine_server_obj_handle( attr->RootDirectory );
if (ObjectAttributes->ObjectName) if (attr->ObjectName)
wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer, wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
ObjectAttributes->ObjectName->Length);
ret = wine_server_call( req ); ret = wine_server_call( req );
*DirectoryHandle = wine_server_ptr_handle( reply->handle ); *handle = wine_server_ptr_handle( reply->handle );
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
@ -586,34 +576,25 @@ NTSTATUS WINAPI NtQueryDirectoryObject(HANDLE handle, PDIRECTORY_BASIC_INFORMATI
* Success: ERROR_SUCCESS. * Success: ERROR_SUCCESS.
* Failure: An NTSTATUS error code. * Failure: An NTSTATUS error code.
*/ */
NTSTATUS WINAPI NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle, IN ACCESS_MASK DesiredAccess, NTSTATUS WINAPI NtOpenSymbolicLinkObject( HANDLE *handle, ACCESS_MASK access,
IN POBJECT_ATTRIBUTES ObjectAttributes) const OBJECT_ATTRIBUTES *attr)
{ {
NTSTATUS ret; NTSTATUS ret;
TRACE("(%p,0x%08x,%s)\n",LinkHandle, DesiredAccess, debugstr_ObjectAttributes(ObjectAttributes));
if (!LinkHandle) return STATUS_ACCESS_VIOLATION; TRACE("(%p,0x%08x,%s)\n", handle, access, debugstr_ObjectAttributes(attr));
if (!ObjectAttributes) return STATUS_INVALID_PARAMETER;
/* Have to test it here because server won't know difference between if (!handle) return STATUS_ACCESS_VIOLATION;
* ObjectName == NULL and ObjectName == "" */ if ((ret = validate_open_object_attributes( attr ))) return ret;
if (!ObjectAttributes->ObjectName)
{
if (ObjectAttributes->RootDirectory)
return STATUS_OBJECT_NAME_INVALID;
else
return STATUS_OBJECT_PATH_SYNTAX_BAD;
}
SERVER_START_REQ(open_symlink) SERVER_START_REQ(open_symlink)
{ {
req->access = DesiredAccess; req->access = access;
req->attributes = ObjectAttributes->Attributes; req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( ObjectAttributes->RootDirectory ); req->rootdir = wine_server_obj_handle( attr->RootDirectory );
if (ObjectAttributes->ObjectName) if (attr->ObjectName)
wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer, wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
ObjectAttributes->ObjectName->Length);
ret = wine_server_call( req ); ret = wine_server_call( req );
*LinkHandle = wine_server_ptr_handle( reply->handle ); *handle = wine_server_ptr_handle( reply->handle );
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;

View File

@ -130,6 +130,8 @@ NTSTATUS WINAPI NtOpenKeyEx( PHANDLE retkey, ACCESS_MASK access, const OBJECT_AT
if (!retkey || !attr || !attr->ObjectName) return STATUS_ACCESS_VIOLATION; if (!retkey || !attr || !attr->ObjectName) return STATUS_ACCESS_VIOLATION;
if (attr->Length > sizeof(OBJECT_ATTRIBUTES)) return STATUS_INVALID_PARAMETER; if (attr->Length > sizeof(OBJECT_ATTRIBUTES)) return STATUS_INVALID_PARAMETER;
if ((ret = validate_open_object_attributes( attr ))) return ret;
TRACE( "(%p,%s,%x,%p)\n", attr->RootDirectory, TRACE( "(%p,%s,%x,%p)\n", attr->RootDirectory,
debugstr_us(attr->ObjectName), access, retkey ); debugstr_us(attr->ObjectName), access, retkey );
if (options) if (options)

View File

@ -151,6 +151,19 @@ NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_a
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS validate_open_object_attributes( const OBJECT_ATTRIBUTES *attr )
{
if (!attr) return STATUS_INVALID_PARAMETER;
if (attr->ObjectName)
{
if (attr->ObjectName->Length & (sizeof(WCHAR) - 1)) return STATUS_OBJECT_NAME_INVALID;
}
else if (attr->RootDirectory) return STATUS_OBJECT_NAME_INVALID;
return STATUS_SUCCESS;
}
/* /*
* Semaphores * Semaphores
*/ */
@ -191,21 +204,21 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
/****************************************************************************** /******************************************************************************
* NtOpenSemaphore (NTDLL.@) * NtOpenSemaphore (NTDLL.@)
*/ */
NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle, NTSTATUS WINAPI NtOpenSemaphore( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
IN ACCESS_MASK access,
IN const OBJECT_ATTRIBUTES *attr )
{ {
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
if ((ret = validate_open_object_attributes( attr ))) return ret;
SERVER_START_REQ( open_semaphore ) SERVER_START_REQ( open_semaphore )
{ {
req->access = access; req->access = access;
req->attributes = (attr) ? attr->Attributes : 0; req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 ); req->rootdir = wine_server_obj_handle( attr->RootDirectory );
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (attr->ObjectName)
wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
ret = wine_server_call( req ); ret = wine_server_call( req );
*SemaphoreHandle = wine_server_ptr_handle( reply->handle ); *handle = wine_server_ptr_handle( reply->handle );
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
@ -298,22 +311,21 @@ NTSTATUS WINAPI NtCreateEvent( PHANDLE EventHandle, ACCESS_MASK DesiredAccess,
* NtOpenEvent (NTDLL.@) * NtOpenEvent (NTDLL.@)
* ZwOpenEvent (NTDLL.@) * ZwOpenEvent (NTDLL.@)
*/ */
NTSTATUS WINAPI NtOpenEvent( NTSTATUS WINAPI NtOpenEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
OUT PHANDLE EventHandle,
IN ACCESS_MASK DesiredAccess,
IN const OBJECT_ATTRIBUTES *attr )
{ {
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
if ((ret = validate_open_object_attributes( attr ))) return ret;
SERVER_START_REQ( open_event ) SERVER_START_REQ( open_event )
{ {
req->access = DesiredAccess; req->access = access;
req->attributes = (attr) ? attr->Attributes : 0; req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 ); req->rootdir = wine_server_obj_handle( attr->RootDirectory );
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (attr->ObjectName)
wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
ret = wine_server_call( req ); ret = wine_server_call( req );
*EventHandle = wine_server_ptr_handle( reply->handle ); *handle = wine_server_ptr_handle( reply->handle );
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
@ -464,21 +476,21 @@ NTSTATUS WINAPI NtCreateMutant(OUT HANDLE* MutantHandle,
* NtOpenMutant [NTDLL.@] * NtOpenMutant [NTDLL.@]
* ZwOpenMutant [NTDLL.@] * ZwOpenMutant [NTDLL.@]
*/ */
NTSTATUS WINAPI NtOpenMutant(OUT HANDLE* MutantHandle, NTSTATUS WINAPI NtOpenMutant( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
IN ACCESS_MASK access,
IN const OBJECT_ATTRIBUTES* attr )
{ {
NTSTATUS status; NTSTATUS status;
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
if ((status = validate_open_object_attributes( attr ))) return status;
SERVER_START_REQ( open_mutex ) SERVER_START_REQ( open_mutex )
{ {
req->access = access; req->access = access;
req->attributes = (attr) ? attr->Attributes : 0; req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 ); req->rootdir = wine_server_obj_handle( attr->RootDirectory );
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (attr->ObjectName)
wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
status = wine_server_call( req ); status = wine_server_call( req );
*MutantHandle = wine_server_ptr_handle( reply->handle ); *handle = wine_server_ptr_handle( reply->handle );
} }
SERVER_END_REQ; SERVER_END_REQ;
return status; return status;
@ -550,17 +562,19 @@ NTSTATUS WINAPI NtCreateJobObject( PHANDLE handle, ACCESS_MASK access, const OBJ
* NtOpenJobObject [NTDLL.@] * NtOpenJobObject [NTDLL.@]
* ZwOpenJobObject [NTDLL.@] * ZwOpenJobObject [NTDLL.@]
*/ */
NTSTATUS WINAPI NtOpenJobObject( PHANDLE handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr ) NTSTATUS WINAPI NtOpenJobObject( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
{ {
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
if ((ret = validate_open_object_attributes( attr ))) return ret;
SERVER_START_REQ( open_job ) SERVER_START_REQ( open_job )
{ {
req->access = access; req->access = access;
req->attributes = attr ? attr->Attributes : 0; req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 ); req->rootdir = wine_server_obj_handle( attr->RootDirectory );
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (attr->ObjectName)
wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
ret = wine_server_call( req ); ret = wine_server_call( req );
*handle = wine_server_ptr_handle( reply->handle ); *handle = wine_server_ptr_handle( reply->handle );
} }
@ -780,19 +794,19 @@ NTSTATUS WINAPI NtCreateTimer(OUT HANDLE *handle,
* NtOpenTimer [NTDLL.@] * NtOpenTimer [NTDLL.@]
* ZwOpenTimer [NTDLL.@] * ZwOpenTimer [NTDLL.@]
*/ */
NTSTATUS WINAPI NtOpenTimer(OUT PHANDLE handle, NTSTATUS WINAPI NtOpenTimer( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
IN ACCESS_MASK access,
IN const OBJECT_ATTRIBUTES* attr )
{ {
DWORD len = (attr && attr->ObjectName) ? attr->ObjectName->Length : 0;
NTSTATUS status; NTSTATUS status;
if ((status = validate_open_object_attributes( attr ))) return status;
SERVER_START_REQ( open_timer ) SERVER_START_REQ( open_timer )
{ {
req->access = access; req->access = access;
req->attributes = (attr) ? attr->Attributes : 0; req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 ); req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 );
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (attr->ObjectName)
wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
status = wine_server_call( req ); status = wine_server_call( req );
*handle = wine_server_ptr_handle( reply->handle ); *handle = wine_server_ptr_handle( reply->handle );
} }
@ -1092,15 +1106,17 @@ NTSTATUS WINAPI NtCreateKeyedEvent( HANDLE *handle, ACCESS_MASK access,
*/ */
NTSTATUS WINAPI NtOpenKeyedEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr ) NTSTATUS WINAPI NtOpenKeyedEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
{ {
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
if ((ret = validate_open_object_attributes( attr ))) return ret;
SERVER_START_REQ( open_keyed_event ) SERVER_START_REQ( open_keyed_event )
{ {
req->access = access; req->access = access;
req->attributes = attr ? attr->Attributes : 0; req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 ); req->rootdir = wine_server_obj_handle( attr->RootDirectory );
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (attr->ObjectName)
wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
ret = wine_server_call( req ); ret = wine_server_call( req );
*handle = wine_server_ptr_handle( reply->handle ); *handle = wine_server_ptr_handle( reply->handle );
} }
@ -1275,24 +1291,22 @@ NTSTATUS WINAPI NtRemoveIoCompletion( HANDLE CompletionPort, PULONG_PTR Completi
* ObjectAttributes [I] completion object name * ObjectAttributes [I] completion object name
* *
*/ */
NTSTATUS WINAPI NtOpenIoCompletion( PHANDLE CompletionPort, ACCESS_MASK DesiredAccess, NTSTATUS WINAPI NtOpenIoCompletion( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
POBJECT_ATTRIBUTES ObjectAttributes )
{ {
NTSTATUS status; NTSTATUS status;
TRACE("(%p, 0x%x, %p)\n", CompletionPort, DesiredAccess, ObjectAttributes); if (!handle) return STATUS_INVALID_PARAMETER;
if ((status = validate_open_object_attributes( attr ))) return status;
if (!CompletionPort || !ObjectAttributes || !ObjectAttributes->ObjectName)
return STATUS_INVALID_PARAMETER;
SERVER_START_REQ( open_completion ) SERVER_START_REQ( open_completion )
{ {
req->access = DesiredAccess; req->access = access;
req->rootdir = wine_server_obj_handle( ObjectAttributes->RootDirectory ); req->attributes = attr->Attributes;
wine_server_add_data( req, ObjectAttributes->ObjectName->Buffer, req->rootdir = wine_server_obj_handle( attr->RootDirectory );
ObjectAttributes->ObjectName->Length ); if (attr->ObjectName)
if (!(status = wine_server_call( req ))) wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
*CompletionPort = wine_server_ptr_handle( reply->handle ); status = wine_server_call( req );
*handle = wine_server_ptr_handle( reply->handle );
} }
SERVER_END_REQ; SERVER_END_REQ;
return status; return status;

View File

@ -514,52 +514,42 @@ static void test_name_limits(void)
status = pNtCreateMutant( &ret, GENERIC_ALL, &attr2, FALSE ); status = pNtCreateMutant( &ret, GENERIC_ALL, &attr2, FALSE );
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMutant failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMutant failed %x\n", str.Length, status );
status = pNtOpenMutant( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenMutant( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenMutant failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenMutant failed %x\n", str.Length, status );
status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr2, 1, 2 ); status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr2, 1, 2 );
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSemaphore failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSemaphore failed %x\n", str.Length, status );
status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSemaphore failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSemaphore failed %x\n", str.Length, status );
status = pNtCreateEvent( &ret, GENERIC_ALL, &attr2, 1, 0 ); status = pNtCreateEvent( &ret, GENERIC_ALL, &attr2, 1, 0 );
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateEvent failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateEvent failed %x\n", str.Length, status );
status = pNtOpenEvent( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenEvent( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenEvent failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenEvent failed %x\n", str.Length, status );
status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr2, 0 ); status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr2, 0 );
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateKeyedEvent failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateKeyedEvent failed %x\n", str.Length, status );
status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenKeyedEvent failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenKeyedEvent failed %x\n", str.Length, status );
status = pNtCreateTimer( &ret, GENERIC_ALL, &attr2, NotificationTimer ); status = pNtCreateTimer( &ret, GENERIC_ALL, &attr2, NotificationTimer );
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateTimer failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateTimer failed %x\n", str.Length, status );
status = pNtOpenTimer( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenTimer( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenTimer failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenTimer failed %x\n", str.Length, status );
status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr2, 0 ); status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr2, 0 );
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateCompletion failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateCompletion failed %x\n", str.Length, status );
status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenCompletion failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenCompletion failed %x\n", str.Length, status );
status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 ); status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 );
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateJobObject failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateJobObject failed %x\n", str.Length, status );
status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenJobObject failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenJobObject failed %x\n", str.Length, status );
status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr2 ); status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr2 );
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateDirectoryObject failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateDirectoryObject failed %x\n", str.Length, status );
status = pNtOpenDirectoryObject( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenDirectoryObject( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenDirectoryObject failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenDirectoryObject failed %x\n", str.Length, status );
status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr2, &target ); status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr2, &target );
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSymbolicLinkObject failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSymbolicLinkObject failed %x\n", str.Length, status );
status = pNtOpenSymbolicLinkObject( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenSymbolicLinkObject( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSymbolicLinkObject failed %x\n", str.Length, status ); 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 ); 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 ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateSection failed %x\n", str.Length, status );
status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr2 ); status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSection failed %x\n", str.Length, status ); ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtOpenSection failed %x\n", str.Length, status );
str.Length = 65532; str.Length = 65532;
@ -620,7 +610,6 @@ static void test_name_limits(void)
status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 ); 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 ); ok( status == STATUS_SUCCESS, "%u: NtCreateSection failed %x\n", str.Length, status );
status = pNtOpenSection( &ret2, SECTION_MAP_WRITE, &attr ); status = pNtOpenSection( &ret2, SECTION_MAP_WRITE, &attr );
todo_wine
ok( status == STATUS_SUCCESS, "%u: NtOpenSection failed %x\n", str.Length, status ); ok( status == STATUS_SUCCESS, "%u: NtOpenSection failed %x\n", str.Length, status );
pNtClose( ret2 ); pNtClose( ret2 );
pNtClose( ret ); pNtClose( ret );
@ -686,7 +675,6 @@ static void test_name_limits(void)
ok( status == STATUS_SUCCESS, "NULL: NtCreateMutant failed %x\n", status ); ok( status == STATUS_SUCCESS, "NULL: NtCreateMutant failed %x\n", status );
pNtClose( ret ); pNtClose( ret );
status = pNtOpenMutant( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenMutant( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenMutant failed %x\n", status ); ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenMutant failed %x\n", status );
status = pNtOpenMutant( &ret, GENERIC_ALL, &attr3 ); status = pNtOpenMutant( &ret, GENERIC_ALL, &attr3 );
ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenMutant failed %x\n", status ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenMutant failed %x\n", status );
@ -696,7 +684,6 @@ static void test_name_limits(void)
ok( status == STATUS_SUCCESS, "NULL: NtCreateSemaphore failed %x\n", status ); ok( status == STATUS_SUCCESS, "NULL: NtCreateSemaphore failed %x\n", status );
pNtClose( ret ); pNtClose( ret );
status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenSemaphore failed %x\n", status ); ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenSemaphore failed %x\n", status );
status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr3 ); status = pNtOpenSemaphore( &ret, GENERIC_ALL, &attr3 );
ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenSemaphore failed %x\n", status ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenSemaphore failed %x\n", status );
@ -706,7 +693,6 @@ static void test_name_limits(void)
ok( status == STATUS_SUCCESS, "NULL: NtCreateEvent failed %x\n", status ); ok( status == STATUS_SUCCESS, "NULL: NtCreateEvent failed %x\n", status );
pNtClose( ret ); pNtClose( ret );
status = pNtOpenEvent( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenEvent( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenEvent failed %x\n", status ); ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenEvent failed %x\n", status );
status = pNtOpenEvent( &ret, GENERIC_ALL, &attr3 ); status = pNtOpenEvent( &ret, GENERIC_ALL, &attr3 );
ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenEvent failed %x\n", status ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenEvent failed %x\n", status );
@ -716,7 +702,6 @@ static void test_name_limits(void)
ok( status == STATUS_SUCCESS, "NULL: NtCreateKeyedEvent failed %x\n", status ); ok( status == STATUS_SUCCESS, "NULL: NtCreateKeyedEvent failed %x\n", status );
pNtClose( ret ); pNtClose( ret );
status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenKeyedEvent failed %x\n", status ); ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenKeyedEvent failed %x\n", status );
status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr3 ); status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, &attr3 );
ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenKeyedEvent failed %x\n", status ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenKeyedEvent failed %x\n", status );
@ -726,7 +711,6 @@ static void test_name_limits(void)
ok( status == STATUS_SUCCESS, "NULL: NtCreateTimer failed %x\n", status ); ok( status == STATUS_SUCCESS, "NULL: NtCreateTimer failed %x\n", status );
pNtClose( ret ); pNtClose( ret );
status = pNtOpenTimer( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenTimer( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenTimer failed %x\n", status ); ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenTimer failed %x\n", status );
status = pNtOpenTimer( &ret, GENERIC_ALL, &attr3 ); status = pNtOpenTimer( &ret, GENERIC_ALL, &attr3 );
ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenTimer failed %x\n", status ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenTimer failed %x\n", status );
@ -736,10 +720,8 @@ static void test_name_limits(void)
ok( status == STATUS_SUCCESS, "NULL: NtCreateCompletion failed %x\n", status ); ok( status == STATUS_SUCCESS, "NULL: NtCreateCompletion failed %x\n", status );
pNtClose( ret ); pNtClose( ret );
status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenCompletion failed %x\n", status ); ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenCompletion failed %x\n", status );
status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr3 ); status = pNtOpenIoCompletion( &ret, GENERIC_ALL, &attr3 );
todo_wine
ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenCompletion failed %x\n", status ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenCompletion failed %x\n", status );
status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 ); status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 );
ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateJobObject failed %x\n", status ); ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateJobObject failed %x\n", status );
@ -747,7 +729,6 @@ static void test_name_limits(void)
ok( status == STATUS_SUCCESS, "NULL: NtCreateJobObject failed %x\n", status ); ok( status == STATUS_SUCCESS, "NULL: NtCreateJobObject failed %x\n", status );
pNtClose( ret ); pNtClose( ret );
status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr2 ); status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenJobObject failed %x\n", status ); ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenJobObject failed %x\n", status );
status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr3 ); status = pNtOpenJobObject( &ret, GENERIC_ALL, &attr3 );
ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenJobObject failed %x\n", status ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenJobObject failed %x\n", status );
@ -775,7 +756,6 @@ static void test_name_limits(void)
ok( status == STATUS_SUCCESS, "NULL: NtCreateSection failed %x\n", status ); ok( status == STATUS_SUCCESS, "NULL: NtCreateSection failed %x\n", status );
pNtClose( ret ); pNtClose( ret );
status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr2 ); status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr2 );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenSection failed %x\n", status ); ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtOpenSection failed %x\n", status );
status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr3 ); status = pNtOpenSection( &ret, SECTION_MAP_WRITE, &attr3 );
ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenSection failed %x\n", status ); ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtOpenSection failed %x\n", status );
@ -898,7 +878,6 @@ static void test_name_limits(void)
pNtClose( ret ); pNtClose( ret );
} }
status = pNtOpenKey( &ret, GENERIC_ALL, &attr ); status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID || ok( status == STATUS_OBJECT_NAME_INVALID ||
status == STATUS_INVALID_PARAMETER || status == STATUS_INVALID_PARAMETER ||
broken( status == STATUS_OBJECT_NAME_NOT_FOUND ), /* wow64 */ broken( status == STATUS_OBJECT_NAME_NOT_FOUND ), /* wow64 */

View File

@ -2498,17 +2498,18 @@ NTSTATUS WINAPI NtCreateSection( HANDLE *handle, ACCESS_MASK access, const OBJEC
NTSTATUS WINAPI NtOpenSection( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr ) NTSTATUS WINAPI NtOpenSection( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
{ {
NTSTATUS ret; NTSTATUS ret;
DWORD len = (attr && attr->ObjectName) ? attr->ObjectName->Length : 0;
if (len > MAX_PATH*sizeof(WCHAR)) return STATUS_NAME_TOO_LONG; if ((ret = validate_open_object_attributes( attr ))) return ret;
SERVER_START_REQ( open_mapping ) SERVER_START_REQ( open_mapping )
{ {
req->access = access; req->access = access;
req->attributes = attr->Attributes; req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr->RootDirectory ); req->rootdir = wine_server_obj_handle( attr->RootDirectory );
wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (attr->ObjectName)
if (!(ret = wine_server_call( req ))) *handle = wine_server_ptr_handle( reply->handle ); wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
ret = wine_server_call( req );
*handle = wine_server_ptr_handle( reply->handle );
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;

View File

@ -2191,11 +2191,11 @@ NTSYSAPI NTSTATUS WINAPI NtMapViewOfSection(HANDLE,HANDLE,PVOID*,ULONG,SIZE_T,c
NTSYSAPI NTSTATUS WINAPI NtNotifyChangeDirectoryFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,ULONG,BOOLEAN); NTSYSAPI NTSTATUS WINAPI NtNotifyChangeDirectoryFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,ULONG,BOOLEAN);
NTSYSAPI NTSTATUS WINAPI NtNotifyChangeKey(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,BOOLEAN,PVOID,ULONG,BOOLEAN); NTSYSAPI NTSTATUS WINAPI NtNotifyChangeKey(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,BOOLEAN,PVOID,ULONG,BOOLEAN);
NTSYSAPI NTSTATUS WINAPI NtNotifyChangeMultipleKeys(HANDLE,ULONG,OBJECT_ATTRIBUTES*,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,BOOLEAN,PVOID,ULONG,BOOLEAN); NTSYSAPI NTSTATUS WINAPI NtNotifyChangeMultipleKeys(HANDLE,ULONG,OBJECT_ATTRIBUTES*,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,BOOLEAN,PVOID,ULONG,BOOLEAN);
NTSYSAPI NTSTATUS WINAPI NtOpenDirectoryObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES); NTSYSAPI NTSTATUS WINAPI NtOpenDirectoryObject(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSYSAPI NTSTATUS WINAPI NtOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *); NTSYSAPI NTSTATUS WINAPI NtOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
NTSYSAPI NTSTATUS WINAPI NtOpenEventPair(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES); NTSYSAPI NTSTATUS WINAPI NtOpenEventPair(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSYSAPI NTSTATUS WINAPI NtOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG); NTSYSAPI NTSTATUS WINAPI NtOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG);
NTSYSAPI NTSTATUS WINAPI NtOpenIoCompletion(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES); NTSYSAPI NTSTATUS WINAPI NtOpenIoCompletion(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSYSAPI NTSTATUS WINAPI NtOpenJobObject(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*); NTSYSAPI NTSTATUS WINAPI NtOpenJobObject(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSYSAPI NTSTATUS WINAPI NtOpenKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *); NTSYSAPI NTSTATUS WINAPI NtOpenKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
NTSYSAPI NTSTATUS WINAPI NtOpenKeyEx(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG); NTSYSAPI NTSTATUS WINAPI NtOpenKeyEx(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG);
@ -2209,7 +2209,7 @@ NTSYSAPI NTSTATUS WINAPI NtOpenProcessToken(HANDLE,DWORD,HANDLE *);
NTSYSAPI NTSTATUS WINAPI NtOpenProcessTokenEx(HANDLE,DWORD,DWORD,HANDLE *); NTSYSAPI NTSTATUS WINAPI NtOpenProcessTokenEx(HANDLE,DWORD,DWORD,HANDLE *);
NTSYSAPI NTSTATUS WINAPI NtOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*); NTSYSAPI NTSTATUS WINAPI NtOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSYSAPI NTSTATUS WINAPI NtOpenSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*); NTSYSAPI NTSTATUS WINAPI NtOpenSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSYSAPI NTSTATUS WINAPI NtOpenSymbolicLinkObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES); NTSYSAPI NTSTATUS WINAPI NtOpenSymbolicLinkObject(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSYSAPI NTSTATUS WINAPI NtOpenThread(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*); NTSYSAPI NTSTATUS WINAPI NtOpenThread(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*);
NTSYSAPI NTSTATUS WINAPI NtOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *); NTSYSAPI NTSTATUS WINAPI NtOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *);
NTSYSAPI NTSTATUS WINAPI NtOpenThreadTokenEx(HANDLE,DWORD,BOOLEAN,DWORD,HANDLE *); NTSYSAPI NTSTATUS WINAPI NtOpenThreadTokenEx(HANDLE,DWORD,BOOLEAN,DWORD,HANDLE *);