WINE_UNICODE_TEXT was incorrect.
[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 <unistd.h>
10 #include "winbase.h"
11 #include "server.h"
12 #include "winerror.h"
13 #include "debugtools.h"
14
15 DEFAULT_DEBUG_CHANNEL(win32);
16
17 /*********************************************************************
18  *           CloseHandle   (KERNEL.11)
19  *           CloseHandle   (WIN32S16.11)
20  *           CloseHandle   (KERNEL32.@)
21  */
22 BOOL WINAPI CloseHandle( HANDLE handle )
23 {
24     NTSTATUS status;
25
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 );
31
32     status = NtClose( handle );
33     if (status) SetLastError( RtlNtStatusToDosError(status) );
34     return !status;
35 }
36
37
38 /*********************************************************************
39  *           GetHandleInformation   (KERNEL32.336)
40  */
41 BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
42 {
43     BOOL ret;
44     SERVER_START_REQ( set_handle_info )
45     {
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;
52     }
53     SERVER_END_REQ;
54     return ret;
55 }
56
57
58 /*********************************************************************
59  *           SetHandleInformation   (KERNEL32.653)
60  */
61 BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
62 {
63     BOOL ret;
64     SERVER_START_REQ( set_handle_info )
65     {
66         req->handle = handle;
67         req->flags  = flags;
68         req->mask   = mask;
69         req->fd     = -1;
70         ret = !SERVER_CALL_ERR();
71     }
72     SERVER_END_REQ;
73     return ret;
74 }
75
76
77 /*********************************************************************
78  *           DuplicateHandle   (KERNEL32.192)
79  */
80 BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
81                                HANDLE dest_process, HANDLE *dest,
82                                DWORD access, BOOL inherit, DWORD options )
83 {
84     BOOL ret;
85     SERVER_START_REQ( dup_handle )
86     {
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;
93
94         ret = !SERVER_CALL_ERR();
95         if (ret)
96         {
97             if (dest) *dest = req->handle;
98             if (req->fd != -1) close( req->fd );
99         }
100     }
101     SERVER_END_REQ;
102     return ret;
103 }
104
105
106 /***********************************************************************
107  *           ConvertToGlobalHandle              (KERNEL.476)
108  *           ConvertToGlobalHandle              (KERNEL32.@)
109  */
110 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
111 {
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;
116 }
117
118 /***********************************************************************
119  *           SetHandleContext                   (KERNEL32.@)
120  */
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;
125 }
126
127 /***********************************************************************
128  *           GetHandleContext                   (KERNEL32.@)
129  */
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;
134 }
135
136 /***********************************************************************
137  *           CreateSocketHandle                 (KERNEL32.@)
138  */
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;
143 }