Commit 2d41fcd8 authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

Kernel32 should create named objects with OBJ_OPENIF flag set.

Handle STATUS_OBJECT_NAME_EXISTS explicitly as it's not mapped with RtlNtStatusToDosError.
parent 4238d2cc
...@@ -445,7 +445,7 @@ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, ...@@ -445,7 +445,7 @@ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
attr.ObjectName = NULL; attr.ObjectName = NULL;
attr.Attributes = OBJ_CASE_INSENSITIVE | attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0); ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
...@@ -456,7 +456,10 @@ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, ...@@ -456,7 +456,10 @@ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
} }
status = NtCreateEvent( &ret, EVENT_ALL_ACCESS, &attr, manual_reset, initial_state ); status = NtCreateEvent( &ret, EVENT_ALL_ACCESS, &attr, manual_reset, initial_state );
SetLastError( RtlNtStatusToDosError(status) ); if (status == STATUS_OBJECT_NAME_EXISTS)
SetLastError( ERROR_ALREADY_EXISTS );
else
SetLastError( RtlNtStatusToDosError(status) );
return ret; return ret;
} }
...@@ -640,7 +643,7 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name ) ...@@ -640,7 +643,7 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
attr.ObjectName = NULL; attr.ObjectName = NULL;
attr.Attributes = OBJ_CASE_INSENSITIVE | attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0); ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
...@@ -651,7 +654,10 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name ) ...@@ -651,7 +654,10 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
} }
status = NtCreateMutant( &ret, MUTEX_ALL_ACCESS, &attr, owner ); status = NtCreateMutant( &ret, MUTEX_ALL_ACCESS, &attr, owner );
SetLastError( RtlNtStatusToDosError(status) ); if (status == STATUS_OBJECT_NAME_EXISTS)
SetLastError( ERROR_ALREADY_EXISTS );
else
SetLastError( RtlNtStatusToDosError(status) );
return ret; return ret;
} }
...@@ -762,7 +768,7 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial, ...@@ -762,7 +768,7 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
attr.ObjectName = NULL; attr.ObjectName = NULL;
attr.Attributes = OBJ_CASE_INSENSITIVE | attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0); ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
...@@ -773,7 +779,10 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial, ...@@ -773,7 +779,10 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
} }
status = NtCreateSemaphore( &ret, SEMAPHORE_ALL_ACCESS, &attr, initial, max ); status = NtCreateSemaphore( &ret, SEMAPHORE_ALL_ACCESS, &attr, initial, max );
SetLastError( RtlNtStatusToDosError(status) ); if (status == STATUS_OBJECT_NAME_EXISTS)
SetLastError( ERROR_ALREADY_EXISTS );
else
SetLastError( RtlNtStatusToDosError(status) );
return ret; return ret;
} }
...@@ -877,7 +886,7 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST ...@@ -877,7 +886,7 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
attr.ObjectName = NULL; attr.ObjectName = NULL;
attr.Attributes = OBJ_CASE_INSENSITIVE | attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0); ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
...@@ -889,7 +898,10 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST ...@@ -889,7 +898,10 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST
status = NtCreateTimer(&handle, TIMER_ALL_ACCESS, &attr, status = NtCreateTimer(&handle, TIMER_ALL_ACCESS, &attr,
manual ? NotificationTimer : SynchronizationTimer); manual ? NotificationTimer : SynchronizationTimer);
SetLastError( RtlNtStatusToDosError(status) ); if (status == STATUS_OBJECT_NAME_EXISTS)
SetLastError( ERROR_ALREADY_EXISTS );
else
SetLastError( RtlNtStatusToDosError(status) );
return handle; return handle;
} }
......
...@@ -308,7 +308,7 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa, ...@@ -308,7 +308,7 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa,
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
attr.ObjectName = NULL; attr.ObjectName = NULL;
attr.Attributes = OBJ_CASE_INSENSITIVE | attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0); ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
...@@ -354,7 +354,10 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa, ...@@ -354,7 +354,10 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa,
size.u.HighPart = size_high; size.u.HighPart = size_high;
status = NtCreateSection( &ret, access, &attr, &size, protect, sec_type, hFile ); status = NtCreateSection( &ret, access, &attr, &size, protect, sec_type, hFile );
SetLastError( RtlNtStatusToDosError(status) ); if (status == STATUS_OBJECT_NAME_EXISTS)
SetLastError( ERROR_ALREADY_EXISTS );
else
SetLastError( RtlNtStatusToDosError(status) );
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment