mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +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
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -16,6 +16,17 @@
|
|||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
WINBOOL STDCALL
|
||||
GetProcessId (HANDLE hProcess, LPDWORD lpProcessId);
|
||||
|
||||
HANDLE STDCALL
|
||||
DuplicateConsoleHandle (HANDLE hConsole,
|
||||
DWORD dwDesiredAccess,
|
||||
BOOL bInheritHandle,
|
||||
DWORD dwOptions);
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
WINBOOL WINAPI GetHandleInformation(HANDLE hObject, LPDWORD lpdwFlags)
|
||||
|
@ -119,18 +130,20 @@ WINBOOL STDCALL DuplicateHandle(HANDLE hSourceProcessHandle,
|
|||
DWORD dwOptions)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
DWORD SourceProcessId, TargetProcessId;
|
||||
if (IsConsoleHandle(hSourceHandle))
|
||||
{
|
||||
/* FIXME: call CSRSS for console handle duplication */
|
||||
if (hSourceProcessHandle == hTargetProcessHandle)
|
||||
if (FALSE == GetProcessId(hSourceProcessHandle, &SourceProcessId) ||
|
||||
FALSE == GetProcessId(hTargetProcessHandle, &TargetProcessId) ||
|
||||
SourceProcessId != TargetProcessId ||
|
||||
SourceProcessId != GetCurrentProcessId())
|
||||
{
|
||||
*lpTargetHandle = hSourceHandle;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*lpTargetHandle = DuplicateConsoleHandle(hSourceHandle, dwDesiredAccess, bInheritHandle, dwOptions);
|
||||
return *lpTargetHandle != INVALID_HANDLE_VALUE ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
errCode = NtDuplicateObject(hSourceProcessHandle,
|
||||
|
|
Loading…
Reference in a new issue