Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
a7aa192a
Commit
a7aa192a
authored
Mar 02, 2018
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Add a helper function to fill object attributes in Open* functions.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
be8affc4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
60 deletions
+59
-60
sync.c
dlls/kernel32/sync.c
+19
-60
sync.c
dlls/kernel32/tests/sync.c
+40
-0
No files found.
dlls/kernel32/sync.c
View file @
a7aa192a
...
...
@@ -81,6 +81,20 @@ HANDLE get_BaseNamedObjects_handle(void)
return
handle
;
}
static
BOOL
get_open_object_attributes
(
OBJECT_ATTRIBUTES
*
attr
,
UNICODE_STRING
*
nameW
,
BOOL
inherit
,
const
WCHAR
*
name
)
{
if
(
!
name
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
RtlInitUnicodeString
(
nameW
,
name
);
InitializeObjectAttributes
(
attr
,
nameW
,
inherit
?
OBJ_INHERIT
:
0
,
get_BaseNamedObjects_handle
(),
NULL
);
return
TRUE
;
}
/* helper for kernel32->ntdll timeout format conversion */
static
inline
PLARGE_INTEGER
get_nt_timeout
(
PLARGE_INTEGER
pTime
,
DWORD
timeout
)
{
...
...
@@ -530,18 +544,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW( DWORD access, BOOL inherit, LPCWSTR
if
(
!
is_version_nt
())
access
=
EVENT_ALL_ACCESS
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
ObjectName
=
NULL
;
attr
.
Attributes
=
inherit
?
OBJ_INHERIT
:
0
;
attr
.
SecurityDescriptor
=
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
if
(
name
)
{
RtlInitUnicodeString
(
&
nameW
,
name
);
attr
.
ObjectName
=
&
nameW
;
attr
.
RootDirectory
=
get_BaseNamedObjects_handle
();
}
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
status
=
NtOpenEvent
(
&
ret
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
...
...
@@ -692,18 +695,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexW( DWORD access, BOOL inherit, LPCWSTR
if
(
!
is_version_nt
())
access
=
MUTEX_ALL_ACCESS
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
ObjectName
=
NULL
;
attr
.
Attributes
=
inherit
?
OBJ_INHERIT
:
0
;
attr
.
SecurityDescriptor
=
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
if
(
name
)
{
RtlInitUnicodeString
(
&
nameW
,
name
);
attr
.
ObjectName
=
&
nameW
;
attr
.
RootDirectory
=
get_BaseNamedObjects_handle
();
}
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
status
=
NtOpenMutant
(
&
ret
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
...
...
@@ -837,18 +829,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreW( DWORD access, BOOL inherit, LPCW
if
(
!
is_version_nt
())
access
=
SEMAPHORE_ALL_ACCESS
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
ObjectName
=
NULL
;
attr
.
Attributes
=
inherit
?
OBJ_INHERIT
:
0
;
attr
.
SecurityDescriptor
=
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
if
(
name
)
{
RtlInitUnicodeString
(
&
nameW
,
name
);
attr
.
ObjectName
=
&
nameW
;
attr
.
RootDirectory
=
get_BaseNamedObjects_handle
();
}
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
status
=
NtOpenSemaphore
(
&
ret
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
...
...
@@ -933,18 +914,7 @@ HANDLE WINAPI OpenJobObjectW( DWORD access, BOOL inherit, LPCWSTR name )
OBJECT_ATTRIBUTES
attr
;
NTSTATUS
status
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
ObjectName
=
NULL
;
attr
.
Attributes
=
inherit
?
OBJ_INHERIT
:
0
;
attr
.
SecurityDescriptor
=
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
if
(
name
)
{
RtlInitUnicodeString
(
&
nameW
,
name
);
attr
.
ObjectName
=
&
nameW
;
attr
.
RootDirectory
=
get_BaseNamedObjects_handle
();
}
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
status
=
NtOpenJobObject
(
&
ret
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
...
...
@@ -1140,18 +1110,7 @@ HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
if
(
!
is_version_nt
())
access
=
TIMER_ALL_ACCESS
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
ObjectName
=
NULL
;
attr
.
Attributes
=
inherit
?
OBJ_INHERIT
:
0
;
attr
.
SecurityDescriptor
=
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
if
(
name
)
{
RtlInitUnicodeString
(
&
nameW
,
name
);
attr
.
ObjectName
=
&
nameW
;
attr
.
RootDirectory
=
get_BaseNamedObjects_handle
();
}
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
status
=
NtOpenTimer
(
&
handle
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
...
...
dlls/kernel32/tests/sync.c
View file @
a7aa192a
...
...
@@ -265,6 +265,16 @@ todo_wine
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
hOpened
=
OpenMutexA
(
READ_CONTROL
,
FALSE
,
NULL
);
ok
(
!
hOpened
,
"OpenMutex succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
hOpened
=
OpenMutexW
(
READ_CONTROL
,
FALSE
,
NULL
);
ok
(
!
hOpened
,
"OpenMutex succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
hOpened
=
CreateMutexA
(
NULL
,
FALSE
,
"WineTestMutex"
);
ok
(
hOpened
!=
NULL
,
"CreateMutex failed with error %d
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_ALREADY_EXISTS
,
"wrong error %u
\n
"
,
GetLastError
());
...
...
@@ -517,6 +527,16 @@ static void test_event(void)
ok
(
!
handle2
,
"OpenEvent succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
handle2
=
OpenEventA
(
EVENT_ALL_ACCESS
,
FALSE
,
NULL
);
ok
(
!
handle2
,
"OpenEvent succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
handle2
=
OpenEventW
(
EVENT_ALL_ACCESS
,
FALSE
,
NULL
);
ok
(
!
handle2
,
"OpenEvent succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
());
CloseHandle
(
handle
);
/* resource notifications are events too */
...
...
@@ -586,6 +606,16 @@ static void test_semaphore(void)
ok
(
!
handle2
,
"OpenSemaphore succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
handle2
=
OpenSemaphoreA
(
SEMAPHORE_ALL_ACCESS
,
FALSE
,
NULL
);
ok
(
!
handle2
,
"OpenSemaphore succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
handle2
=
OpenSemaphoreW
(
SEMAPHORE_ALL_ACCESS
,
FALSE
,
NULL
);
ok
(
!
handle2
,
"OpenSemaphore succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
());
CloseHandle
(
handle
);
}
...
...
@@ -622,6 +652,16 @@ static void test_waitable_timer(void)
ok
(
!
handle2
,
"OpenWaitableTimer succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
handle2
=
OpenWaitableTimerA
(
TIMER_ALL_ACCESS
,
FALSE
,
NULL
);
ok
(
!
handle2
,
"OpenWaitableTimer failed with error %d
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
handle2
=
OpenWaitableTimerW
(
TIMER_ALL_ACCESS
,
FALSE
,
NULL
);
ok
(
!
handle2
,
"OpenWaitableTimer failed with error %d
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
());
CloseHandle
(
handle
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment