michael@0: // Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_WIN_WINDOWS_VERSION_H_ michael@0: #define BASE_WIN_WINDOWS_VERSION_H_ michael@0: michael@0: #include michael@0: michael@0: #include "base/base_export.h" michael@0: #include "base/basictypes.h" michael@0: michael@0: typedef void* HANDLE; michael@0: michael@0: namespace base { michael@0: namespace win { michael@0: michael@0: // The running version of Windows. This is declared outside OSInfo for michael@0: // syntactic sugar reasons; see the declaration of GetVersion() below. michael@0: // NOTE: Keep these in order so callers can do things like michael@0: // "if (base::win::GetVersion() >= base::win::VERSION_VISTA) ...". michael@0: enum Version { michael@0: VERSION_PRE_XP = 0, // Not supported. michael@0: VERSION_XP, michael@0: VERSION_SERVER_2003, // Also includes XP Pro x64 and Server 2003 R2. michael@0: VERSION_VISTA, // Also includes Windows Server 2008. michael@0: VERSION_WIN7, // Also includes Windows Server 2008 R2. michael@0: VERSION_WIN8, // Also includes Windows Server 2012. michael@0: VERSION_WIN8_1, // Code named Windows Blue michael@0: VERSION_WIN_LAST, // Indicates error condition. michael@0: }; michael@0: michael@0: // A singleton that can be used to query various pieces of information about the michael@0: // OS and process state. Note that this doesn't use the base Singleton class, so michael@0: // it can be used without an AtExitManager. michael@0: class BASE_EXPORT OSInfo { michael@0: public: michael@0: struct VersionNumber { michael@0: int major; michael@0: int minor; michael@0: int build; michael@0: }; michael@0: michael@0: struct ServicePack { michael@0: int major; michael@0: int minor; michael@0: }; michael@0: michael@0: // The processor architecture this copy of Windows natively uses. For michael@0: // example, given an x64-capable processor, we have three possibilities: michael@0: // 32-bit Chrome running on 32-bit Windows: X86_ARCHITECTURE michael@0: // 32-bit Chrome running on 64-bit Windows via WOW64: X64_ARCHITECTURE michael@0: // 64-bit Chrome running on 64-bit Windows: X64_ARCHITECTURE michael@0: enum WindowsArchitecture { michael@0: X86_ARCHITECTURE, michael@0: X64_ARCHITECTURE, michael@0: IA64_ARCHITECTURE, michael@0: OTHER_ARCHITECTURE, michael@0: }; michael@0: michael@0: // Whether a process is running under WOW64 (the wrapper that allows 32-bit michael@0: // processes to run on 64-bit versions of Windows). This will return michael@0: // WOW64_DISABLED for both "32-bit Chrome on 32-bit Windows" and "64-bit michael@0: // Chrome on 64-bit Windows". WOW64_UNKNOWN means "an error occurred", e.g. michael@0: // the process does not have sufficient access rights to determine this. michael@0: enum WOW64Status { michael@0: WOW64_DISABLED, michael@0: WOW64_ENABLED, michael@0: WOW64_UNKNOWN, michael@0: }; michael@0: michael@0: static OSInfo* GetInstance(); michael@0: michael@0: Version version() const { return version_; } michael@0: // The next two functions return arrays of values, [major, minor(, build)]. michael@0: VersionNumber version_number() const { return version_number_; } michael@0: ServicePack service_pack() const { return service_pack_; } michael@0: WindowsArchitecture architecture() const { return architecture_; } michael@0: int processors() const { return processors_; } michael@0: size_t allocation_granularity() const { return allocation_granularity_; } michael@0: WOW64Status wow64_status() const { return wow64_status_; } michael@0: std::string processor_model_name(); michael@0: michael@0: // Like wow64_status(), but for the supplied handle instead of the current michael@0: // process. This doesn't touch member state, so you can bypass the singleton. michael@0: static WOW64Status GetWOW64StatusForProcess(HANDLE process_handle); michael@0: michael@0: private: michael@0: OSInfo(); michael@0: ~OSInfo(); michael@0: michael@0: Version version_; michael@0: VersionNumber version_number_; michael@0: ServicePack service_pack_; michael@0: WindowsArchitecture architecture_; michael@0: int processors_; michael@0: size_t allocation_granularity_; michael@0: WOW64Status wow64_status_; michael@0: std::string processor_model_name_; michael@0: michael@0: DISALLOW_COPY_AND_ASSIGN(OSInfo); michael@0: }; michael@0: michael@0: // Because this is by far the most commonly-requested value from the above michael@0: // singleton, we add a global-scope accessor here as syntactic sugar. michael@0: BASE_EXPORT Version GetVersion(); michael@0: michael@0: } // namespace win michael@0: } // namespace base michael@0: michael@0: #endif // BASE_WIN_WINDOWS_VERSION_H_