Removed the code duplication.
[wine.git] / scheduler / handle.c
blob21c60213a69a3903d0e3536eb7531163de9da3f9
1 /*
2 * Win32 process handles
4 * Copyright 1998 Alexandre Julliard
5 */
7 #include <assert.h>
8 #include <stdio.h>
9 #include "winbase.h"
10 #include "server.h"
11 #include "winerror.h"
12 #include "debugtools.h"
14 DEFAULT_DEBUG_CHANNEL(win32);
16 /*********************************************************************
17 * CloseHandle (KERNEL32.23)
19 BOOL WINAPI CloseHandle( HANDLE handle )
21 NTSTATUS status;
23 /* stdio handles need special treatment */
24 if ((handle == STD_INPUT_HANDLE) ||
25 (handle == STD_OUTPUT_HANDLE) ||
26 (handle == STD_ERROR_HANDLE))
27 handle = GetStdHandle( handle );
29 status = NtClose( handle );
30 if (status) SetLastError( RtlNtStatusToDosError(status) );
31 return !status;
35 /*********************************************************************
36 * GetHandleInformation (KERNEL32.336)
38 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
40 BOOL ret;
41 SERVER_START_REQ
43 struct get_handle_info_request *req = server_alloc_req( sizeof(*req), 0 );
44 req->handle = handle;
45 ret = !server_call( REQ_GET_HANDLE_INFO );
46 if (ret && flags) *flags = req->flags;
48 SERVER_END_REQ;
49 return ret;
53 /*********************************************************************
54 * SetHandleInformation (KERNEL32.653)
56 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
58 BOOL ret;
59 SERVER_START_REQ
61 struct set_handle_info_request *req = server_alloc_req( sizeof(*req), 0 );
62 req->handle = handle;
63 req->flags = flags;
64 req->mask = mask;
65 ret = !server_call( REQ_SET_HANDLE_INFO );
67 SERVER_END_REQ;
68 return ret;
72 /*********************************************************************
73 * DuplicateHandle (KERNEL32.192)
75 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
76 HANDLE dest_process, HANDLE *dest,
77 DWORD access, BOOL inherit, DWORD options )
79 BOOL ret;
80 SERVER_START_REQ
82 struct dup_handle_request *req = server_alloc_req( sizeof(*req), 0 );
84 req->src_process = source_process;
85 req->src_handle = source;
86 req->dst_process = dest_process;
87 req->access = access;
88 req->inherit = inherit;
89 req->options = options;
91 ret = !server_call( REQ_DUP_HANDLE );
92 if (ret && dest) *dest = req->handle;
94 SERVER_END_REQ;
95 return ret;
99 /***********************************************************************
100 * ConvertToGlobalHandle (KERNEL32)
102 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
104 HANDLE ret = -1;
105 DuplicateHandle( GetCurrentProcess(), hSrc, (HANDLE)-1, &ret, 0, FALSE,
106 DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
107 return ret;
110 /***********************************************************************
111 * SetHandleContext (KERNEL32)
113 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
114 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);
115 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
116 return FALSE;
119 /***********************************************************************
120 * GetHandleContext (KERNEL32)
122 DWORD WINAPI GetHandleContext(HANDLE hnd) {
123 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);
124 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
125 return 0;
128 /***********************************************************************
129 * CreateSocketHandle (KERNEL32)
131 HANDLE WINAPI CreateSocketHandle(void) {
132 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");
133 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
134 return INVALID_HANDLE_VALUE;