2 * Win32 process handles
4 * Copyright 1998 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "wine/server.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(win32);
38 /*********************************************************************
39 * CloseW32Handle (KERNEL.474)
40 * CloseHandle (KERNEL32.@)
42 BOOL WINAPI CloseHandle( HANDLE handle )
46 /* stdio handles need special treatment */
47 if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
48 (handle == (HANDLE)STD_OUTPUT_HANDLE) ||
49 (handle == (HANDLE)STD_ERROR_HANDLE))
50 handle = GetStdHandle( (DWORD)handle );
52 status = NtClose( handle );
53 if (status) SetLastError( RtlNtStatusToDosError(status) );
58 /*********************************************************************
59 * GetHandleInformation (KERNEL32.@)
61 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
64 SERVER_START_REQ( set_handle_info )
70 ret = !wine_server_call_err( req );
71 if (ret && flags) *flags = reply->old_flags;
78 /*********************************************************************
79 * SetHandleInformation (KERNEL32.@)
81 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
84 SERVER_START_REQ( set_handle_info )
90 ret = !wine_server_call_err( req );
97 /*********************************************************************
98 * DuplicateHandle (KERNEL32.@)
100 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
101 HANDLE dest_process, HANDLE *dest,
102 DWORD access, BOOL inherit, DWORD options )
105 SERVER_START_REQ( dup_handle )
107 req->src_process = source_process;
108 req->src_handle = source;
109 req->dst_process = dest_process;
110 req->access = access;
111 req->inherit = inherit;
112 req->options = options;
114 ret = !wine_server_call_err( req );
117 if (dest) *dest = reply->handle;
118 if (reply->fd != -1) close( reply->fd );
126 /***********************************************************************
127 * ConvertToGlobalHandle (KERNEL.476)
128 * ConvertToGlobalHandle (KERNEL32.@)
130 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
132 HANDLE ret = INVALID_HANDLE_VALUE;
133 DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
134 DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
138 /***********************************************************************
139 * SetHandleContext (KERNEL32.@)
141 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
142 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);
143 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
147 /***********************************************************************
148 * GetHandleContext (KERNEL32.@)
150 DWORD WINAPI GetHandleContext(HANDLE hnd) {
151 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);
152 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
156 /***********************************************************************
157 * CreateSocketHandle (KERNEL32.@)
159 HANDLE WINAPI CreateSocketHandle(void) {
160 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");
161 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
162 return INVALID_HANDLE_VALUE;