Changed process initialisation to use the new server requests.
[wine] / scheduler / handle.c
1 /*
2  * Win32 process handles
3  *
4  * Copyright 1998 Alexandre Julliard
5  */
6
7 #include <assert.h>
8 #include <stdio.h>
9 #include "winbase.h"
10 #include "server.h"
11
12
13 /*********************************************************************
14  *           CloseHandle   (KERNEL32.23)
15  */
16 BOOL WINAPI CloseHandle( HANDLE handle )
17 {
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 );
21 }
22
23
24 /*********************************************************************
25  *           GetHandleInformation   (KERNEL32.336)
26  */
27 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
28 {
29     struct get_handle_info_request req;
30     struct get_handle_info_reply reply;
31
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;
37 }
38
39
40 /*********************************************************************
41  *           SetHandleInformation   (KERNEL32.653)
42  */
43 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
44 {
45     struct set_handle_info_request req;
46
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 );
52 }
53
54
55 /*********************************************************************
56  *           DuplicateHandle   (KERNEL32.192)
57  */
58 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
59                                HANDLE dest_process, HANDLE *dest,
60                                DWORD access, BOOL inherit, DWORD options )
61 {
62     struct dup_handle_request req;
63     struct dup_handle_reply reply;
64
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;
71
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;
76 }
77
78
79 /***********************************************************************
80  *           ConvertToGlobalHandle              (KERNEL32)
81  */
82 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
83 {
84     struct dup_handle_request req;
85     struct dup_handle_reply reply;
86
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;
93
94     CLIENT_SendRequest( REQ_DUP_HANDLE, -1, 1, &req, sizeof(req) );
95     CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
96     return reply.handle;
97 }