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

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

Issue 1369833002: win: Gather memory information (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@save-peb-stuff
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') | util/win/process_info.cc » ('J')
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 //! \brief The base address of the loaded DLL. 42 //! \brief The base address of the loaded DLL.
43 WinVMAddress dll_base; 43 WinVMAddress dll_base;
44 44
45 //! \brief The size of the module. 45 //! \brief The size of the module.
46 WinVMSize size; 46 WinVMSize size;
47 47
48 //! \brief The module's timestamp. 48 //! \brief The module's timestamp.
49 time_t timestamp; 49 time_t timestamp;
50 }; 50 };
51 51
52 // \brief Contains information about a range of pages in the virtual address
53 // space of a process.
54 struct MemoryInfo {
55 MemoryInfo();
56
57 //! \brief Constructs a MemoryInfo object from MEMORY_BASIC_INFORMATION32 or
58 //! MEMORY_BASIC_INFORMATION64.
59 template <class MBI>
60 explicit MemoryInfo(const MBI& mbi);
61
62 ~MemoryInfo();
63
64 //! \brief The base address of the region of pages.
65 WinVMAddress base_address;
66
67 //! \brief The size of the region beginning at base_address in bytes.
68 WinVMSize region_size;
69
70 //! \brief The base address of a range of pages that was allocated by
71 //! `VirtualAlloc()`. The page pointed to base_address is within this
72 //! range of pages.
73 WinVMAddress allocation_base;
74
75 //! \brief The state of the pages, one of `MEM_COMMIT`, `MEM_FREE`, or
76 //! `MEM_RESERVE`.
77 uint32_t state;
78
79 //! \brief The memory protection option when this page was originally
80 //! allocated. This will be `PAGE_EXECUTE`, `PAGE_EXECUTE_READ`, etc.
81 uint32_t allocation_protect;
82
83 //! \brief The current memoryprotection state. This will be `PAGE_EXECUTE`,
84 //! `PAGE_EXECUTE_READ`, etc.
85 uint32_t protect;
86
87 //! \brief The type of the pages. This will be one of `MEM_IMAGE`,
88 //! `MEM_MAPPED`, or `MEM_PRIVATE`.
89 uint32_t type;
90 };
91
52 ProcessInfo(); 92 ProcessInfo();
53 ~ProcessInfo(); 93 ~ProcessInfo();
54 94
55 //! \brief Initializes this object with information about the given 95 //! \brief Initializes this object with information about the given
56 //! \a process. 96 //! \a process.
57 //! 97 //!
58 //! This method must be called successfully prior to calling any other 98 //! This method must be called successfully prior to calling any other
59 //! method in this class. This method may only be called once. 99 //! method in this class. This method may only be called once.
60 //! 100 //!
61 //! \return `true` on success, `false` on failure with a message logged. 101 //! \return `true` on success, `false` on failure with a message logged.
(...skipping 23 matching lines...) Expand all
85 //! \param[out] peb_size The size of the Process Environment Block. 125 //! \param[out] peb_size The size of the Process Environment Block.
86 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const; 126 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const;
87 127
88 //! \brief Retrieves the modules loaded into the target process. 128 //! \brief Retrieves the modules loaded into the target process.
89 //! 129 //!
90 //! The modules are enumerated in initialization order as detailed in the 130 //! The modules are enumerated in initialization order as detailed in the
91 //! Process Environment Block. The main executable will always be the 131 //! Process Environment Block. The main executable will always be the
92 //! first element. 132 //! first element.
93 bool Modules(std::vector<Module>* modules) const; 133 bool Modules(std::vector<Module>* modules) const;
94 134
135 //! \brief Retrieves information about all pages mapped into the process.
136 const std::vector<MemoryInfo>& MemoryInformation() const;
137
95 private: 138 private:
96 template <class Traits> 139 template <class Traits>
97 friend bool GetProcessBasicInformation(HANDLE process, 140 friend bool GetProcessBasicInformation(HANDLE process,
98 bool is_wow64, 141 bool is_wow64,
99 ProcessInfo* process_info, 142 ProcessInfo* process_info,
100 WinVMAddress* peb_address, 143 WinVMAddress* peb_address,
101 WinVMSize* peb_size); 144 WinVMSize* peb_size);
102 template <class Traits> 145 template <class Traits>
103 friend bool ReadProcessData(HANDLE process, 146 friend bool ReadProcessData(HANDLE process,
104 WinVMAddress peb_address_vmaddr, 147 WinVMAddress peb_address_vmaddr,
105 ProcessInfo* process_info); 148 ProcessInfo* process_info);
106 149
150 template <class Traits>
151 friend bool ReadMemoryInfo(HANDLE process, ProcessInfo* process_info);
152
107 pid_t process_id_; 153 pid_t process_id_;
108 pid_t inherited_from_process_id_; 154 pid_t inherited_from_process_id_;
109 std::wstring command_line_; 155 std::wstring command_line_;
110 WinVMAddress peb_address_; 156 WinVMAddress peb_address_;
111 WinVMSize peb_size_; 157 WinVMSize peb_size_;
112 std::vector<Module> modules_; 158 std::vector<Module> modules_;
159 std::vector<MemoryInfo> memory_info_;
113 bool is_64_bit_; 160 bool is_64_bit_;
114 bool is_wow64_; 161 bool is_wow64_;
115 InitializationStateDcheck initialized_; 162 InitializationStateDcheck initialized_;
116 163
117 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); 164 DISALLOW_COPY_AND_ASSIGN(ProcessInfo);
118 }; 165 };
119 166
120 } // namespace crashpad 167 } // namespace crashpad
121 168
122 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ 169 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_
OLDNEW
« no previous file with comments | « no previous file | util/win/process_info.cc » ('j') | util/win/process_info.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698