1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/chromium/base/win/windows_version.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,111 @@ 1.4 +// Copyright (c) 2012 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef BASE_WIN_WINDOWS_VERSION_H_ 1.9 +#define BASE_WIN_WINDOWS_VERSION_H_ 1.10 + 1.11 +#include <string> 1.12 + 1.13 +#include "base/base_export.h" 1.14 +#include "base/basictypes.h" 1.15 + 1.16 +typedef void* HANDLE; 1.17 + 1.18 +namespace base { 1.19 +namespace win { 1.20 + 1.21 +// The running version of Windows. This is declared outside OSInfo for 1.22 +// syntactic sugar reasons; see the declaration of GetVersion() below. 1.23 +// NOTE: Keep these in order so callers can do things like 1.24 +// "if (base::win::GetVersion() >= base::win::VERSION_VISTA) ...". 1.25 +enum Version { 1.26 + VERSION_PRE_XP = 0, // Not supported. 1.27 + VERSION_XP, 1.28 + VERSION_SERVER_2003, // Also includes XP Pro x64 and Server 2003 R2. 1.29 + VERSION_VISTA, // Also includes Windows Server 2008. 1.30 + VERSION_WIN7, // Also includes Windows Server 2008 R2. 1.31 + VERSION_WIN8, // Also includes Windows Server 2012. 1.32 + VERSION_WIN8_1, // Code named Windows Blue 1.33 + VERSION_WIN_LAST, // Indicates error condition. 1.34 +}; 1.35 + 1.36 +// A singleton that can be used to query various pieces of information about the 1.37 +// OS and process state. Note that this doesn't use the base Singleton class, so 1.38 +// it can be used without an AtExitManager. 1.39 +class BASE_EXPORT OSInfo { 1.40 + public: 1.41 + struct VersionNumber { 1.42 + int major; 1.43 + int minor; 1.44 + int build; 1.45 + }; 1.46 + 1.47 + struct ServicePack { 1.48 + int major; 1.49 + int minor; 1.50 + }; 1.51 + 1.52 + // The processor architecture this copy of Windows natively uses. For 1.53 + // example, given an x64-capable processor, we have three possibilities: 1.54 + // 32-bit Chrome running on 32-bit Windows: X86_ARCHITECTURE 1.55 + // 32-bit Chrome running on 64-bit Windows via WOW64: X64_ARCHITECTURE 1.56 + // 64-bit Chrome running on 64-bit Windows: X64_ARCHITECTURE 1.57 + enum WindowsArchitecture { 1.58 + X86_ARCHITECTURE, 1.59 + X64_ARCHITECTURE, 1.60 + IA64_ARCHITECTURE, 1.61 + OTHER_ARCHITECTURE, 1.62 + }; 1.63 + 1.64 + // Whether a process is running under WOW64 (the wrapper that allows 32-bit 1.65 + // processes to run on 64-bit versions of Windows). This will return 1.66 + // WOW64_DISABLED for both "32-bit Chrome on 32-bit Windows" and "64-bit 1.67 + // Chrome on 64-bit Windows". WOW64_UNKNOWN means "an error occurred", e.g. 1.68 + // the process does not have sufficient access rights to determine this. 1.69 + enum WOW64Status { 1.70 + WOW64_DISABLED, 1.71 + WOW64_ENABLED, 1.72 + WOW64_UNKNOWN, 1.73 + }; 1.74 + 1.75 + static OSInfo* GetInstance(); 1.76 + 1.77 + Version version() const { return version_; } 1.78 + // The next two functions return arrays of values, [major, minor(, build)]. 1.79 + VersionNumber version_number() const { return version_number_; } 1.80 + ServicePack service_pack() const { return service_pack_; } 1.81 + WindowsArchitecture architecture() const { return architecture_; } 1.82 + int processors() const { return processors_; } 1.83 + size_t allocation_granularity() const { return allocation_granularity_; } 1.84 + WOW64Status wow64_status() const { return wow64_status_; } 1.85 + std::string processor_model_name(); 1.86 + 1.87 + // Like wow64_status(), but for the supplied handle instead of the current 1.88 + // process. This doesn't touch member state, so you can bypass the singleton. 1.89 + static WOW64Status GetWOW64StatusForProcess(HANDLE process_handle); 1.90 + 1.91 + private: 1.92 + OSInfo(); 1.93 + ~OSInfo(); 1.94 + 1.95 + Version version_; 1.96 + VersionNumber version_number_; 1.97 + ServicePack service_pack_; 1.98 + WindowsArchitecture architecture_; 1.99 + int processors_; 1.100 + size_t allocation_granularity_; 1.101 + WOW64Status wow64_status_; 1.102 + std::string processor_model_name_; 1.103 + 1.104 + DISALLOW_COPY_AND_ASSIGN(OSInfo); 1.105 +}; 1.106 + 1.107 +// Because this is by far the most commonly-requested value from the above 1.108 +// singleton, we add a global-scope accessor here as syntactic sugar. 1.109 +BASE_EXPORT Version GetVersion(); 1.110 + 1.111 +} // namespace win 1.112 +} // namespace base 1.113 + 1.114 +#endif // BASE_WIN_WINDOWS_VERSION_H_