]> sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/wincap.cc
* cygheap.h (cwdstuff::override_win32_cwd): Declare.
[newlib-cygwin.git] / winsup / cygwin / wincap.cc
1 /* wincap.cc -- figure out on which OS we're running. Set the
2 capability class to the appropriate values.
3
4 Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
5 2009, 2010 Red Hat, Inc.
6
7 This file is part of Cygwin.
8
9 This software is a copyrighted work licensed under the terms of the
10 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 details. */
12
13 #include "winsup.h"
14 #include "security.h"
15 #include "ntdll.h"
16
17 /* CV, 2008-10-23: All wincapc's have to be in the .cygwin_dll_common section,
18 same as wincap itself. Otherwise the capability changes made in
19 wincapc::init() are not propagated to any subsequently started process
20 in the same session. I'm only writing this longish comment because I'm
21 puzzled that this has never been noticed before... */
22
23 /* Minimal set of capabilities required to run Cygwin. */
24 #define wincap_minimal wincap_nt4sp4
25
26 wincaps wincap_nt4sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
27 chunksize:0,
28 heapslop:0x0,
29 max_sys_priv:SE_CHANGE_NOTIFY_PRIVILEGE,
30 is_server:false,
31 has_dacl_protect:false,
32 has_broken_if_oper_status:true,
33 has_physical_mem_access:true,
34 has_process_io_counters:false,
35 has_terminal_services:false,
36 has_create_global_privilege:false,
37 has_ioctl_storage_get_media_types_ex:false,
38 has_extended_priority_class:false,
39 has_guid_volumes:false,
40 has_disk_ex_ioctls:false,
41 has_fileid_dirinfo:false,
42 has_enhanced_socket_security:false,
43 has_buggy_restart_scan:false,
44 has_mandatory_integrity_control:false,
45 needs_logon_sid_in_sid_list:true,
46 needs_count_in_si_lpres2:false,
47 has_recycle_dot_bin:false,
48 has_gaa_prefixes:false,
49 has_gaa_on_link_prefix:false,
50 supports_all_posix_ai_flags:false,
51 has_restricted_stack_args:false,
52 has_transactions:false,
53 ts_has_dep_problem:false,
54 has_recvmsg:false,
55 has_sendmsg:false,
56 has_broken_udf:false,
57 has_console_handle_problem:false,
58 has_broken_alloc_console:false,
59 has_always_all_codepages:false,
60 has_localenames:false,
61 has_mwmo_inputavailable:false,
62 has_buggy_thread_startup:false,
63 has_fast_cwd:false,
64 };
65
66 wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = {
67 chunksize:0,
68 heapslop:0x0,
69 max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE,
70 is_server:false,
71 has_dacl_protect:true,
72 has_broken_if_oper_status:false,
73 has_physical_mem_access:true,
74 has_process_io_counters:true,
75 has_terminal_services:true,
76 has_create_global_privilege:false,
77 has_ioctl_storage_get_media_types_ex:false,
78 has_extended_priority_class:true,
79 has_guid_volumes:true,
80 has_disk_ex_ioctls:false,
81 has_fileid_dirinfo:true,
82 has_enhanced_socket_security:false,
83 has_buggy_restart_scan:true,
84 has_mandatory_integrity_control:false,
85 needs_logon_sid_in_sid_list:true,
86 needs_count_in_si_lpres2:false,
87 has_recycle_dot_bin:false,
88 has_gaa_prefixes:false,
89 has_gaa_on_link_prefix:false,
90 supports_all_posix_ai_flags:false,
91 has_restricted_stack_args:false,
92 has_transactions:false,
93 ts_has_dep_problem:false,
94 has_recvmsg:false,
95 has_sendmsg:false,
96 has_broken_udf:true,
97 has_console_handle_problem:false,
98 has_broken_alloc_console:false,
99 has_always_all_codepages:false,
100 has_localenames:false,
101 has_mwmo_inputavailable:true,
102 has_buggy_thread_startup:false,
103 has_fast_cwd:false,
104 };
105
106 wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
107 chunksize:0,
108 heapslop:0x0,
109 max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
110 is_server:false,
111 has_dacl_protect:true,
112 has_broken_if_oper_status:false,
113 has_physical_mem_access:true,
114 has_process_io_counters:true,
115 has_terminal_services:true,
116 has_create_global_privilege:true,
117 has_ioctl_storage_get_media_types_ex:false,
118 has_extended_priority_class:true,
119 has_guid_volumes:true,
120 has_disk_ex_ioctls:false,
121 has_fileid_dirinfo:true,
122 has_enhanced_socket_security:false,
123 has_buggy_restart_scan:true,
124 has_mandatory_integrity_control:false,
125 needs_logon_sid_in_sid_list:true,
126 needs_count_in_si_lpres2:false,
127 has_recycle_dot_bin:false,
128 has_gaa_prefixes:false,
129 has_gaa_on_link_prefix:false,
130 supports_all_posix_ai_flags:false,
131 has_restricted_stack_args:false,
132 has_transactions:false,
133 ts_has_dep_problem:false,
134 has_recvmsg:false,
135 has_sendmsg:false,
136 has_broken_udf:true,
137 has_console_handle_problem:false,
138 has_broken_alloc_console:false,
139 has_always_all_codepages:false,
140 has_localenames:false,
141 has_mwmo_inputavailable:true,
142 has_buggy_thread_startup:false,
143 has_fast_cwd:false,
144 };
145
146 wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
147 chunksize:0,
148 heapslop:0x0,
149 max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE,
150 is_server:false,
151 has_dacl_protect:true,
152 has_broken_if_oper_status:false,
153 has_physical_mem_access:true,
154 has_process_io_counters:true,
155 has_terminal_services:true,
156 has_create_global_privilege:false,
157 has_ioctl_storage_get_media_types_ex:true,
158 has_extended_priority_class:true,
159 has_guid_volumes:true,
160 has_disk_ex_ioctls:true,
161 has_fileid_dirinfo:true,
162 has_enhanced_socket_security:false,
163 has_buggy_restart_scan:false,
164 has_mandatory_integrity_control:false,
165 needs_logon_sid_in_sid_list:false,
166 needs_count_in_si_lpres2:false,
167 has_recycle_dot_bin:false,
168 has_gaa_prefixes:false,
169 has_gaa_on_link_prefix:false,
170 supports_all_posix_ai_flags:false,
171 has_restricted_stack_args:false,
172 has_transactions:false,
173 ts_has_dep_problem:false,
174 has_recvmsg:true,
175 has_sendmsg:false,
176 has_broken_udf:true,
177 has_console_handle_problem:false,
178 has_broken_alloc_console:false,
179 has_always_all_codepages:false,
180 has_localenames:false,
181 has_mwmo_inputavailable:true,
182 has_buggy_thread_startup:false,
183 has_fast_cwd:false,
184 };
185
186 wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
187 chunksize:0,
188 heapslop:0x0,
189 max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE,
190 is_server:false,
191 has_dacl_protect:true,
192 has_broken_if_oper_status:false,
193 has_physical_mem_access:true,
194 has_process_io_counters:true,
195 has_terminal_services:true,
196 has_create_global_privilege:false,
197 has_ioctl_storage_get_media_types_ex:true,
198 has_extended_priority_class:true,
199 has_guid_volumes:true,
200 has_disk_ex_ioctls:true,
201 has_fileid_dirinfo:true,
202 has_enhanced_socket_security:false,
203 has_buggy_restart_scan:false,
204 has_mandatory_integrity_control:false,
205 needs_logon_sid_in_sid_list:false,
206 needs_count_in_si_lpres2:false,
207 has_recycle_dot_bin:false,
208 has_gaa_prefixes:true,
209 has_gaa_on_link_prefix:false,
210 supports_all_posix_ai_flags:false,
211 has_restricted_stack_args:false,
212 has_transactions:false,
213 ts_has_dep_problem:false,
214 has_recvmsg:true,
215 has_sendmsg:false,
216 has_broken_udf:true,
217 has_console_handle_problem:false,
218 has_broken_alloc_console:false,
219 has_always_all_codepages:false,
220 has_localenames:false,
221 has_mwmo_inputavailable:true,
222 has_buggy_thread_startup:false,
223 has_fast_cwd:false,
224 };
225
226 wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
227 chunksize:0,
228 heapslop:0x0,
229 max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
230 is_server:false,
231 has_dacl_protect:true,
232 has_broken_if_oper_status:false,
233 has_physical_mem_access:true,
234 has_process_io_counters:true,
235 has_terminal_services:true,
236 has_create_global_privilege:true,
237 has_ioctl_storage_get_media_types_ex:true,
238 has_extended_priority_class:true,
239 has_guid_volumes:true,
240 has_disk_ex_ioctls:true,
241 has_fileid_dirinfo:true,
242 has_enhanced_socket_security:false,
243 has_buggy_restart_scan:false,
244 has_mandatory_integrity_control:false,
245 needs_logon_sid_in_sid_list:false,
246 needs_count_in_si_lpres2:false,
247 has_recycle_dot_bin:false,
248 has_gaa_prefixes:true,
249 has_gaa_on_link_prefix:false,
250 supports_all_posix_ai_flags:false,
251 has_restricted_stack_args:false,
252 has_transactions:false,
253 ts_has_dep_problem:false,
254 has_recvmsg:true,
255 has_sendmsg:false,
256 has_broken_udf:true,
257 has_console_handle_problem:false,
258 has_broken_alloc_console:false,
259 has_always_all_codepages:false,
260 has_localenames:false,
261 has_mwmo_inputavailable:true,
262 has_buggy_thread_startup:false,
263 has_fast_cwd:false,
264 };
265
266 wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
267 chunksize:0,
268 heapslop:0x4,
269 max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
270 is_server:true,
271 has_dacl_protect:true,
272 has_broken_if_oper_status:false,
273 has_physical_mem_access:false,
274 has_process_io_counters:true,
275 has_terminal_services:true,
276 has_create_global_privilege:true,
277 has_ioctl_storage_get_media_types_ex:true,
278 has_extended_priority_class:true,
279 has_guid_volumes:true,
280 has_disk_ex_ioctls:true,
281 has_fileid_dirinfo:true,
282 has_enhanced_socket_security:true,
283 has_buggy_restart_scan:false,
284 has_mandatory_integrity_control:false,
285 needs_logon_sid_in_sid_list:false,
286 needs_count_in_si_lpres2:false,
287 has_recycle_dot_bin:false,
288 has_gaa_prefixes:true,
289 has_gaa_on_link_prefix:false,
290 supports_all_posix_ai_flags:false,
291 has_restricted_stack_args:true,
292 has_transactions:false,
293 ts_has_dep_problem:false,
294 has_recvmsg:true,
295 has_sendmsg:false,
296 has_broken_udf:true,
297 has_console_handle_problem:false,
298 has_broken_alloc_console:false,
299 has_always_all_codepages:false,
300 has_localenames:false,
301 has_mwmo_inputavailable:true,
302 has_buggy_thread_startup:false,
303 has_fast_cwd:false,
304 };
305
306 wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
307 chunksize:0,
308 heapslop:0x4,
309 max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE,
310 is_server:false,
311 has_dacl_protect:true,
312 has_broken_if_oper_status:false,
313 has_physical_mem_access:false,
314 has_process_io_counters:true,
315 has_terminal_services:true,
316 has_create_global_privilege:true,
317 has_ioctl_storage_get_media_types_ex:true,
318 has_extended_priority_class:true,
319 has_guid_volumes:true,
320 has_disk_ex_ioctls:true,
321 has_fileid_dirinfo:true,
322 has_enhanced_socket_security:true,
323 has_buggy_restart_scan:false,
324 has_mandatory_integrity_control:true,
325 needs_logon_sid_in_sid_list:false,
326 needs_count_in_si_lpres2:true,
327 has_recycle_dot_bin:true,
328 has_gaa_prefixes:true,
329 has_gaa_on_link_prefix:true,
330 supports_all_posix_ai_flags:true,
331 has_restricted_stack_args:false,
332 has_transactions:true,
333 ts_has_dep_problem:false,
334 has_recvmsg:true,
335 has_sendmsg:true,
336 has_broken_udf:false,
337 has_console_handle_problem:false,
338 has_broken_alloc_console:false,
339 has_always_all_codepages:true,
340 has_localenames:true,
341 has_mwmo_inputavailable:true,
342 has_buggy_thread_startup:true,
343 has_fast_cwd:true,
344 };
345
346 wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
347 chunksize:0,
348 heapslop:0x4,
349 max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE,
350 is_server:false,
351 has_dacl_protect:true,
352 has_broken_if_oper_status:false,
353 has_physical_mem_access:false,
354 has_process_io_counters:true,
355 has_terminal_services:true,
356 has_create_global_privilege:true,
357 has_ioctl_storage_get_media_types_ex:true,
358 has_extended_priority_class:true,
359 has_guid_volumes:true,
360 has_disk_ex_ioctls:true,
361 has_fileid_dirinfo:true,
362 has_enhanced_socket_security:true,
363 has_buggy_restart_scan:false,
364 has_mandatory_integrity_control:true,
365 needs_logon_sid_in_sid_list:false,
366 needs_count_in_si_lpres2:false,
367 has_recycle_dot_bin:true,
368 has_gaa_prefixes:true,
369 has_gaa_on_link_prefix:true,
370 supports_all_posix_ai_flags:true,
371 has_restricted_stack_args:false,
372 has_transactions:true,
373 ts_has_dep_problem:false,
374 has_recvmsg:true,
375 has_sendmsg:true,
376 has_broken_udf:false,
377 has_console_handle_problem:true,
378 has_broken_alloc_console:true,
379 has_always_all_codepages:true,
380 has_localenames:true,
381 has_mwmo_inputavailable:true,
382 has_buggy_thread_startup:false,
383 has_fast_cwd:true,
384 };
385
386 wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
387
388 void
389 wincapc::init ()
390 {
391 bool has_osversioninfoex = true;
392
393 if (caps)
394 return; // already initialized
395
396 memset (&version, 0, sizeof version);
397 /* Request versionex info first, which is available on all systems since
398 NT4 SP6 anyway. If that fails, call the simple version. */
399 version.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
400 if (!GetVersionEx (reinterpret_cast<LPOSVERSIONINFO>(&version)))
401 {
402 has_osversioninfoex = false;
403 version.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
404 GetVersionEx (reinterpret_cast<LPOSVERSIONINFO>(&version));
405 }
406
407 switch (version.dwPlatformId)
408 {
409 case VER_PLATFORM_WIN32_NT:
410 switch (version.dwMajorVersion)
411 {
412 case 4:
413 /* No mercy. We require at least NT4 SP4. */
414 caps = &wincap_nt4sp4;
415 break;
416 case 5:
417 switch (version.dwMinorVersion)
418 {
419 case 0:
420 if (version.wServicePackMajor < 4)
421 caps = &wincap_2000;
422 else
423 caps = &wincap_2000sp4;
424 break;
425
426 case 1:
427 caps = &wincap_xp;
428 switch (version.wServicePackMajor)
429 {
430 case 0:
431 caps = &wincap_xp;
432 case 1:
433 caps = &wincap_xpsp1;
434 default:
435 caps = &wincap_xpsp2;
436 }
437 break;
438
439 default:
440 caps = &wincap_2003;
441 }
442 break;
443 case 6:
444 switch (version.dwMinorVersion)
445 {
446 case 0:
447 caps = &wincap_vista;
448 break;
449 default:
450 caps = &wincap_7;
451 break;
452 }
453 break;
454 default:
455 caps = &wincap_minimal;
456 break;
457 }
458 break;
459 case VER_PLATFORM_WIN32_WINDOWS:
460 /* I'd be very surprised if this code is ever hit, but it doesn't
461 hurt to keep it. */
462 api_fatal ("Windows 95/98/Me are not supported.");
463 break;
464 default:
465 caps = &wincap_minimal;
466 break;
467 }
468
469 if (has_osversioninfoex && version.wProductType != VER_NT_WORKSTATION)
470 {
471 ((wincaps *)caps)->is_server = true;
472 if (version.dwMajorVersion >= 6
473 && (version.wSuiteMask
474 & (VER_SUITE_TERMINAL | VER_SUITE_SINGLEUSERTS))
475 == VER_SUITE_TERMINAL)
476 ((wincaps *)caps)->ts_has_dep_problem = true;
477 }
478 if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (),
479 ProcessWow64Information,
480 &wow64, sizeof wow64, NULL))
481 && !wow64)
482 {
483 ((wincaps *)caps)->needs_count_in_si_lpres2 = false;
484 ((wincaps *)caps)->has_restricted_stack_args = false;
485 }
486
487 if (!wow64)
488 ((wincaps *) caps)->has_buggy_thread_startup = false;
489 __small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion,
490 version.dwMinorVersion);
491 }
492
493 void
494 wincapc::set_chunksize (DWORD nchunksize)
495 {
496 ((wincaps *)caps)->chunksize = nchunksize;
497 }
This page took 0.055579 seconds and 5 git commands to generate.