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
c9dbef3d
Commit
c9dbef3d
authored
Jun 05, 2013
by
Piotr Caban
Committed by
Alexandre Julliard
Jun 05, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernet32: Added DuplicateHandle tests with DUPLICATE_CLOSE_SOURCE flag.
parent
76bfbf43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
process.c
dlls/kernel32/tests/process.c
+98
-0
No files found.
dlls/kernel32/tests/process.c
View file @
c9dbef3d
...
...
@@ -1963,6 +1963,103 @@ static void test_TerminateProcess(void)
CloseHandle
(
pi
.
hThread
);
}
static
void
test_DuplicateHandle
(
void
)
{
char
path
[
MAX_PATH
],
file_name
[
MAX_PATH
];
HANDLE
f
,
fmin
,
out
;
DWORD
info
;
BOOL
r
;
r
=
DuplicateHandle
(
GetCurrentProcess
(),
GetCurrentProcess
(),
GetCurrentProcess
(),
&
out
,
0
,
FALSE
,
DUPLICATE_SAME_ACCESS
|
DUPLICATE_CLOSE_SOURCE
);
ok
(
r
,
"DuplicateHandle error %u
\n
"
,
GetLastError
());
r
=
GetHandleInformation
(
out
,
&
info
);
ok
(
r
,
"GetHandleInformation error %u
\n
"
,
GetLastError
());
ok
(
info
==
0
,
"info = %x
\n
"
,
info
);
ok
(
out
!=
GetCurrentProcess
(),
"out = GetCurrentProcess()
\n
"
);
CloseHandle
(
out
);
r
=
DuplicateHandle
(
GetCurrentProcess
(),
GetCurrentProcess
(),
GetCurrentProcess
(),
&
out
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
|
DUPLICATE_CLOSE_SOURCE
);
ok
(
r
,
"DuplicateHandle error %u
\n
"
,
GetLastError
());
r
=
GetHandleInformation
(
out
,
&
info
);
ok
(
r
,
"GetHandleInformation error %u
\n
"
,
GetLastError
());
ok
(
info
==
HANDLE_FLAG_INHERIT
,
"info = %x
\n
"
,
info
);
ok
(
out
!=
GetCurrentProcess
(),
"out = GetCurrentProcess()
\n
"
);
CloseHandle
(
out
);
GetTempPath
(
MAX_PATH
,
path
);
GetTempFileName
(
path
,
"wt"
,
0
,
file_name
);
f
=
CreateFile
(
file_name
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
if
(
f
==
INVALID_HANDLE_VALUE
)
{
ok
(
0
,
"could not create %s
\n
"
,
file_name
);
return
;
}
r
=
DuplicateHandle
(
GetCurrentProcess
(),
f
,
GetCurrentProcess
(),
&
out
,
0
,
FALSE
,
DUPLICATE_SAME_ACCESS
|
DUPLICATE_CLOSE_SOURCE
);
ok
(
r
,
"DuplicateHandle error %u
\n
"
,
GetLastError
());
ok
(
f
==
out
,
"f != out
\n
"
);
r
=
GetHandleInformation
(
out
,
&
info
);
ok
(
r
,
"GetHandleInformation error %u
\n
"
,
GetLastError
());
ok
(
info
==
0
,
"info = %x
\n
"
,
info
);
r
=
DuplicateHandle
(
GetCurrentProcess
(),
f
,
GetCurrentProcess
(),
&
out
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
|
DUPLICATE_CLOSE_SOURCE
);
ok
(
r
,
"DuplicateHandle error %u
\n
"
,
GetLastError
());
ok
(
f
==
out
,
"f != out
\n
"
);
r
=
GetHandleInformation
(
out
,
&
info
);
ok
(
r
,
"GetHandleInformation error %u
\n
"
,
GetLastError
());
ok
(
info
==
HANDLE_FLAG_INHERIT
,
"info = %x
\n
"
,
info
);
r
=
SetHandleInformation
(
f
,
HANDLE_FLAG_PROTECT_FROM_CLOSE
,
HANDLE_FLAG_PROTECT_FROM_CLOSE
);
ok
(
r
,
"SetHandleInformation error %u
\n
"
,
GetLastError
());
r
=
DuplicateHandle
(
GetCurrentProcess
(),
f
,
GetCurrentProcess
(),
&
out
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
|
DUPLICATE_CLOSE_SOURCE
);
ok
(
r
,
"DuplicateHandle error %u
\n
"
,
GetLastError
());
ok
(
f
!=
out
,
"f == out
\n
"
);
r
=
GetHandleInformation
(
out
,
&
info
);
ok
(
r
,
"GetHandleInformation error %u
\n
"
,
GetLastError
());
ok
(
info
==
HANDLE_FLAG_INHERIT
,
"info = %x
\n
"
,
info
);
r
=
SetHandleInformation
(
f
,
HANDLE_FLAG_PROTECT_FROM_CLOSE
,
0
);
ok
(
r
,
"SetHandleInformation error %u
\n
"
,
GetLastError
());
/* Test if DuplicateHandle allocates first free handle */
if
(
f
>
out
)
{
fmin
=
out
;
}
else
{
fmin
=
f
;
f
=
out
;
}
CloseHandle
(
fmin
);
r
=
DuplicateHandle
(
GetCurrentProcess
(),
f
,
GetCurrentProcess
(),
&
out
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
|
DUPLICATE_CLOSE_SOURCE
);
ok
(
r
,
"DuplicateHandle error %u
\n
"
,
GetLastError
());
ok
(
f
==
out
,
"f != out
\n
"
);
CloseHandle
(
out
);
DeleteFile
(
file_name
);
f
=
CreateFile
(
"CONIN$"
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
if
(
!
is_console
(
f
))
{
skip
(
"DuplicateHandle on console handle"
);
CloseHandle
(
f
);
return
;
}
r
=
DuplicateHandle
(
GetCurrentProcess
(),
f
,
GetCurrentProcess
(),
&
out
,
0
,
FALSE
,
DUPLICATE_SAME_ACCESS
|
DUPLICATE_CLOSE_SOURCE
);
ok
(
r
,
"DuplicateHandle error %u
\n
"
,
GetLastError
());
todo_wine
ok
(
f
!=
out
,
"f == out
\n
"
);
CloseHandle
(
out
);
}
START_TEST
(
process
)
{
int
b
=
init
();
...
...
@@ -1991,6 +2088,7 @@ START_TEST(process)
test_Handles
();
test_SystemInfo
();
test_RegistryQuota
();
test_DuplicateHandle
();
/* things that can be tested:
* lookup: check the way program to be executed is searched
* handles: check the handle inheritance stuff (+sec options)
...
...
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