Rearrange winver detection code and cache the winver value we
[wine.git] / scheduler / handle.c
blob98d9c59d9c8c85d57ff15b1beb6f566bd22fb98a
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"
11 #include "winerror.h"
12 #include "debugtools.h"
14 DEFAULT_DEBUG_CHANNEL(win32)
16 /*********************************************************************
17 * CloseHandle (KERNEL32.23)
19 BOOL WINAPI CloseHandle( HANDLE handle )
21 struct close_handle_request req;
23 req.handle = handle;
24 CLIENT_SendRequest( REQ_CLOSE_HANDLE, -1, 1, &req, sizeof(req) );
25 return !CLIENT_WaitReply( NULL, NULL, 0 );
29 /*********************************************************************
30 * GetHandleInformation (KERNEL32.336)
32 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
34 struct get_handle_info_request req;
35 struct get_handle_info_reply reply;
37 req.handle = handle;
38 CLIENT_SendRequest( REQ_GET_HANDLE_INFO, -1, 1, &req, sizeof(req) );
39 if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return FALSE;
40 if (flags) *flags = reply.flags;
41 return TRUE;
45 /*********************************************************************
46 * SetHandleInformation (KERNEL32.653)
48 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
50 struct set_handle_info_request req;
52 req.handle = handle;
53 req.flags = flags;
54 req.mask = mask;
55 CLIENT_SendRequest( REQ_SET_HANDLE_INFO, -1, 1, &req, sizeof(req) );
56 return !CLIENT_WaitReply( NULL, NULL, 0 );
60 /*********************************************************************
61 * DuplicateHandle (KERNEL32.192)
63 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
64 HANDLE dest_process, HANDLE *dest,
65 DWORD access, BOOL inherit, DWORD options )
67 struct dup_handle_request req;
68 struct dup_handle_reply reply;
70 req.src_process = source_process;
71 req.src_handle = source;
72 req.dst_process = dest_process;
73 req.access = access;
74 req.inherit = inherit;
75 req.options = options;
77 CLIENT_SendRequest( REQ_DUP_HANDLE, -1, 1, &req, sizeof(req) );
78 if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return FALSE;
79 if (dest) *dest = reply.handle;
80 return TRUE;
84 /***********************************************************************
85 * ConvertToGlobalHandle (KERNEL32)
87 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
89 struct dup_handle_request req;
90 struct dup_handle_reply reply;
92 req.src_process = GetCurrentProcess();
93 req.src_handle = hSrc;
94 req.dst_process = -1;
95 req.access = 0;
96 req.inherit = FALSE;
97 req.options = DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS;
99 CLIENT_SendRequest( REQ_DUP_HANDLE, -1, 1, &req, sizeof(req) );
100 CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
101 return reply.handle;
104 /***********************************************************************
105 * SetHandleContext (KERNEL32)
107 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context) {
108 FIXME("(%d,%ld), stub. The external WSOCK32 will not work with WINE, do not use it.\n",hnd,context);
109 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
110 return FALSE;
113 /***********************************************************************
114 * GetHandleContext (KERNEL32)
116 DWORD WINAPI GetHandleContext(HANDLE hnd) {
117 FIXME("(%d), stub. The external WSOCK32 will not work with WINE, do not use it.\n",hnd);
118 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
119 return 0;
122 /***********************************************************************
123 * CreateSocketHandle (KERNEL32)
125 HANDLE WINAPI CreateSocketHandle(void) {
126 FIXME("(), stub. The external WSOCK32 will not work with WINE, do not use it.\n");
127 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
128 return INVALID_HANDLE_VALUE;