1 // Copyright 2015 The Crashpad Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef CRASHPAD_SNAPSHOT_WIN_SYSTEM_SNAPSHOT_WIN_H_ 16 #define CRASHPAD_SNAPSHOT_WIN_SYSTEM_SNAPSHOT_WIN_H_ 17 18 #include <stdint.h> 19 #include <sys/time.h> 20 21 #include <string> 22 23 #include "base/macros.h" 24 #include "snapshot/system_snapshot.h" 25 #include "snapshot/win/process_reader_win.h" 26 #include "util/misc/initialization_state_dcheck.h" 27 28 namespace crashpad { 29 30 class ProcessReaderWin; 31 32 namespace internal { 33 34 //! \brief A SystemSnapshot of the running system, when the system runs Windows. 35 class SystemSnapshotWin final : public SystemSnapshot { 36 public: 37 SystemSnapshotWin(); 38 ~SystemSnapshotWin() override; 39 40 //! \brief Initializes the object. 41 //! 42 //! \param[in] process_reader A reader for the process being snapshotted. 43 //! 44 //! It seems odd that a system snapshot implementation would need a 45 //! ProcessReaderWin, but some of the information reported about the 46 //! system depends on the process it's being reported for. For example, 47 //! the architecture returned by GetCPUArchitecture() should be the 48 //! architecture of the process, which may be different than the native 49 //! architecture of the system: an x86_64 system can run both x86_64 and 50 //! 32-bit x86 processes. 51 void Initialize(ProcessReaderWin* process_reader); 52 53 // SystemSnapshot: 54 55 CPUArchitecture GetCPUArchitecture() const override; 56 uint32_t CPURevision() const override; 57 uint8_t CPUCount() const override; 58 std::string CPUVendor() const override; 59 void CPUFrequency(uint64_t* current_hz, uint64_t* max_hz) const override; 60 uint32_t CPUX86Signature() const override; 61 uint64_t CPUX86Features() const override; 62 uint64_t CPUX86ExtendedFeatures() const override; 63 uint32_t CPUX86Leaf7Features() const override; 64 bool CPUX86SupportsDAZ() const override; 65 OperatingSystem GetOperatingSystem() const override; 66 bool OSServer() const override; 67 void OSVersion(int* major, 68 int* minor, 69 int* bugfix, 70 std::string* build) const override; 71 std::string OSVersionFull() const override; 72 bool NXEnabled() const override; 73 std::string MachineDescription() const override; 74 void TimeZone(DaylightSavingTimeStatus* dst_status, 75 int* standard_offset_seconds, 76 int* daylight_offset_seconds, 77 std::string* standard_name, 78 std::string* daylight_name) const override; 79 80 private: 81 std::string os_version_full_; 82 std::string os_version_build_; 83 ProcessReaderWin* process_reader_; // weak 84 int os_version_major_; 85 int os_version_minor_; 86 int os_version_bugfix_; 87 bool os_server_; 88 InitializationStateDcheck initialized_; 89 90 DISALLOW_COPY_AND_ASSIGN(SystemSnapshotWin); 91 }; 92 93 } // namespace internal 94 } // namespace crashpad 95 96 #endif // CRASHPAD_SNAPSHOT_WIN_SYSTEM_SNAPSHOT_WIN_H_ 97