mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
- Improved DuplicateHandle for console handles.
svn path=/trunk/; revision=4272
This commit is contained in:
parent
bb63ba9048
commit
59798c6f34
1 changed files with 22 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: handle.c,v 1.10 2003/02/12 00:39:31 hyperion Exp $
|
/* $Id: handle.c,v 1.11 2003/03/09 21:37:57 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -16,6 +16,17 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <kernel32/kernel32.h>
|
#include <kernel32/kernel32.h>
|
||||||
|
|
||||||
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
WINBOOL STDCALL
|
||||||
|
GetProcessId (HANDLE hProcess, LPDWORD lpProcessId);
|
||||||
|
|
||||||
|
HANDLE STDCALL
|
||||||
|
DuplicateConsoleHandle (HANDLE hConsole,
|
||||||
|
DWORD dwDesiredAccess,
|
||||||
|
BOOL bInheritHandle,
|
||||||
|
DWORD dwOptions);
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
WINBOOL WINAPI GetHandleInformation(HANDLE hObject, LPDWORD lpdwFlags)
|
WINBOOL WINAPI GetHandleInformation(HANDLE hObject, LPDWORD lpdwFlags)
|
||||||
|
@ -119,18 +130,20 @@ WINBOOL STDCALL DuplicateHandle(HANDLE hSourceProcessHandle,
|
||||||
DWORD dwOptions)
|
DWORD dwOptions)
|
||||||
{
|
{
|
||||||
NTSTATUS errCode;
|
NTSTATUS errCode;
|
||||||
|
DWORD SourceProcessId, TargetProcessId;
|
||||||
if (IsConsoleHandle(hSourceHandle))
|
if (IsConsoleHandle(hSourceHandle))
|
||||||
{
|
{
|
||||||
/* FIXME: call CSRSS for console handle duplication */
|
if (FALSE == GetProcessId(hSourceProcessHandle, &SourceProcessId) ||
|
||||||
if (hSourceProcessHandle == hTargetProcessHandle)
|
FALSE == GetProcessId(hTargetProcessHandle, &TargetProcessId) ||
|
||||||
{
|
SourceProcessId != TargetProcessId ||
|
||||||
*lpTargetHandle = hSourceHandle;
|
SourceProcessId != GetCurrentProcessId())
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*lpTargetHandle = DuplicateConsoleHandle(hSourceHandle, dwDesiredAccess, bInheritHandle, dwOptions);
|
||||||
|
return *lpTargetHandle != INVALID_HANDLE_VALUE ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
errCode = NtDuplicateObject(hSourceProcessHandle,
|
errCode = NtDuplicateObject(hSourceProcessHandle,
|
||||||
|
|
Loading…
Reference in a new issue