Removed redundant thread priority defines.
[wine] / scheduler / handle.c
1 /*
2  * Win32 process handles
3  *
4  * Copyright 1998 Alexandre Julliard
5  */
6
7 #include <assert.h>
8 #include <stdio.h>
9 #include "winbase.h"
10 #include "server.h"
11 #include "winerror.h"
12 #include "debugtools.h"
13
14 DEFAULT_DEBUG_CHANNEL(win32)
15
16 /*********************************************************************
17  *           CloseHandle   (KERNEL32.23)
18  */
19 BOOL WINAPI CloseHandle( HANDLE handle )
20 {
21     NTSTATUS status;
22
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 );
28
29     status = NtClose( handle );
30     if (status) SetLastError( RtlNtStatusToDosError(status) );
31     return !status;
32 }
33
34
35 /*********************************************************************
36  *           GetHandleInformation   (KERNEL32.336)
37  */
38 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
39 {
40     BOOL ret;
41     SERVER_START_REQ
42     {
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;
47     }
48     SERVER_END_REQ;
49     return ret;
50 }
51
52
53 /*********************************************************************
54  *           SetHandleInformation   (KERNEL32.653)
55  */
56 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
57 {
58     BOOL ret;
59     SERVER_START_REQ
60     {
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 );
66     }
67     SERVER_END_REQ;
68     return ret;
69 }
70
71
72 /*********************************************************************
73  *           DuplicateHandle   (KERNEL32.192)
74  */
75 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
76                                HANDLE dest_process, HANDLE *dest,
77                                DWORD access, BOOL inherit, DWORD options )
78 {
79     BOOL ret;
80     SERVER_START_REQ
81     {
82         struct dup_handle_request *req = server_alloc_req( sizeof(*req), 0 );
83
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;
90
91         ret = !server_call( REQ_DUP_HANDLE );
92         if (ret && dest) *dest = req->handle;
93     }
94     SERVER_END_REQ;
95     return ret;
96 }
97
98
99 /***********************************************************************
100  *           ConvertToGlobalHandle              (KERNEL32)
101  */
102 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
103 {
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;
108 }
109
110 /***********************************************************************
111  *           SetHandleContext                   (KERNEL32)
112  */
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;
117 }
118
119 /***********************************************************************
120  *           GetHandleContext                   (KERNEL32)
121  */
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;
126 }
127
128 /***********************************************************************
129  *           CreateSocketHandle                 (KERNEL32)
130  */
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;
135 }