1998-02-15 19:40:49 +00:00
|
|
|
/*
|
|
|
|
* Win32 process handles
|
|
|
|
*
|
|
|
|
* Copyright 1998 Alexandre Julliard
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-02-15 19:40:49 +00:00
|
|
|
*/
|
|
|
|
|
2002-08-17 00:43:16 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-02-15 19:40:49 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
2002-08-28 23:42:34 +00:00
|
|
|
#ifdef HAVE_IO_H
|
|
|
|
# include <io.h>
|
|
|
|
#endif
|
2002-08-17 00:43:16 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
1998-02-15 19:40:49 +00:00
|
|
|
#include "winbase.h"
|
2001-07-19 00:39:09 +00:00
|
|
|
#include "wine/server.h"
|
1999-04-22 14:55:06 +00:00
|
|
|
#include "winerror.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
1998-04-13 12:21:30 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(win32);
|
1998-04-13 12:21:30 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-11 18:56:41 +00:00
|
|
|
* CloseW32Handle (KERNEL.474)
|
|
|
|
* CloseHandle (KERNEL32.@)
|
1998-04-13 12:21:30 +00:00
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL WINAPI CloseHandle( HANDLE handle )
|
1998-04-13 12:21:30 +00:00
|
|
|
{
|
2000-08-30 00:00:48 +00:00
|
|
|
NTSTATUS status;
|
|
|
|
|
1999-11-04 02:49:06 +00:00
|
|
|
/* stdio handles need special treatment */
|
2002-07-31 17:20:00 +00:00
|
|
|
if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
|
|
|
|
(handle == (HANDLE)STD_OUTPUT_HANDLE) ||
|
|
|
|
(handle == (HANDLE)STD_ERROR_HANDLE))
|
|
|
|
handle = GetStdHandle( (DWORD)handle );
|
2000-08-30 00:00:48 +00:00
|
|
|
|
|
|
|
status = NtClose( handle );
|
|
|
|
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
1998-04-13 12:21:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-02-15 19:40:49 +00:00
|
|
|
/*********************************************************************
|
2001-06-13 20:13:18 +00:00
|
|
|
* GetHandleInformation (KERNEL32.@)
|
1998-02-15 19:40:49 +00:00
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
|
1998-02-15 19:40:49 +00:00
|
|
|
{
|
2000-08-30 00:00:48 +00:00
|
|
|
BOOL ret;
|
2001-02-27 02:09:16 +00:00
|
|
|
SERVER_START_REQ( set_handle_info )
|
2000-08-30 00:00:48 +00:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
2000-12-22 02:04:15 +00:00
|
|
|
req->flags = 0;
|
|
|
|
req->mask = 0;
|
|
|
|
req->fd = -1;
|
2001-11-30 18:46:42 +00:00
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
if (ret && flags) *flags = reply->old_flags;
|
2000-08-30 00:00:48 +00:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1998-02-15 19:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-13 20:13:18 +00:00
|
|
|
* SetHandleInformation (KERNEL32.@)
|
1998-02-15 19:40:49 +00:00
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
|
1998-02-15 19:40:49 +00:00
|
|
|
{
|
2000-08-30 00:00:48 +00:00
|
|
|
BOOL ret;
|
2001-02-27 02:09:16 +00:00
|
|
|
SERVER_START_REQ( set_handle_info )
|
2000-08-30 00:00:48 +00:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
req->flags = flags;
|
|
|
|
req->mask = mask;
|
2000-12-22 02:04:15 +00:00
|
|
|
req->fd = -1;
|
2001-11-30 18:46:42 +00:00
|
|
|
ret = !wine_server_call_err( req );
|
2000-08-30 00:00:48 +00:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1998-02-15 19:40:49 +00:00
|
|
|
}
|
1998-04-13 12:21:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-13 20:13:18 +00:00
|
|
|
* DuplicateHandle (KERNEL32.@)
|
1998-04-13 12:21:30 +00:00
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
|
2002-09-16 19:32:50 +00:00
|
|
|
HANDLE dest_process, HANDLE *dest,
|
|
|
|
DWORD access, BOOL inherit, DWORD options )
|
1998-04-13 12:21:30 +00:00
|
|
|
{
|
2002-09-16 19:32:50 +00:00
|
|
|
NTSTATUS status = NtDuplicateObject( source_process, source, dest_process, dest,
|
|
|
|
access, inherit ? OBJ_INHERIT : 0, options );
|
|
|
|
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
1998-04-13 12:21:30 +00:00
|
|
|
}
|
1998-12-31 15:52:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-02-14 23:11:17 +00:00
|
|
|
* ConvertToGlobalHandle (KERNEL.476)
|
|
|
|
* ConvertToGlobalHandle (KERNEL32.@)
|
1998-12-31 15:52:06 +00:00
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
|
1998-12-31 15:52:06 +00:00
|
|
|
{
|
2000-12-24 20:33:01 +00:00
|
|
|
HANDLE ret = INVALID_HANDLE_VALUE;
|
2001-01-05 04:08:07 +00:00
|
|
|
DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
|
2000-08-30 00:00:48 +00:00
|
|
|
DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
|
|
|
|
return ret;
|
1998-12-31 15:52:06 +00:00
|
|
|
}
|
1999-04-22 14:55:06 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-02-14 23:11:17 +00:00
|
|
|
* SetHandleContext (KERNEL32.@)
|
1999-04-22 14:55:06 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
|
2000-07-15 21:29:34 +00:00
|
|
|
FIXME("(%d,%ld), stub. In case this got called by WSOCK32/WS2_32: the external WINSOCK DLLs won't work with WINE, don't use them.\n",hnd,context);
|
1999-04-22 14:55:06 +00:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-02-14 23:11:17 +00:00
|
|
|
* GetHandleContext (KERNEL32.@)
|
1999-04-22 14:55:06 +00:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetHandleContext(HANDLE hnd) {
|
2000-07-15 21:29:34 +00:00
|
|
|
FIXME("(%d), stub. In case this got called by WSOCK32/WS2_32: the external WINSOCK DLLs won't work with WINE, don't use them.\n",hnd);
|
1999-04-22 14:55:06 +00:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-02-14 23:11:17 +00:00
|
|
|
* CreateSocketHandle (KERNEL32.@)
|
1999-04-22 14:55:06 +00:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateSocketHandle(void) {
|
2000-07-15 21:29:34 +00:00
|
|
|
FIXME("(), stub. In case this got called by WSOCK32/WS2_32: the external WINSOCK DLLs won't work with WINE, don't use them.\n");
|
1999-04-22 14:55:06 +00:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|