debug.h must be last, or we get ERR() macro problems again.
[wine/multimedia.git] / scheduler / handle.c
blobe4850f47c616804b4b2e4c4fc1fc7c63eba71f51
1 /*
2 * Win32 process handles
4 * Copyright 1998 Alexandre Julliard
5 */
7 #include <assert.h>
8 #include <stdio.h>
9 #include "winbase.h"
10 #include "server.h"
13 /*********************************************************************
14 * CloseHandle (KERNEL32.23)
16 BOOL WINAPI CloseHandle( HANDLE handle )
18 struct close_handle_request req = { handle };
19 CLIENT_SendRequest( REQ_CLOSE_HANDLE, -1, 1, &req, sizeof(req) );
20 return !CLIENT_WaitReply( NULL, NULL, 0 );
24 /*********************************************************************
25 * GetHandleInformation (KERNEL32.336)
27 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
29 struct get_handle_info_request req;
30 struct get_handle_info_reply reply;
32 req.handle = handle;
33 CLIENT_SendRequest( REQ_GET_HANDLE_INFO, -1, 1, &req, sizeof(req) );
34 if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return FALSE;
35 if (flags) *flags = reply.flags;
36 return TRUE;
40 /*********************************************************************
41 * SetHandleInformation (KERNEL32.653)
43 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
45 struct set_handle_info_request req;
47 req.handle = handle;
48 req.flags = flags;
49 req.mask = mask;
50 CLIENT_SendRequest( REQ_SET_HANDLE_INFO, -1, 1, &req, sizeof(req) );
51 return !CLIENT_WaitReply( NULL, NULL, 0 );
55 /*********************************************************************
56 * DuplicateHandle (KERNEL32.192)
58 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
59 HANDLE dest_process, HANDLE *dest,
60 DWORD access, BOOL inherit, DWORD options )
62 struct dup_handle_request req;
63 struct dup_handle_reply reply;
65 req.src_process = source_process;
66 req.src_handle = source;
67 req.dst_process = dest_process;
68 req.access = access;
69 req.inherit = inherit;
70 req.options = options;
72 CLIENT_SendRequest( REQ_DUP_HANDLE, -1, 1, &req, sizeof(req) );
73 if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return FALSE;
74 if (dest) *dest = reply.handle;
75 return TRUE;
79 /***********************************************************************
80 * ConvertToGlobalHandle (KERNEL32)
82 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
84 struct dup_handle_request req;
85 struct dup_handle_reply reply;
87 req.src_process = GetCurrentProcess();
88 req.src_handle = hSrc;
89 req.dst_process = -1;
90 req.access = 0;
91 req.inherit = FALSE;
92 req.options = DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS;
94 CLIENT_SendRequest( REQ_DUP_HANDLE, -1, 1, &req, sizeof(req) );
95 CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
96 return reply.handle;