1 /* wincap.cc -- figure out on which OS we're running. Set the
2 capability class to the appropriate values.
4 Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
5 2009, 2010 Red Hat, Inc.
7 This file is part of Cygwin.
9 This software is a copyrighted work licensed under the terms of the
10 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
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... */
23 /* Minimal set of capabilities required to run Cygwin. */
24 #define wincap_minimal wincap_nt4sp4
26 wincaps wincap_nt4sp4
__attribute__((section (".cygwin_dll_common"), shared
)) = {
29 max_sys_priv
:SE_CHANGE_NOTIFY_PRIVILEGE
,
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,
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,
66 wincaps wincap_2000
__attribute__((section (".cygwin_dll_common"), shared
)) = {
69 max_sys_priv
:SE_MANAGE_VOLUME_PRIVILEGE
,
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,
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,
106 wincaps wincap_2000sp4
__attribute__((section (".cygwin_dll_common"), shared
)) = {
109 max_sys_priv
:SE_CREATE_GLOBAL_PRIVILEGE
,
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,
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,
146 wincaps wincap_xp
__attribute__((section (".cygwin_dll_common"), shared
)) = {
149 max_sys_priv
:SE_MANAGE_VOLUME_PRIVILEGE
,
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,
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,
186 wincaps wincap_xpsp1
__attribute__((section (".cygwin_dll_common"), shared
)) = {
189 max_sys_priv
:SE_MANAGE_VOLUME_PRIVILEGE
,
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,
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,
226 wincaps wincap_xpsp2
__attribute__((section (".cygwin_dll_common"), shared
)) = {
229 max_sys_priv
:SE_CREATE_GLOBAL_PRIVILEGE
,
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,
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,
266 wincaps wincap_2003
__attribute__((section (".cygwin_dll_common"), shared
)) = {
269 max_sys_priv
:SE_CREATE_GLOBAL_PRIVILEGE
,
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,
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,
306 wincaps wincap_vista
__attribute__((section (".cygwin_dll_common"), shared
)) = {
309 max_sys_priv
:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
,
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,
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,
346 wincaps wincap_7
__attribute__((section (".cygwin_dll_common"), shared
)) = {
349 max_sys_priv
:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
,
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,
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,
386 wincapc wincap
__attribute__((section (".cygwin_dll_common"), shared
));
391 bool has_osversioninfoex
= true;
394 return; // already initialized
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
)))
402 has_osversioninfoex
= false;
403 version
.dwOSVersionInfoSize
= sizeof (OSVERSIONINFO
);
404 GetVersionEx (reinterpret_cast<LPOSVERSIONINFO
>(&version
));
407 switch (version
.dwPlatformId
)
409 case VER_PLATFORM_WIN32_NT
:
410 switch (version
.dwMajorVersion
)
413 /* No mercy. We require at least NT4 SP4. */
414 caps
= &wincap_nt4sp4
;
417 switch (version
.dwMinorVersion
)
420 if (version
.wServicePackMajor
< 4)
423 caps
= &wincap_2000sp4
;
428 switch (version
.wServicePackMajor
)
433 caps
= &wincap_xpsp1
;
435 caps
= &wincap_xpsp2
;
444 switch (version
.dwMinorVersion
)
447 caps
= &wincap_vista
;
455 caps
= &wincap_minimal
;
459 case VER_PLATFORM_WIN32_WINDOWS
:
460 /* I'd be very surprised if this code is ever hit, but it doesn't
462 api_fatal ("Windows 95/98/Me are not supported.");
465 caps
= &wincap_minimal
;
469 if (has_osversioninfoex
&& version
.wProductType
!= VER_NT_WORKSTATION
)
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;
478 if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (),
479 ProcessWow64Information
,
480 &wow64
, sizeof wow64
, NULL
))
483 ((wincaps
*)caps
)->needs_count_in_si_lpres2
= false;
484 ((wincaps
*)caps
)->has_restricted_stack_args
= false;
488 ((wincaps
*) caps
)->has_buggy_thread_startup
= false;
489 __small_sprintf (osnam
, "NT-%d.%d", version
.dwMajorVersion
,
490 version
.dwMinorVersion
);
494 wincapc::set_chunksize (DWORD nchunksize
)
496 ((wincaps
*)caps
)->chunksize
= nchunksize
;