OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 SystemSnapshotWin::~SystemSnapshotWin() { | 81 SystemSnapshotWin::~SystemSnapshotWin() { |
82 } | 82 } |
83 | 83 |
84 void SystemSnapshotWin::Initialize(ProcessReaderWin* process_reader) { | 84 void SystemSnapshotWin::Initialize(ProcessReaderWin* process_reader) { |
85 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 85 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
86 | 86 |
87 process_reader_ = process_reader; | 87 process_reader_ = process_reader; |
88 | 88 |
89 // We use both GetVersionEx and VerQueryValue. GetVersionEx is not trustworthy | 89 // We use both GetVersionEx() and GetModuleVersionAndType() (which uses |
90 // after Windows 8 (depending on the application manifest) so its data is used | 90 // VerQueryValue() internally). GetVersionEx() is not trustworthy after |
91 // only to fill the os_server_ field, and the rest comes from the version | 91 // Windows 8 (depending on the application manifest) so its data is used only |
| 92 // to fill the os_server_ field, and the rest comes from the version |
92 // information stamped on kernel32.dll. | 93 // information stamped on kernel32.dll. |
93 OSVERSIONINFOEX version_info = {sizeof(version_info)}; | 94 OSVERSIONINFOEX version_info = {sizeof(version_info)}; |
94 if (!GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info))) { | 95 if (!GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info))) { |
95 PLOG(WARNING) << "GetVersionEx"; | 96 PLOG(WARNING) << "GetVersionEx"; |
96 } else { | 97 } else { |
97 const wchar_t kSystemDll[] = L"kernel32.dll"; | 98 os_server_ = version_info.wProductType != VER_NT_WORKSTATION; |
98 VS_FIXEDFILEINFO ffi; | 99 } |
99 if (GetModuleVersionAndType(base::FilePath(kSystemDll), &ffi)) { | 100 |
100 std::string flags_string = GetStringForFileFlags(ffi.dwFileFlags); | 101 const wchar_t kSystemDll[] = L"kernel32.dll"; |
101 os_server_ = version_info.wProductType != VER_NT_WORKSTATION; | 102 VS_FIXEDFILEINFO ffi; |
102 std::string os_name = GetStringForFileOS(ffi.dwFileOS); | 103 if (GetModuleVersionAndType(base::FilePath(kSystemDll), &ffi)) { |
103 os_version_major_ = ffi.dwFileVersionMS >> 16; | 104 std::string flags_string = GetStringForFileFlags(ffi.dwFileFlags); |
104 os_version_minor_ = ffi.dwFileVersionMS & 0xffff; | 105 std::string os_name = GetStringForFileOS(ffi.dwFileOS); |
105 os_version_bugfix_ = ffi.dwFileVersionLS >> 16; | 106 os_version_major_ = ffi.dwFileVersionMS >> 16; |
106 os_version_build_ = | 107 os_version_minor_ = ffi.dwFileVersionMS & 0xffff; |
107 base::StringPrintf("%d", ffi.dwFileVersionLS & 0xffff); | 108 os_version_bugfix_ = ffi.dwFileVersionLS >> 16; |
108 os_version_full_ = base::StringPrintf( | 109 os_version_build_ = |
109 "%s %d.%d.%d.%s%s", | 110 base::StringPrintf("%d", ffi.dwFileVersionLS & 0xffff); |
110 os_name.c_str(), | 111 os_version_full_ = base::StringPrintf( |
111 os_version_major_, | 112 "%s %d.%d.%d.%s%s", |
112 os_version_minor_, | 113 os_name.c_str(), |
113 os_version_bugfix_, | 114 os_version_major_, |
114 os_version_build_.c_str(), | 115 os_version_minor_, |
115 flags_string.empty() ? "" : (std::string(" (") + flags_string + ")") | 116 os_version_bugfix_, |
116 .c_str()); | 117 os_version_build_.c_str(), |
117 } | 118 flags_string.empty() ? "" : (std::string(" (") + flags_string + ")") |
| 119 .c_str()); |
118 } | 120 } |
119 | 121 |
120 INITIALIZATION_STATE_SET_VALID(initialized_); | 122 INITIALIZATION_STATE_SET_VALID(initialized_); |
121 } | 123 } |
122 | 124 |
123 CPUArchitecture SystemSnapshotWin::GetCPUArchitecture() const { | 125 CPUArchitecture SystemSnapshotWin::GetCPUArchitecture() const { |
124 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 126 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
125 | 127 |
126 return process_reader_->Is64Bit() ? kCPUArchitectureX86_64 | 128 return process_reader_->Is64Bit() ? kCPUArchitectureX86_64 |
127 : kCPUArchitectureX86; | 129 : kCPUArchitectureX86; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 *standard_offset_seconds = | 329 *standard_offset_seconds = |
328 (time_zone_information.Bias + time_zone_information.StandardBias) * -60; | 330 (time_zone_information.Bias + time_zone_information.StandardBias) * -60; |
329 *daylight_offset_seconds = | 331 *daylight_offset_seconds = |
330 (time_zone_information.Bias + time_zone_information.DaylightBias) * -60; | 332 (time_zone_information.Bias + time_zone_information.DaylightBias) * -60; |
331 *standard_name = base::UTF16ToUTF8(time_zone_information.StandardName); | 333 *standard_name = base::UTF16ToUTF8(time_zone_information.StandardName); |
332 *daylight_name = base::UTF16ToUTF8(time_zone_information.DaylightName); | 334 *daylight_name = base::UTF16ToUTF8(time_zone_information.DaylightName); |
333 } | 335 } |
334 | 336 |
335 } // namespace internal | 337 } // namespace internal |
336 } // namespace crashpad | 338 } // namespace crashpad |
OLD | NEW |