Define environment variable TMP as an alias for TEMP.
[wine/multimedia.git] / scheduler / handle.c
blobf60d4b851d8cec95f5d346ba8158291f6e33538f
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 (KERNEL32.23)
20 BOOL WINAPI CloseHandle( HANDLE handle )
22 NTSTATUS status;
24 /* stdio handles need special treatment */
25 if ((handle == STD_INPUT_HANDLE) ||
26 (handle == STD_OUTPUT_HANDLE) ||
27 (handle == STD_ERROR_HANDLE))
28 handle = GetStdHandle( handle );
30 status = NtClose( handle );
31 if (status) SetLastError( RtlNtStatusToDosError(status) );
32 return !status;
36 /*********************************************************************
37 * GetHandleInformation (KERNEL32.336)
39 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
41 BOOL ret;
42 SERVER_START_REQ
44 struct set_handle_info_request *req = server_alloc_req( sizeof(*req), 0 );
45 req->handle = handle;
46 req->flags = 0;
47 req->mask = 0;
48 req->fd = -1;
49 ret = !server_call( REQ_SET_HANDLE_INFO );
50 if (ret && flags) *flags = req->old_flags;
52 SERVER_END_REQ;
53 return ret;
57 /*********************************************************************
58 * SetHandleInformation (KERNEL32.653)
60 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
62 BOOL ret;
63 SERVER_START_REQ
65 struct set_handle_info_request *req = server_alloc_req( sizeof(*req), 0 );
66 req->handle = handle;
67 req->flags = flags;
68 req->mask = mask;
69 req->fd = -1;
70 ret = !server_call( REQ_SET_HANDLE_INFO );
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
87 struct dup_handle_request *req = server_alloc_req( sizeof(*req), 0 );
89 req->src_process = source_process;
90 req->src_handle = source;
91 req->dst_process = dest_process;
92 req->access = access;
93 req->inherit = inherit;
94 req->options = options;
96 ret = !server_call( REQ_DUP_HANDLE );
97 if (ret)
99 if (dest) *dest = req->handle;
100 if (req->fd != -1) close( req->fd );
103 SERVER_END_REQ;
104 return ret;
108 /***********************************************************************
109 * ConvertToGlobalHandle (KERNEL32)
111 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
113 HANDLE ret = -1;
114 DuplicateHandle( GetCurrentProcess(), hSrc, (HANDLE)-1, &ret, 0, FALSE,
115 DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
116 return ret;
119 /***********************************************************************
120 * SetHandleContext (KERNEL32)
122 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
123 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);
124 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
125 return FALSE;
128 /***********************************************************************
129 * GetHandleContext (KERNEL32)
131 DWORD WINAPI GetHandleContext(HANDLE hnd) {
132 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);
133 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
134 return 0;
137 /***********************************************************************
138 * CreateSocketHandle (KERNEL32)
140 HANDLE WINAPI CreateSocketHandle(void) {
141 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");
142 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
143 return INVALID_HANDLE_VALUE;