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
34 #include "wine/server.h"
36 #include "wine/debug.h"
37 #include "../kernel/kernel_private.h" /* FIXME: to be changed when moving file to dlls/kernel */
39 WINE_DEFAULT_DEBUG_CHANNEL(win32
);
41 /*********************************************************************
42 * CloseW32Handle (KERNEL.474)
43 * CloseHandle (KERNEL32.@)
45 BOOL WINAPI
CloseHandle( HANDLE handle
)
49 /* stdio handles need special treatment */
50 if ((handle
== (HANDLE
)STD_INPUT_HANDLE
) ||
51 (handle
== (HANDLE
)STD_OUTPUT_HANDLE
) ||
52 (handle
== (HANDLE
)STD_ERROR_HANDLE
))
53 handle
= GetStdHandle( (DWORD
)handle
);
55 if (is_console_handle(handle
))
56 return CloseConsoleHandle(handle
);
58 status
= NtClose( handle
);
59 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
64 /*********************************************************************
65 * GetHandleInformation (KERNEL32.@)
67 BOOL WINAPI
GetHandleInformation( HANDLE handle
, LPDWORD flags
)
70 SERVER_START_REQ( set_handle_info
)
76 ret
= !wine_server_call_err( req
);
77 if (ret
&& flags
) *flags
= reply
->old_flags
;
84 /*********************************************************************
85 * SetHandleInformation (KERNEL32.@)
87 BOOL WINAPI
SetHandleInformation( HANDLE handle
, DWORD mask
, DWORD flags
)
90 SERVER_START_REQ( set_handle_info
)
96 ret
= !wine_server_call_err( req
);
103 /*********************************************************************
104 * DuplicateHandle (KERNEL32.@)
106 BOOL WINAPI
DuplicateHandle( HANDLE source_process
, HANDLE source
,
107 HANDLE dest_process
, HANDLE
*dest
,
108 DWORD access
, BOOL inherit
, DWORD options
)
112 if (is_console_handle(source
))
114 /* FIXME: this test is not sufficient, we need to test process ids, not handles */
115 if (source_process
!= dest_process
||
116 source_process
!= GetCurrentProcess())
118 SetLastError(ERROR_INVALID_PARAMETER
);
121 *dest
= DuplicateConsoleHandle( source
, access
, inherit
, options
);
122 return (*dest
!= INVALID_HANDLE_VALUE
);
124 status
= NtDuplicateObject( source_process
, source
, dest_process
, dest
,
125 access
, inherit
? OBJ_INHERIT
: 0, options
);
126 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
131 /***********************************************************************
132 * ConvertToGlobalHandle (KERNEL.476)
133 * ConvertToGlobalHandle (KERNEL32.@)
135 HANDLE WINAPI
ConvertToGlobalHandle(HANDLE hSrc
)
137 HANDLE ret
= INVALID_HANDLE_VALUE
;
138 DuplicateHandle( GetCurrentProcess(), hSrc
, GetCurrentProcess(), &ret
, 0, FALSE
,
139 DUP_HANDLE_MAKE_GLOBAL
| DUP_HANDLE_SAME_ACCESS
| DUP_HANDLE_CLOSE_SOURCE
);
143 /***********************************************************************
144 * SetHandleContext (KERNEL32.@)
146 BOOL WINAPI
SetHandleContext(HANDLE hnd
,DWORD context
) {
147 FIXME("(%p,%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
);
148 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
152 /***********************************************************************
153 * GetHandleContext (KERNEL32.@)
155 DWORD WINAPI
GetHandleContext(HANDLE hnd
) {
156 FIXME("(%p), 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
);
157 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
161 /***********************************************************************
162 * CreateSocketHandle (KERNEL32.@)
164 HANDLE WINAPI
CreateSocketHandle(void) {
165 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");
166 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
167 return INVALID_HANDLE_VALUE
;