New set of macros for server calls; makes requests without variable
[wine/multimedia.git] / scheduler / handle.c
blob81d467280058113b1eee31a1eca010e979eacc40
1 /*
2 * Win32 process handles
4 * Copyright 1998 Alexandre Julliard
5 */
7 #include <assert.h>
8 #include <stdio.h>
9 #include <unistd.h>
10 #include "winbase.h"
11 #include "server.h"
12 #include "winerror.h"
13 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(win32);
17 /*********************************************************************
18 * CloseHandle (KERNEL.11)
19 * CloseHandle (WIN32S16.11)
20 * CloseHandle (KERNEL32.@)
22 BOOL WINAPI CloseHandle( HANDLE handle )
24 NTSTATUS status;
26 /* stdio handles need special treatment */
27 if ((handle == STD_INPUT_HANDLE) ||
28 (handle == STD_OUTPUT_HANDLE) ||
29 (handle == STD_ERROR_HANDLE))
30 handle = GetStdHandle( handle );
32 status = NtClose( handle );
33 if (status) SetLastError( RtlNtStatusToDosError(status) );
34 return !status;
38 /*********************************************************************
39 * GetHandleInformation (KERNEL32.336)
41 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
43 BOOL ret;
44 SERVER_START_REQ( set_handle_info )
46 req->handle = handle;
47 req->flags = 0;
48 req->mask = 0;
49 req->fd = -1;
50 ret = !SERVER_CALL_ERR();
51 if (ret && flags) *flags = req->old_flags;
53 SERVER_END_REQ;
54 return ret;
58 /*********************************************************************
59 * SetHandleInformation (KERNEL32.653)
61 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
63 BOOL ret;
64 SERVER_START_REQ( set_handle_info )
66 req->handle = handle;
67 req->flags = flags;
68 req->mask = mask;
69 req->fd = -1;
70 ret = !SERVER_CALL_ERR();
72 SERVER_END_REQ;
73 return ret;
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 )
84 BOOL ret;
85 SERVER_START_REQ( dup_handle )
87 req->src_process = source_process;
88 req->src_handle = source;
89 req->dst_process = dest_process;
90 req->access = access;
91 req->inherit = inherit;
92 req->options = options;
94 ret = !SERVER_CALL_ERR();
95 if (ret)
97 if (dest) *dest = req->handle;
98 if (req->fd != -1) close( req->fd );
101 SERVER_END_REQ;
102 return ret;
106 /***********************************************************************
107 * ConvertToGlobalHandle (KERNEL.476)
108 * ConvertToGlobalHandle (KERNEL32.@)
110 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
112 HANDLE ret = INVALID_HANDLE_VALUE;
113 DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
114 DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
115 return ret;
118 /***********************************************************************
119 * SetHandleContext (KERNEL32.@)
121 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
122 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);
123 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
124 return FALSE;
127 /***********************************************************************
128 * GetHandleContext (KERNEL32.@)
130 DWORD WINAPI GetHandleContext(HANDLE hnd) {
131 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);
132 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
133 return 0;
136 /***********************************************************************
137 * CreateSocketHandle (KERNEL32.@)
139 HANDLE WINAPI CreateSocketHandle(void) {
140 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");
141 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
142 return INVALID_HANDLE_VALUE;