Duplicated wsprintf implementation in shlwapi.
[wine.git] / scheduler / handle.c
blobb19db57a8759ab58f8fd3e996617d84cb7548215
1 /*
2 * Win32 process handles
4 * Copyright 1998 Alexandre Julliard
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.
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.
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
21 #include <assert.h>
22 #include <stdio.h>
23 #include <unistd.h>
24 #include "winbase.h"
25 #include "wine/server.h"
26 #include "winerror.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(win32);
31 /*********************************************************************
32 * CloseW32Handle (KERNEL.474)
33 * CloseHandle (KERNEL32.@)
35 BOOL WINAPI CloseHandle( HANDLE handle )
37 NTSTATUS status;
39 /* stdio handles need special treatment */
40 if ((handle == STD_INPUT_HANDLE) ||
41 (handle == STD_OUTPUT_HANDLE) ||
42 (handle == STD_ERROR_HANDLE))
43 handle = GetStdHandle( handle );
45 status = NtClose( handle );
46 if (status) SetLastError( RtlNtStatusToDosError(status) );
47 return !status;
51 /*********************************************************************
52 * GetHandleInformation (KERNEL32.@)
54 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
56 BOOL ret;
57 SERVER_START_REQ( set_handle_info )
59 req->handle = handle;
60 req->flags = 0;
61 req->mask = 0;
62 req->fd = -1;
63 ret = !wine_server_call_err( req );
64 if (ret && flags) *flags = reply->old_flags;
66 SERVER_END_REQ;
67 return ret;
71 /*********************************************************************
72 * SetHandleInformation (KERNEL32.@)
74 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
76 BOOL ret;
77 SERVER_START_REQ( set_handle_info )
79 req->handle = handle;
80 req->flags = flags;
81 req->mask = mask;
82 req->fd = -1;
83 ret = !wine_server_call_err( req );
85 SERVER_END_REQ;
86 return ret;
90 /*********************************************************************
91 * DuplicateHandle (KERNEL32.@)
93 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
94 HANDLE dest_process, HANDLE *dest,
95 DWORD access, BOOL inherit, DWORD options )
97 BOOL ret;
98 SERVER_START_REQ( dup_handle )
100 req->src_process = source_process;
101 req->src_handle = source;
102 req->dst_process = dest_process;
103 req->access = access;
104 req->inherit = inherit;
105 req->options = options;
107 ret = !wine_server_call_err( req );
108 if (ret)
110 if (dest) *dest = reply->handle;
111 if (reply->fd != -1) close( reply->fd );
114 SERVER_END_REQ;
115 return ret;
119 /***********************************************************************
120 * ConvertToGlobalHandle (KERNEL.476)
121 * ConvertToGlobalHandle (KERNEL32.@)
123 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
125 HANDLE ret = INVALID_HANDLE_VALUE;
126 DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
127 DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
128 return ret;
131 /***********************************************************************
132 * SetHandleContext (KERNEL32.@)
134 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
135 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);
136 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
137 return FALSE;
140 /***********************************************************************
141 * GetHandleContext (KERNEL32.@)
143 DWORD WINAPI GetHandleContext(HANDLE hnd) {
144 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);
145 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
146 return 0;
149 /***********************************************************************
150 * CreateSocketHandle (KERNEL32.@)
152 HANDLE WINAPI CreateSocketHandle(void) {
153 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");
154 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
155 return INVALID_HANDLE_VALUE;