1998-02-15 20:40:49 +01:00
|
|
|
/*
|
|
|
|
* Win32 process handles
|
|
|
|
*
|
|
|
|
* Copyright 1998 Alexandre Julliard
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
2000-12-22 03:04:15 +01:00
|
|
|
#include <unistd.h>
|
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"
|
1999-05-23 12:25:25 +02:00
|
|
|
#include "debugtools.h"
|
1998-04-13 14:21:30 +02:00
|
|
|
|
2000-11-28 00:54:25 +01:00
|
|
|
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 */
|
|
|
|
if ((handle == STD_INPUT_HANDLE) ||
|
|
|
|
(handle == STD_OUTPUT_HANDLE) ||
|
|
|
|
(handle == STD_ERROR_HANDLE))
|
|
|
|
handle = GetStdHandle( 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;
|
|
|
|
}
|