Get rid of the 32-bit user signal proc since we always run builtin
[wine] / scheduler / handle.c
1 /*
2  * Win32 process handles
3  *
4  * Copyright 1998 Alexandre Julliard
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22
23 #include <assert.h>
24 #include <stdio.h>
25 #ifdef HAVE_IO_H
26 # include <io.h>
27 #endif
28 #ifdef HAVE_UNISTD_H
29 # include <unistd.h>
30 #endif
31 #include "winbase.h"
32 #include "wine/server.h"
33 #include "winerror.h"
34 #include "wine/debug.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(win32);
37
38 /*********************************************************************
39  *           CloseW32Handle (KERNEL.474)
40  *           CloseHandle    (KERNEL32.@)
41  */
42 BOOL WINAPI CloseHandle( HANDLE handle )
43 {
44     NTSTATUS status;
45
46     /* stdio handles need special treatment */
47     if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
48         (handle == (HANDLE)STD_OUTPUT_HANDLE) ||
49         (handle == (HANDLE)STD_ERROR_HANDLE))
50         handle = GetStdHandle( (DWORD)handle );
51
52     status = NtClose( handle );
53     if (status) SetLastError( RtlNtStatusToDosError(status) );
54     return !status;
55 }
56
57
58 /*********************************************************************
59  *           GetHandleInformation   (KERNEL32.@)
60  */
61 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
62 {
63     BOOL ret;
64     SERVER_START_REQ( set_handle_info )
65     {
66         req->handle = handle;
67         req->flags  = 0;
68         req->mask   = 0;
69         req->fd     = -1;
70         ret = !wine_server_call_err( req );
71         if (ret && flags) *flags = reply->old_flags;
72     }
73     SERVER_END_REQ;
74     return ret;
75 }
76
77
78 /*********************************************************************
79  *           SetHandleInformation   (KERNEL32.@)
80  */
81 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
82 {
83     BOOL ret;
84     SERVER_START_REQ( set_handle_info )
85     {
86         req->handle = handle;
87         req->flags  = flags;
88         req->mask   = mask;
89         req->fd     = -1;
90         ret = !wine_server_call_err( req );
91     }
92     SERVER_END_REQ;
93     return ret;
94 }
95
96
97 /*********************************************************************
98  *           DuplicateHandle   (KERNEL32.@)
99  */
100 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
101                              HANDLE dest_process, HANDLE *dest,
102                              DWORD access, BOOL inherit, DWORD options )
103 {
104     NTSTATUS status = NtDuplicateObject( source_process, source, dest_process, dest,
105                                          access, inherit ? OBJ_INHERIT : 0, options );
106     if (status) SetLastError( RtlNtStatusToDosError(status) );
107     return !status;
108 }
109
110
111 /***********************************************************************
112  *           ConvertToGlobalHandle              (KERNEL.476)
113  *           ConvertToGlobalHandle              (KERNEL32.@)
114  */
115 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
116 {
117     HANDLE ret = INVALID_HANDLE_VALUE;
118     DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
119                      DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
120     return ret;
121 }
122
123 /***********************************************************************
124  *           SetHandleContext                   (KERNEL32.@)
125  */
126 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
127     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);
128     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
129     return FALSE;
130 }
131
132 /***********************************************************************
133  *           GetHandleContext                   (KERNEL32.@)
134  */
135 DWORD WINAPI GetHandleContext(HANDLE hnd) {
136     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);
137     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
138     return 0;
139 }
140
141 /***********************************************************************
142  *           CreateSocketHandle                 (KERNEL32.@)
143  */
144 HANDLE WINAPI CreateSocketHandle(void) {
145     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");
146     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
147     return INVALID_HANDLE_VALUE;
148 }