2 * Win32 process handles
4 * Copyright 1998 Alexandre Julliard
13 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(win32
);
17 /*********************************************************************
18 * CloseHandle (KERNEL32.23)
20 BOOL WINAPI
CloseHandle( HANDLE handle
)
24 /* stdio handles need special treatment */
25 if ((handle
== STD_INPUT_HANDLE
) ||
26 (handle
== STD_OUTPUT_HANDLE
) ||
27 (handle
== STD_ERROR_HANDLE
))
28 handle
= GetStdHandle( handle
);
30 status
= NtClose( handle
);
31 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
36 /*********************************************************************
37 * GetHandleInformation (KERNEL32.336)
39 BOOL WINAPI
GetHandleInformation( HANDLE handle
, LPDWORD flags
)
44 struct set_handle_info_request
*req
= server_alloc_req( sizeof(*req
), 0 );
49 ret
= !server_call( REQ_SET_HANDLE_INFO
);
50 if (ret
&& flags
) *flags
= req
->old_flags
;
57 /*********************************************************************
58 * SetHandleInformation (KERNEL32.653)
60 BOOL WINAPI
SetHandleInformation( HANDLE handle
, DWORD mask
, DWORD flags
)
65 struct set_handle_info_request
*req
= server_alloc_req( sizeof(*req
), 0 );
70 ret
= !server_call( REQ_SET_HANDLE_INFO
);
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
)
87 struct dup_handle_request
*req
= server_alloc_req( sizeof(*req
), 0 );
89 req
->src_process
= source_process
;
90 req
->src_handle
= source
;
91 req
->dst_process
= dest_process
;
93 req
->inherit
= inherit
;
94 req
->options
= options
;
96 ret
= !server_call( REQ_DUP_HANDLE
);
99 if (dest
) *dest
= req
->handle
;
100 if (req
->fd
!= -1) close( req
->fd
);
108 /***********************************************************************
109 * ConvertToGlobalHandle (KERNEL32)
111 HANDLE WINAPI
ConvertToGlobalHandle(HANDLE hSrc
)
114 DuplicateHandle( GetCurrentProcess(), hSrc
, (HANDLE
)-1, &ret
, 0, FALSE
,
115 DUP_HANDLE_MAKE_GLOBAL
| DUP_HANDLE_SAME_ACCESS
| DUP_HANDLE_CLOSE_SOURCE
);
119 /***********************************************************************
120 * SetHandleContext (KERNEL32)
122 BOOL WINAPI
SetHandleContext(HANDLE hnd
,DWORD context
) {
123 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
);
124 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
128 /***********************************************************************
129 * GetHandleContext (KERNEL32)
131 DWORD WINAPI
GetHandleContext(HANDLE hnd
) {
132 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
);
133 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
137 /***********************************************************************
138 * CreateSocketHandle (KERNEL32)
140 HANDLE WINAPI
CreateSocketHandle(void) {
141 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");
142 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
143 return INVALID_HANDLE_VALUE
;