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

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

Issue 1375313005: Use MEMORY_BASIC_INFORMATION64 rather than a custom MemoryInfo (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@save-peb-more-2
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 | « no previous file | 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,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 //! \brief The base address of the loaded DLL. 43 //! \brief The base address of the loaded DLL.
44 WinVMAddress dll_base; 44 WinVMAddress dll_base;
45 45
46 //! \brief The size of the module. 46 //! \brief The size of the module.
47 WinVMSize size; 47 WinVMSize size;
48 48
49 //! \brief The module's timestamp. 49 //! \brief The module's timestamp.
50 time_t timestamp; 50 time_t timestamp;
51 }; 51 };
52 52
53 // \brief Contains information about a range of pages in the virtual address
54 // space of a process.
55 struct MemoryInfo {
56 explicit MemoryInfo(const MEMORY_BASIC_INFORMATION& mbi);
57 ~MemoryInfo();
58
59 //! \brief The base address of the region of pages.
60 WinVMAddress base_address;
61
62 //! \brief The size of the region beginning at base_address in bytes.
63 WinVMSize region_size;
64
65 //! \brief The base address of a range of pages that was allocated by
66 //! `VirtualAlloc()`. The page pointed to base_address is within this
67 //! range of pages.
68 WinVMAddress allocation_base;
69
70 //! \brief The state of the pages, one of `MEM_COMMIT`, `MEM_FREE`, or
71 //! `MEM_RESERVE`.
72 uint32_t state;
73
74 //! \brief The memory protection option when this page was originally
75 //! allocated. This will be `PAGE_EXECUTE`, `PAGE_EXECUTE_READ`, etc.
76 uint32_t allocation_protect;
77
78 //! \brief The current memoryprotection state. This will be `PAGE_EXECUTE`,
79 //! `PAGE_EXECUTE_READ`, etc.
80 uint32_t protect;
81
82 //! \brief The type of the pages. This will be one of `MEM_IMAGE`,
83 //! `MEM_MAPPED`, or `MEM_PRIVATE`.
84 uint32_t type;
85 };
86
87 ProcessInfo(); 53 ProcessInfo();
88 ~ProcessInfo(); 54 ~ProcessInfo();
89 55
90 //! \brief Initializes this object with information about the given 56 //! \brief Initializes this object with information about the given
91 //! \a process. 57 //! \a process.
92 //! 58 //!
93 //! This method must be called successfully prior to calling any other 59 //! This method must be called successfully prior to calling any other
94 //! method in this class. This method may only be called once. 60 //! method in this class. This method may only be called once.
95 //! 61 //!
96 //! \return `true` on success, `false` on failure with a message logged. 62 //! \return `true` on success, `false` on failure with a message logged.
(...skipping 24 matching lines...) Expand all
121 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const; 87 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const;
122 88
123 //! \brief Retrieves the modules loaded into the target process. 89 //! \brief Retrieves the modules loaded into the target process.
124 //! 90 //!
125 //! The modules are enumerated in initialization order as detailed in the 91 //! The modules are enumerated in initialization order as detailed in the
126 //! Process Environment Block. The main executable will always be the 92 //! Process Environment Block. The main executable will always be the
127 //! first element. 93 //! first element.
128 bool Modules(std::vector<Module>* modules) const; 94 bool Modules(std::vector<Module>* modules) const;
129 95
130 //! \brief Retrieves information about all pages mapped into the process. 96 //! \brief Retrieves information about all pages mapped into the process.
131 const std::vector<MemoryInfo>& MemoryInformation() const; 97 const std::vector<MEMORY_BASIC_INFORMATION64>& MemoryInfo() const;
132 98
133 //! \brief Given a range to be read from the target process, returns a vector 99 //! \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. 100 //! of ranges, representing the readable portions of the original range.
135 //! 101 //!
136 //! \param[in] range The range being identified. 102 //! \param[in] range The range being identified.
137 //! 103 //!
138 //! \return A vector of ranges corresponding to the portion of \a range that 104 //! \return A vector of ranges corresponding to the portion of \a range that
139 //! is readable based on the memory map. 105 //! is readable based on the memory map.
140 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( 106 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges(
141 const CheckedRange<WinVMAddress, WinVMSize>& range) const; 107 const CheckedRange<WinVMAddress, WinVMSize>& range) const;
(...skipping 13 matching lines...) Expand all
155 friend bool ReadMemoryInfo(HANDLE process, 121 friend bool ReadMemoryInfo(HANDLE process,
156 bool is_64_bit, 122 bool is_64_bit,
157 ProcessInfo* process_info); 123 ProcessInfo* process_info);
158 124
159 pid_t process_id_; 125 pid_t process_id_;
160 pid_t inherited_from_process_id_; 126 pid_t inherited_from_process_id_;
161 std::wstring command_line_; 127 std::wstring command_line_;
162 WinVMAddress peb_address_; 128 WinVMAddress peb_address_;
163 WinVMSize peb_size_; 129 WinVMSize peb_size_;
164 std::vector<Module> modules_; 130 std::vector<Module> modules_;
165 std::vector<MemoryInfo> memory_info_; 131 std::vector<MEMORY_BASIC_INFORMATION64> memory_info_;
166 bool is_64_bit_; 132 bool is_64_bit_;
167 bool is_wow64_; 133 bool is_wow64_;
168 InitializationStateDcheck initialized_; 134 InitializationStateDcheck initialized_;
169 135
170 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); 136 DISALLOW_COPY_AND_ASSIGN(ProcessInfo);
171 }; 137 };
172 138
173 //! \brief Given a memory map of a process, and a range to be read from the 139 //! \brief Given a memory map of a process, and a range to be read from the
174 //! target process, returns a vector of ranges, representing the readable 140 //! target process, returns a vector of ranges, representing the readable
175 //! portions of the original range. 141 //! portions of the original range.
176 //! 142 //!
177 //! This is a free function for testing, but prefer 143 //! This is a free function for testing, but prefer
178 //! ProcessInfo::GetReadableRanges(). 144 //! ProcessInfo::GetReadableRanges().
179 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( 145 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap(
180 const CheckedRange<WinVMAddress, WinVMSize>& range, 146 const CheckedRange<WinVMAddress, WinVMSize>& range,
181 const std::vector<ProcessInfo::MemoryInfo>& memory_info); 147 const std::vector<MEMORY_BASIC_INFORMATION64>& memory_info);
182 148
183 } // namespace crashpad 149 } // namespace crashpad
184 150
185 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ 151 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_
OLDNEW
« no previous file with comments | « no previous file | util/win/process_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698