Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: util/win/process_info.h

Issue 1372183002: win: Add memory map range intersection helper (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/numeric/checked_range_test.cc ('k') | util/win/process_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #ifndef CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ 15 #ifndef CRASHPAD_UTIL_WIN_PROCESS_INFO_H_
16 #define CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ 16 #define CRASHPAD_UTIL_WIN_PROCESS_INFO_H_
17 17
18 #include <sys/types.h> 18 #include <sys/types.h>
19 #include <windows.h> 19 #include <windows.h>
20 20
21 #include <string> 21 #include <string>
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/basictypes.h" 24 #include "base/basictypes.h"
25 #include "util/misc/initialization_state_dcheck.h" 25 #include "util/misc/initialization_state_dcheck.h"
26 #include "util/numeric/checked_range.h"
26 #include "util/win/address_types.h" 27 #include "util/win/address_types.h"
27 28
28 namespace crashpad { 29 namespace crashpad {
29 30
30 //! \brief Gathers information about a process given its `HANDLE`. This consists 31 //! \brief Gathers information about a process given its `HANDLE`. This consists
31 //! primarily of information stored in the Process Environment Block. 32 //! primarily of information stored in the Process Environment Block.
32 class ProcessInfo { 33 class ProcessInfo {
33 public: 34 public:
34 //! \brief Contains information about a module loaded into a process. 35 //! \brief Contains information about a module loaded into a process.
35 struct Module { 36 struct Module {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 //! \brief Retrieves the modules loaded into the target process. 123 //! \brief Retrieves the modules loaded into the target process.
123 //! 124 //!
124 //! The modules are enumerated in initialization order as detailed in the 125 //! The modules are enumerated in initialization order as detailed in the
125 //! Process Environment Block. The main executable will always be the 126 //! Process Environment Block. The main executable will always be the
126 //! first element. 127 //! first element.
127 bool Modules(std::vector<Module>* modules) const; 128 bool Modules(std::vector<Module>* modules) const;
128 129
129 //! \brief Retrieves information about all pages mapped into the process. 130 //! \brief Retrieves information about all pages mapped into the process.
130 const std::vector<MemoryInfo>& MemoryInformation() const; 131 const std::vector<MemoryInfo>& MemoryInformation() const;
131 132
133 //! \brief Given a range to be read from the target process, returns a vector
134 //! of ranges, representing the readable portions of the original range.
135 //!
136 //! \param[in] range The range being identified.
137 //!
138 //! \return A vector of ranges corresponding to the portion of \a range that
139 //! is readable based on the memory map.
140 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges(
141 const CheckedRange<WinVMAddress, WinVMSize>& range) const;
142
132 private: 143 private:
133 template <class Traits> 144 template <class Traits>
134 friend bool GetProcessBasicInformation(HANDLE process, 145 friend bool GetProcessBasicInformation(HANDLE process,
135 bool is_wow64, 146 bool is_wow64,
136 ProcessInfo* process_info, 147 ProcessInfo* process_info,
137 WinVMAddress* peb_address, 148 WinVMAddress* peb_address,
138 WinVMSize* peb_size); 149 WinVMSize* peb_size);
139 template <class Traits> 150 template <class Traits>
140 friend bool ReadProcessData(HANDLE process, 151 friend bool ReadProcessData(HANDLE process,
141 WinVMAddress peb_address_vmaddr, 152 WinVMAddress peb_address_vmaddr,
142 ProcessInfo* process_info); 153 ProcessInfo* process_info);
143 154
144 friend bool ReadMemoryInfo(HANDLE process, ProcessInfo* process_info); 155 friend bool ReadMemoryInfo(HANDLE process, ProcessInfo* process_info);
145 156
146 pid_t process_id_; 157 pid_t process_id_;
147 pid_t inherited_from_process_id_; 158 pid_t inherited_from_process_id_;
148 std::wstring command_line_; 159 std::wstring command_line_;
149 WinVMAddress peb_address_; 160 WinVMAddress peb_address_;
150 WinVMSize peb_size_; 161 WinVMSize peb_size_;
151 std::vector<Module> modules_; 162 std::vector<Module> modules_;
152 std::vector<MemoryInfo> memory_info_; 163 std::vector<MemoryInfo> memory_info_;
153 bool is_64_bit_; 164 bool is_64_bit_;
154 bool is_wow64_; 165 bool is_wow64_;
155 InitializationStateDcheck initialized_; 166 InitializationStateDcheck initialized_;
156 167
157 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); 168 DISALLOW_COPY_AND_ASSIGN(ProcessInfo);
158 }; 169 };
159 170
171 //! \brief Given a memory map of a process, and a range to be read from the
172 //! target process, returns a vector of ranges, representing the readable
173 //! portions of the original range.
174 //!
175 //! This is a free function for testing, but prefer
176 //! ProcessInfo::GetReadableRanges().
177 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap(
178 const CheckedRange<WinVMAddress, WinVMSize>& range,
179 const std::vector<ProcessInfo::MemoryInfo>& memory_info);
180
160 } // namespace crashpad 181 } // namespace crashpad
161 182
162 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ 183 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_
OLDNEW
« no previous file with comments | « util/numeric/checked_range_test.cc ('k') | util/win/process_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698