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
9d74a70a
Commit
9d74a70a
authored
Sep 22, 2010
by
Peter Oberndorfer
Committed by
Alexandre Julliard
Sep 23, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Fix last error value of GetStdHandle/SetStdHandle when called with wrong std handle.
parent
297b054e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
environ.c
dlls/kernel32/environ.c
+2
-2
console.c
dlls/kernel32/tests/console.c
+36
-0
No files found.
dlls/kernel32/environ.c
View file @
9d74a70a
...
...
@@ -396,7 +396,7 @@ HANDLE WINAPI GetStdHandle( DWORD std_handle )
case
STD_OUTPUT_HANDLE
:
return
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdOutput
;
case
STD_ERROR_HANDLE
:
return
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdError
;
}
SetLastError
(
ERROR_INVALID_
PARAMETER
);
SetLastError
(
ERROR_INVALID_
HANDLE
);
return
INVALID_HANDLE_VALUE
;
}
...
...
@@ -412,7 +412,7 @@ BOOL WINAPI SetStdHandle( DWORD std_handle, HANDLE handle )
case
STD_OUTPUT_HANDLE
:
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdOutput
=
handle
;
return
TRUE
;
case
STD_ERROR_HANDLE
:
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdError
=
handle
;
return
TRUE
;
}
SetLastError
(
ERROR_INVALID_
PARAMETER
);
SetLastError
(
ERROR_INVALID_
HANDLE
);
return
FALSE
;
}
...
...
dlls/kernel32/tests/console.c
View file @
9d74a70a
...
...
@@ -1134,6 +1134,41 @@ static void test_VerifyConsoleIoHandle(void)
ok
(
error
==
0xdeadbeef
,
"wrong GetLastError() %d
\n
"
,
error
);
}
static
void
test_GetSetStdHandle
(
void
)
{
HANDLE
handle
;
DWORD
error
;
BOOL
ret
;
/* get invalid std handle */
SetLastError
(
0xdeadbeef
);
handle
=
GetStdHandle
(
42
);
error
=
GetLastError
();
ok
(
error
==
ERROR_INVALID_HANDLE
||
broken
(
error
==
ERROR_INVALID_FUNCTION
)
/* Win9x */
,
"wrong GetLastError() %d
\n
"
,
error
);
ok
(
handle
==
INVALID_HANDLE_VALUE
,
"expected INVALID_HANDLE_VALUE
\n
"
);
/* get valid */
SetLastError
(
0xdeadbeef
);
handle
=
GetStdHandle
(
STD_INPUT_HANDLE
);
error
=
GetLastError
();
ok
(
error
==
0xdeadbeef
,
"wrong GetLastError() %d
\n
"
,
error
);
/* set invalid std handle */
SetLastError
(
0xdeadbeef
);
ret
=
SetStdHandle
(
42
,
handle
);
error
=
GetLastError
();
ok
(
!
ret
,
"expected SetStdHandle to fail
\n
"
);
ok
(
error
==
ERROR_INVALID_HANDLE
||
broken
(
error
==
ERROR_INVALID_FUNCTION
)
/* Win9x */
,
"wrong GetLastError() %d
\n
"
,
error
);
/* set valid (restore old value) */
SetLastError
(
0xdeadbeef
);
ret
=
SetStdHandle
(
STD_INPUT_HANDLE
,
handle
);
error
=
GetLastError
();
ok
(
ret
,
"expected SetStdHandle to succeed
\n
"
);
ok
(
error
==
0xdeadbeef
,
"wrong GetLastError() %d
\n
"
,
error
);
}
START_TEST
(
console
)
{
...
...
@@ -1187,4 +1222,5 @@ START_TEST(console)
test_GetConsoleProcessList
();
test_OpenConsoleW
();
test_VerifyConsoleIoHandle
();
test_GetSetStdHandle
();
}
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