123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #ifndef BASE_WIN_WINDOWS_VERSION_H_
- #define BASE_WIN_WINDOWS_VERSION_H_
- #include <stddef.h>
- #include <string>
- #include "base/base_export.h"
- #include "base/gtest_prod_util.h"
- #include "base/macros.h"
- #include "base/version.h"
- using HANDLE = void*;
- struct _OSVERSIONINFOEXW;
- struct _SYSTEM_INFO;
- namespace base {
- namespace test {
- class ScopedOSInfoOverride;
- }
- }
- namespace base {
- namespace win {
- enum class Version {
- PRE_XP = 0,
- XP = 1,
- SERVER_2003 = 2,
- VISTA = 3,
- WIN7 = 4,
- WIN8 = 5,
- WIN8_1 = 6,
- WIN10 = 7,
- WIN10_TH2 = 8,
- WIN10_RS1 = 9,
- WIN10_RS2 = 10,
- WIN10_RS3 = 11,
- WIN10_RS4 = 12,
- WIN10_RS5 = 13,
- WIN10_19H1 = 14,
- WIN10_20H1 = 15,
-
-
- WIN_LAST,
- };
- enum VersionType {
- SUITE_HOME = 0,
- SUITE_PROFESSIONAL,
- SUITE_SERVER,
- SUITE_ENTERPRISE,
- SUITE_EDUCATION,
- SUITE_LAST,
- };
- class BASE_EXPORT OSInfo {
- public:
- struct VersionNumber {
- int major;
- int minor;
- int build;
- int patch;
- };
- struct ServicePack {
- int major;
- int minor;
- };
-
-
-
-
-
- enum WindowsArchitecture {
- X86_ARCHITECTURE,
- X64_ARCHITECTURE,
- IA64_ARCHITECTURE,
- ARM64_ARCHITECTURE,
- OTHER_ARCHITECTURE,
- };
-
-
-
-
-
- enum WOW64Status {
- WOW64_DISABLED,
- WOW64_ENABLED,
- WOW64_UNKNOWN,
- };
- static OSInfo* GetInstance();
-
-
- static WindowsArchitecture GetArchitecture();
-
-
- static WOW64Status GetWOW64StatusForProcess(HANDLE process_handle);
- const Version& version() const { return version_; }
- Version Kernel32Version() const;
- base::Version Kernel32BaseVersion() const;
-
- const VersionNumber& version_number() const { return version_number_; }
- const VersionType& version_type() const { return version_type_; }
- const ServicePack& service_pack() const { return service_pack_; }
- const std::string& service_pack_str() const { return service_pack_str_; }
- const int& processors() const { return processors_; }
- const size_t& allocation_granularity() const {
- return allocation_granularity_;
- }
- const WOW64Status& wow64_status() const { return wow64_status_; }
- std::string processor_model_name();
- const std::string& release_id() const { return release_id_; }
- private:
- friend class base::test::ScopedOSInfoOverride;
- FRIEND_TEST_ALL_PREFIXES(OSInfo, MajorMinorBuildToVersion);
- static OSInfo** GetInstanceStorage();
- OSInfo(const _OSVERSIONINFOEXW& version_info,
- const _SYSTEM_INFO& system_info,
- int os_type);
- ~OSInfo();
-
- static Version MajorMinorBuildToVersion(int major, int minor, int build);
- Version version_;
- VersionNumber version_number_;
- VersionType version_type_;
- ServicePack service_pack_;
-
-
-
-
-
-
-
-
- std::string release_id_;
-
-
-
- std::string service_pack_str_;
- int processors_;
- size_t allocation_granularity_;
- WOW64Status wow64_status_;
- std::string processor_model_name_;
- DISALLOW_COPY_AND_ASSIGN(OSInfo);
- };
- BASE_EXPORT Version GetVersion();
- }
- }
- #endif
|