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, 2011 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_buggy_restart_scan:false,
43 has_mandatory_integrity_control:false,
44 needs_logon_sid_in_sid_list:true,
45 needs_count_in_si_lpres2:false,
46 has_recycle_dot_bin:false,
47 has_gaa_prefixes:false,
48 has_gaa_on_link_prefix:false,
49 supports_all_posix_ai_flags:false,
50 has_restricted_stack_args:false,
51 has_transactions:false,
52 ts_has_dep_problem:false,
56 has_console_handle_problem:false,
57 has_broken_alloc_console:false,
58 has_always_all_codepages:false,
59 has_localenames:false,
60 has_mwmo_inputavailable:false,
61 has_buggy_thread_startup:false,
63 has_restricted_raw_disk_access:false,
64 use_dont_resolve_hack:false,
67 wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = {
70 max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE,
72 has_dacl_protect:true,
73 has_broken_if_oper_status:false,
74 has_physical_mem_access:true,
75 has_process_io_counters:true,
76 has_terminal_services:true,
77 has_create_global_privilege:false,
78 has_ioctl_storage_get_media_types_ex:false,
79 has_extended_priority_class:true,
80 has_guid_volumes:true,
81 has_disk_ex_ioctls:false,
82 has_fileid_dirinfo:true,
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,
104 has_restricted_raw_disk_access:false,
105 use_dont_resolve_hack:false,
108 wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
111 max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
113 has_dacl_protect:true,
114 has_broken_if_oper_status:false,
115 has_physical_mem_access:true,
116 has_process_io_counters:true,
117 has_terminal_services:true,
118 has_create_global_privilege:true,
119 has_ioctl_storage_get_media_types_ex:false,
120 has_extended_priority_class:true,
121 has_guid_volumes:true,
122 has_disk_ex_ioctls:false,
123 has_fileid_dirinfo:true,
124 has_buggy_restart_scan:true,
125 has_mandatory_integrity_control:false,
126 needs_logon_sid_in_sid_list:true,
127 needs_count_in_si_lpres2:false,
128 has_recycle_dot_bin:false,
129 has_gaa_prefixes:false,
130 has_gaa_on_link_prefix:false,
131 supports_all_posix_ai_flags:false,
132 has_restricted_stack_args:false,
133 has_transactions:false,
134 ts_has_dep_problem:false,
138 has_console_handle_problem:false,
139 has_broken_alloc_console:false,
140 has_always_all_codepages:false,
141 has_localenames:false,
142 has_mwmo_inputavailable:true,
143 has_buggy_thread_startup:false,
145 has_restricted_raw_disk_access:false,
146 use_dont_resolve_hack:false,
149 wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
152 max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE,
154 has_dacl_protect:true,
155 has_broken_if_oper_status:false,
156 has_physical_mem_access:true,
157 has_process_io_counters:true,
158 has_terminal_services:true,
159 has_create_global_privilege:false,
160 has_ioctl_storage_get_media_types_ex:true,
161 has_extended_priority_class:true,
162 has_guid_volumes:true,
163 has_disk_ex_ioctls:true,
164 has_fileid_dirinfo:true,
165 has_buggy_restart_scan:false,
166 has_mandatory_integrity_control:false,
167 needs_logon_sid_in_sid_list:false,
168 needs_count_in_si_lpres2:false,
169 has_recycle_dot_bin:false,
170 has_gaa_prefixes:false,
171 has_gaa_on_link_prefix:false,
172 supports_all_posix_ai_flags:false,
173 has_restricted_stack_args:false,
174 has_transactions:false,
175 ts_has_dep_problem:false,
179 has_console_handle_problem:false,
180 has_broken_alloc_console:false,
181 has_always_all_codepages:false,
182 has_localenames:false,
183 has_mwmo_inputavailable:true,
184 has_buggy_thread_startup:false,
186 has_restricted_raw_disk_access:false,
187 use_dont_resolve_hack:true,
190 wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
193 max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE,
195 has_dacl_protect:true,
196 has_broken_if_oper_status:false,
197 has_physical_mem_access:true,
198 has_process_io_counters:true,
199 has_terminal_services:true,
200 has_create_global_privilege:false,
201 has_ioctl_storage_get_media_types_ex:true,
202 has_extended_priority_class:true,
203 has_guid_volumes:true,
204 has_disk_ex_ioctls:true,
205 has_fileid_dirinfo:true,
206 has_buggy_restart_scan:false,
207 has_mandatory_integrity_control:false,
208 needs_logon_sid_in_sid_list:false,
209 needs_count_in_si_lpres2:false,
210 has_recycle_dot_bin:false,
211 has_gaa_prefixes:true,
212 has_gaa_on_link_prefix:false,
213 supports_all_posix_ai_flags:false,
214 has_restricted_stack_args:false,
215 has_transactions:false,
216 ts_has_dep_problem:false,
220 has_console_handle_problem:false,
221 has_broken_alloc_console:false,
222 has_always_all_codepages:false,
223 has_localenames:false,
224 has_mwmo_inputavailable:true,
225 has_buggy_thread_startup:false,
227 has_restricted_raw_disk_access:false,
228 use_dont_resolve_hack:true,
231 wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
234 max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
236 has_dacl_protect:true,
237 has_broken_if_oper_status:false,
238 has_physical_mem_access:true,
239 has_process_io_counters:true,
240 has_terminal_services:true,
241 has_create_global_privilege:true,
242 has_ioctl_storage_get_media_types_ex:true,
243 has_extended_priority_class:true,
244 has_guid_volumes:true,
245 has_disk_ex_ioctls:true,
246 has_fileid_dirinfo:true,
247 has_buggy_restart_scan:false,
248 has_mandatory_integrity_control:false,
249 needs_logon_sid_in_sid_list:false,
250 needs_count_in_si_lpres2:false,
251 has_recycle_dot_bin:false,
252 has_gaa_prefixes:true,
253 has_gaa_on_link_prefix:false,
254 supports_all_posix_ai_flags:false,
255 has_restricted_stack_args:false,
256 has_transactions:false,
257 ts_has_dep_problem:false,
261 has_console_handle_problem:false,
262 has_broken_alloc_console:false,
263 has_always_all_codepages:false,
264 has_localenames:false,
265 has_mwmo_inputavailable:true,
266 has_buggy_thread_startup:false,
268 has_restricted_raw_disk_access:false,
269 use_dont_resolve_hack:true,
272 wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
275 max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
277 has_dacl_protect:true,
278 has_broken_if_oper_status:false,
279 has_physical_mem_access:false,
280 has_process_io_counters:true,
281 has_terminal_services:true,
282 has_create_global_privilege:true,
283 has_ioctl_storage_get_media_types_ex:true,
284 has_extended_priority_class:true,
285 has_guid_volumes:true,
286 has_disk_ex_ioctls:true,
287 has_fileid_dirinfo:true,
288 has_buggy_restart_scan:false,
289 has_mandatory_integrity_control:false,
290 needs_logon_sid_in_sid_list:false,
291 needs_count_in_si_lpres2:false,
292 has_recycle_dot_bin:false,
293 has_gaa_prefixes:true,
294 has_gaa_on_link_prefix:false,
295 supports_all_posix_ai_flags:false,
296 has_restricted_stack_args:true,
297 has_transactions:false,
298 ts_has_dep_problem:false,
302 has_console_handle_problem:false,
303 has_broken_alloc_console:false,
304 has_always_all_codepages:false,
305 has_localenames:false,
306 has_mwmo_inputavailable:true,
307 has_buggy_thread_startup:false,
309 has_restricted_raw_disk_access:false,
310 use_dont_resolve_hack:false,
313 wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
316 max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE,
318 has_dacl_protect:true,
319 has_broken_if_oper_status:false,
320 has_physical_mem_access:false,
321 has_process_io_counters:true,
322 has_terminal_services:true,
323 has_create_global_privilege:true,
324 has_ioctl_storage_get_media_types_ex:true,
325 has_extended_priority_class:true,
326 has_guid_volumes:true,
327 has_disk_ex_ioctls:true,
328 has_fileid_dirinfo:true,
329 has_buggy_restart_scan:false,
330 has_mandatory_integrity_control:true,
331 needs_logon_sid_in_sid_list:false,
332 needs_count_in_si_lpres2:true,
333 has_recycle_dot_bin:true,
334 has_gaa_prefixes:true,
335 has_gaa_on_link_prefix:true,
336 supports_all_posix_ai_flags:true,
337 has_restricted_stack_args:false,
338 has_transactions:true,
339 ts_has_dep_problem:false,
342 has_broken_udf:false,
343 has_console_handle_problem:false,
344 has_broken_alloc_console:false,
345 has_always_all_codepages:true,
346 has_localenames:true,
347 has_mwmo_inputavailable:true,
348 has_buggy_thread_startup:true,
350 has_restricted_raw_disk_access:true,
351 use_dont_resolve_hack:false,
354 wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
357 max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE,
359 has_dacl_protect:true,
360 has_broken_if_oper_status:false,
361 has_physical_mem_access:false,
362 has_process_io_counters:true,
363 has_terminal_services:true,
364 has_create_global_privilege:true,
365 has_ioctl_storage_get_media_types_ex:true,
366 has_extended_priority_class:true,
367 has_guid_volumes:true,
368 has_disk_ex_ioctls:true,
369 has_fileid_dirinfo:true,
370 has_buggy_restart_scan:false,
371 has_mandatory_integrity_control:true,
372 needs_logon_sid_in_sid_list:false,
373 needs_count_in_si_lpres2:false,
374 has_recycle_dot_bin:true,
375 has_gaa_prefixes:true,
376 has_gaa_on_link_prefix:true,
377 supports_all_posix_ai_flags:true,
378 has_restricted_stack_args:false,
379 has_transactions:true,
380 ts_has_dep_problem:false,
383 has_broken_udf:false,
384 has_console_handle_problem:true,
385 has_broken_alloc_console:true,
386 has_always_all_codepages:true,
387 has_localenames:true,
388 has_mwmo_inputavailable:true,
389 has_buggy_thread_startup:false,
391 has_restricted_raw_disk_access:true,
392 use_dont_resolve_hack:false,
395 wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
400 bool has_osversioninfoex = true;
403 return; // already initialized
405 memset (&version, 0, sizeof version);
406 /* Request versionex info first, which is available on all systems since
407 NT4 SP6 anyway. If that fails, call the simple version. */
408 version.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
409 if (!GetVersionEx (reinterpret_cast<LPOSVERSIONINFO>(&version)))
411 has_osversioninfoex = false;
412 version.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
413 GetVersionEx (reinterpret_cast<LPOSVERSIONINFO>(&version));
416 switch (version.dwPlatformId)
418 case VER_PLATFORM_WIN32_NT:
419 switch (version.dwMajorVersion)
422 /* No mercy. We require at least NT4 SP4. */
423 caps = &wincap_nt4sp4;
426 switch (version.dwMinorVersion)
429 if (version.wServicePackMajor < 4)
432 caps = &wincap_2000sp4;
437 switch (version.wServicePackMajor)
442 caps = &wincap_xpsp1;
444 caps = &wincap_xpsp2;
453 switch (version.dwMinorVersion)
456 caps = &wincap_vista;
464 caps = &wincap_minimal;
468 case VER_PLATFORM_WIN32_WINDOWS:
469 /* I'd be very surprised if this code is ever hit, but it doesn't
471 api_fatal ("Windows 95/98/Me are not supported.");
474 caps = &wincap_minimal;
478 if (has_osversioninfoex && version.wProductType != VER_NT_WORKSTATION)
480 ((wincaps *)caps)->is_server = true;
481 if (version.dwMajorVersion >= 6
482 && (version.wSuiteMask
483 & (VER_SUITE_TERMINAL | VER_SUITE_SINGLEUSERTS))
484 == VER_SUITE_TERMINAL)
485 ((wincaps *)caps)->ts_has_dep_problem = true;
487 if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (),
488 ProcessWow64Information,
489 &wow64, sizeof wow64, NULL))
492 ((wincaps *)caps)->needs_count_in_si_lpres2 = false;
493 ((wincaps *)caps)->has_restricted_stack_args = false;
497 ((wincaps *) caps)->has_buggy_thread_startup = false;
498 __small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion,
499 version.dwMinorVersion);
503 wincapc::set_chunksize (DWORD nchunksize)
505 ((wincaps *)caps)->chunksize = nchunksize;