2 * Win32 process handles
4 * Copyright 1998 Alexandre Julliard
13 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(win32);
17 /*********************************************************************
18 * CloseHandle (KERNEL.11)
19 * CloseHandle (WIN32S16.11)
20 * CloseHandle (KERNEL32.@)
22 BOOL WINAPI CloseHandle( HANDLE handle )
26 /* stdio handles need special treatment */
27 if ((handle == STD_INPUT_HANDLE) ||
28 (handle == STD_OUTPUT_HANDLE) ||
29 (handle == STD_ERROR_HANDLE))
30 handle = GetStdHandle( handle );
32 status = NtClose( handle );
33 if (status) SetLastError( RtlNtStatusToDosError(status) );
38 /*********************************************************************
39 * GetHandleInformation (KERNEL32.336)
41 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
44 SERVER_START_REQ( set_handle_info )
50 ret = !SERVER_CALL_ERR();
51 if (ret && flags) *flags = req->old_flags;
58 /*********************************************************************
59 * SetHandleInformation (KERNEL32.653)
61 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
64 SERVER_START_REQ( set_handle_info )
70 ret = !SERVER_CALL_ERR();
77 /*********************************************************************
78 * DuplicateHandle (KERNEL32.192)
80 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
81 HANDLE dest_process, HANDLE *dest,
82 DWORD access, BOOL inherit, DWORD options )
85 SERVER_START_REQ( dup_handle )
87 req->src_process = source_process;
88 req->src_handle = source;
89 req->dst_process = dest_process;
91 req->inherit = inherit;
92 req->options = options;
94 ret = !SERVER_CALL_ERR();
97 if (dest) *dest = req->handle;
98 if (req->fd != -1) close( req->fd );
106 /***********************************************************************
107 * ConvertToGlobalHandle (KERNEL.476)
108 * ConvertToGlobalHandle (KERNEL32.@)
110 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
112 HANDLE ret = INVALID_HANDLE_VALUE;
113 DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
114 DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
118 /***********************************************************************
119 * SetHandleContext (KERNEL32.@)
121 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
122 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);
123 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
127 /***********************************************************************
128 * GetHandleContext (KERNEL32.@)
130 DWORD WINAPI GetHandleContext(HANDLE hnd) {
131 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);
132 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
136 /***********************************************************************
137 * CreateSocketHandle (KERNEL32.@)
139 HANDLE WINAPI CreateSocketHandle(void) {
140 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");
141 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
142 return INVALID_HANDLE_VALUE;