1998-02-15 20:40:49 +01:00
|
|
|
/*
|
|
|
|
* Win32 process handles
|
|
|
|
*
|
|
|
|
* Copyright 1998 Alexandre Julliard
|
2002-03-10 00:29:33 +01: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 20:40:49 +01:00
|
|
|
*/
|
|
|
|
|
2002-08-17 02:43:16 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-02-15 20:40:49 +01:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
1998-02-15 20:40:49 +01:00
|
|
|
#include "winbase.h"
|
2001-07-19 02:39:09 +02:00
|
|
|
#include "wine/server.h"
|
1999-04-22 16:55:06 +02:00
|
|
|
#include "winerror.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1998-04-13 14:21:30 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(win32);
|
1998-04-13 14:21:30 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-11 20:56:41 +02:00
|
|
|
* CloseW32Handle (KERNEL.474)
|
|
|
|
* CloseHandle (KERNEL32.@)
|
1998-04-13 14:21:30 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI CloseHandle( HANDLE handle )
|
1998-04-13 14:21:30 +02:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
1999-11-04 03:49:06 +01:00
|
|
|
/* stdio handles need special treatment */
|
2002-07-31 19:20:00 +02:00
|
|
|
if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
|
|
|
|
(handle == (HANDLE)STD_OUTPUT_HANDLE) ||
|
|
|
|
(handle == (HANDLE)STD_ERROR_HANDLE))
|
|
|
|
handle = GetStdHandle( (DWORD)handle );
|
2000-08-30 02:00:48 +02:00
|
|
|
|
|
|
|
status = NtClose( handle );
|
|
|
|
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
1998-04-13 14:21:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-02-15 20:40:49 +01:00
|
|
|
/*********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetHandleInformation (KERNEL32.@)
|
1998-02-15 20:40:49 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
|
1998-02-15 20:40:49 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
BOOL ret;
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( set_handle_info )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
2000-12-22 03:04:15 +01:00
|
|
|
req->flags = 0;
|
|
|
|
req->mask = 0;
|
|
|
|
req->fd = -1;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
if (ret && flags) *flags = reply->old_flags;
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1998-02-15 20:40:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetHandleInformation (KERNEL32.@)
|
1998-02-15 20:40:49 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
|
1998-02-15 20:40:49 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
BOOL ret;
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( set_handle_info )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
req->flags = flags;
|
|
|
|
req->mask = mask;
|
2000-12-22 03:04:15 +01:00
|
|
|
req->fd = -1;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1998-02-15 20:40:49 +01:00
|
|
|
}
|
1998-04-13 14:21:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DuplicateHandle (KERNEL32.@)
|
1998-04-13 14:21:30 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
|
|
|
|
HANDLE dest_process, HANDLE *dest,
|
|
|
|
DWORD access, BOOL inherit, DWORD options )
|
1998-04-13 14:21:30 +02:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
BOOL ret;
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( dup_handle )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->src_process = source_process;
|
|
|
|
req->src_handle = source;
|
|
|
|
req->dst_process = dest_process;
|
|
|
|
req->access = access;
|
|
|
|
req->inherit = inherit;
|
|
|
|
req->options = options;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2000-12-22 03:04:15 +01:00
|
|
|
if (ret)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
if (dest) *dest = reply->handle;
|
|
|
|
if (reply->fd != -1) close( reply->fd );
|
2000-12-22 03:04:15 +01:00
|
|
|
}
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1998-04-13 14:21:30 +02:00
|
|
|
}
|
1998-12-31 16:52:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* ConvertToGlobalHandle (KERNEL.476)
|
|
|
|
* ConvertToGlobalHandle (KERNEL32.@)
|
1998-12-31 16:52:06 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
|
1998-12-31 16:52:06 +01:00
|
|
|
{
|
2000-12-24 21:33:01 +01:00
|
|
|
HANDLE ret = INVALID_HANDLE_VALUE;
|
2001-01-05 05:08:07 +01:00
|
|
|
DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
|
2000-08-30 02:00:48 +02:00
|
|
|
DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
|
|
|
|
return ret;
|
1998-12-31 16:52:06 +01:00
|
|
|
}
|
1999-04-22 16:55:06 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SetHandleContext (KERNEL32.@)
|
1999-04-22 16:55:06 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
|
2000-07-15 23:29:34 +02: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 16:55:06 +02:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetHandleContext (KERNEL32.@)
|
1999-04-22 16:55:06 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetHandleContext(HANDLE hnd) {
|
2000-07-15 23:29:34 +02: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 16:55:06 +02:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* CreateSocketHandle (KERNEL32.@)
|
1999-04-22 16:55:06 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateSocketHandle(void) {
|
2000-07-15 23:29:34 +02: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 16:55:06 +02:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|