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

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

Issue 1400413002: win: Add Handles() to ProcessInfo (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: test 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
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 struct Handle {
54 Handle();
55 ~Handle();
56
57 //! \brief A string representation of the handle's type.
58 std::wstring type_name;
59
60 //! \brief The handle's value.
61 uint32_t handle;
Mark Mentovai 2015/10/14 22:49:55 This is at least as good a place for the comment a
scottmg 2015/10/15 00:17:42 Done.
62
63 //! \brief The attributes for the handle, e.g. `OBJ_INHERIT`,
64 //! `OBJ_CASE_INSENSITIVE`, etc.
65 uint32_t attributes;
66
67 //! \brief The ACCESS_MASK for the handle in this process. Ref:
Mark Mentovai 2015/10/14 22:49:55 `ACCESS_MASK`
scottmg 2015/10/15 00:17:42 Done.
68 //! http://blogs.msdn.com/b/openspecification/archive/2010/04/01/about-the-a ccess-mask-structure.aspx
Mark Mentovai 2015/10/14 22:49:55 The URL reference shouldn’t be part of the \brief.
scottmg 2015/10/15 00:17:42 Done.
69 uint32_t granted_access;
70
71 //! \brief The number of kernel references to the object that this handle
72 //! refers to.
73 uint32_t pointer_count;
74
75 //! \brief The number of open handles to the object that this handle refers
76 //! to.
77 uint32_t handle_count;
78 };
79
53 ProcessInfo(); 80 ProcessInfo();
54 ~ProcessInfo(); 81 ~ProcessInfo();
55 82
56 //! \brief Initializes this object with information about the given 83 //! \brief Initializes this object with information about the given
57 //! \a process. 84 //! \a process.
58 //! 85 //!
59 //! This method must be called successfully prior to calling any other 86 //! This method must be called successfully prior to calling any other
60 //! method in this class. This method may only be called once. 87 //! method in this class. This method may only be called once.
61 //! 88 //!
62 //! \return `true` on success, `false` on failure with a message logged. 89 //! \return `true` on success, `false` on failure with a message logged.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 //! \brief Given a range to be read from the target process, returns a vector 126 //! \brief Given a range to be read from the target process, returns a vector
100 //! of ranges, representing the readable portions of the original range. 127 //! of ranges, representing the readable portions of the original range.
101 //! 128 //!
102 //! \param[in] range The range being identified. 129 //! \param[in] range The range being identified.
103 //! 130 //!
104 //! \return A vector of ranges corresponding to the portion of \a range that 131 //! \return A vector of ranges corresponding to the portion of \a range that
105 //! is readable based on the memory map. 132 //! is readable based on the memory map.
106 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( 133 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges(
107 const CheckedRange<WinVMAddress, WinVMSize>& range) const; 134 const CheckedRange<WinVMAddress, WinVMSize>& range) const;
108 135
136 //! \brief Retrieves information about open handles in the target process.
137 const std::vector<Handle>& Handles() const { return handles_; }
138
109 private: 139 private:
110 template <class Traits> 140 template <class Traits>
111 friend bool GetProcessBasicInformation(HANDLE process, 141 friend bool GetProcessBasicInformation(HANDLE process,
112 bool is_wow64, 142 bool is_wow64,
113 ProcessInfo* process_info, 143 ProcessInfo* process_info,
114 WinVMAddress* peb_address, 144 WinVMAddress* peb_address,
115 WinVMSize* peb_size); 145 WinVMSize* peb_size);
116 template <class Traits> 146 template <class Traits>
117 friend bool ReadProcessData(HANDLE process, 147 friend bool ReadProcessData(HANDLE process,
118 WinVMAddress peb_address_vmaddr, 148 WinVMAddress peb_address_vmaddr,
119 ProcessInfo* process_info); 149 ProcessInfo* process_info);
120 150
121 friend bool ReadMemoryInfo(HANDLE process, 151 friend bool ReadMemoryInfo(HANDLE process,
122 bool is_64_bit, 152 bool is_64_bit,
123 ProcessInfo* process_info); 153 ProcessInfo* process_info);
124 154
155 template <class Traits>
156 std::vector<Handle> BuildHandleVector(HANDLE process) const;
157
125 pid_t process_id_; 158 pid_t process_id_;
126 pid_t inherited_from_process_id_; 159 pid_t inherited_from_process_id_;
127 std::wstring command_line_; 160 std::wstring command_line_;
128 WinVMAddress peb_address_; 161 WinVMAddress peb_address_;
129 WinVMSize peb_size_; 162 WinVMSize peb_size_;
130 std::vector<Module> modules_; 163 std::vector<Module> modules_;
131 std::vector<MEMORY_BASIC_INFORMATION64> memory_info_; 164 std::vector<MEMORY_BASIC_INFORMATION64> memory_info_;
165 std::vector<Handle> handles_;
132 bool is_64_bit_; 166 bool is_64_bit_;
133 bool is_wow64_; 167 bool is_wow64_;
134 InitializationStateDcheck initialized_; 168 InitializationStateDcheck initialized_;
135 169
136 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); 170 DISALLOW_COPY_AND_ASSIGN(ProcessInfo);
137 }; 171 };
138 172
139 //! \brief Given a memory map of a process, and a range to be read from the 173 //! \brief Given a memory map of a process, and a range to be read from the
140 //! target process, returns a vector of ranges, representing the readable 174 //! target process, returns a vector of ranges, representing the readable
141 //! portions of the original range. 175 //! portions of the original range.
142 //! 176 //!
143 //! This is a free function for testing, but prefer 177 //! This is a free function for testing, but prefer
144 //! ProcessInfo::GetReadableRanges(). 178 //! ProcessInfo::GetReadableRanges().
145 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( 179 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap(
146 const CheckedRange<WinVMAddress, WinVMSize>& range, 180 const CheckedRange<WinVMAddress, WinVMSize>& range,
147 const std::vector<MEMORY_BASIC_INFORMATION64>& memory_info); 181 const std::vector<MEMORY_BASIC_INFORMATION64>& memory_info);
148 182
149 } // namespace crashpad 183 } // namespace crashpad
150 184
151 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ 185 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698